From 414a9e6c8630d31c749fff387a5a2dce4daea881 Mon Sep 17 00:00:00 2001 From: Bert Blommers Date: Sat, 29 Jul 2023 22:26:04 +0000 Subject: [PATCH] Techdebt: Replace sure with regular assertions in Glue (#6568) --- tests/test_glue/test_datacatalog.py | 419 +++++++-------- tests/test_glue/test_glue.py | 73 ++- tests/test_glue/test_glue_job_runs.py | 28 +- tests/test_glue/test_partition_filter.py | 95 ++-- tests/test_glue/test_schema_registry.py | 629 +++++++++++------------ 5 files changed, 607 insertions(+), 637 deletions(-) diff --git a/tests/test_glue/test_datacatalog.py b/tests/test_glue/test_datacatalog.py index d8964c66d..c3e0336ee 100644 --- a/tests/test_glue/test_datacatalog.py +++ b/tests/test_glue/test_datacatalog.py @@ -1,5 +1,3 @@ -import sure # noqa # pylint: disable=unused-import -import re import pytest import json import boto3 @@ -29,19 +27,17 @@ def test_create_database(): response = helpers.get_database(client, database_name) database = response["Database"] - database.get("Name").should.equal(database_name) - database.get("Description").should.equal(database_input.get("Description")) - database.get("LocationUri").should.equal(database_input.get("LocationUri")) - database.get("Parameters").should.equal(database_input.get("Parameters")) + assert database.get("Name") == database_name + assert database.get("Description") == database_input.get("Description") + assert database.get("LocationUri") == database_input.get("LocationUri") + assert database.get("Parameters") == database_input.get("Parameters") if not settings.TEST_SERVER_MODE: - database.get("CreateTime").timestamp().should.equal( - FROZEN_CREATE_TIME.timestamp() - ) - database.get("CreateTableDefaultPermissions").should.equal( - database_input.get("CreateTableDefaultPermissions") + assert database["CreateTime"].timestamp() == FROZEN_CREATE_TIME.timestamp() + assert database["CreateTableDefaultPermissions"] == database_input.get( + "CreateTableDefaultPermissions" ) - database.get("TargetDatabase").should.equal(database_input.get("TargetDatabase")) - database.get("CatalogId").should.equal(database_catalog_id) + assert database.get("TargetDatabase") == database_input.get("TargetDatabase") + assert database.get("CatalogId") == database_catalog_id @mock_glue @@ -53,7 +49,7 @@ def test_create_database_already_exists(): with pytest.raises(ClientError) as exc: helpers.create_database(client, database_name) - exc.value.response["Error"]["Code"].should.equal("AlreadyExistsException") + assert exc.value.response["Error"]["Code"] == "AlreadyExistsException" @mock_glue @@ -64,9 +60,9 @@ def test_get_database_not_exits(): with pytest.raises(ClientError) as exc: helpers.get_database(client, database_name) - exc.value.response["Error"]["Code"].should.equal("EntityNotFoundException") - exc.value.response["Error"]["Message"].should.match( - "Database nosuchdatabase not found" + assert exc.value.response["Error"]["Code"] == "EntityNotFoundException" + assert ( + exc.value.response["Error"]["Message"] == "Database nosuchdatabase not found." ) @@ -74,7 +70,7 @@ def test_get_database_not_exits(): def test_get_databases_empty(): client = boto3.client("glue", region_name="us-east-1") response = client.get_databases() - response["DatabaseList"].should.have.length_of(0) + assert len(response["DatabaseList"]) == 0 @mock_glue @@ -88,9 +84,9 @@ def test_get_databases_several_items(): database_list = sorted( client.get_databases()["DatabaseList"], key=lambda x: x["Name"] ) - database_list.should.have.length_of(2) - database_list[0]["Name"].should.equal(database_name_1) - database_list[1]["Name"].should.equal(database_name_2) + assert len(database_list) == 2 + assert database_list[0]["Name"] == database_name_1 + assert database_list[1]["Name"] == database_name_2 @mock_glue @@ -104,9 +100,9 @@ def test_update_database(): response = helpers.get_database(client, database_name) database = response["Database"] - database.get("CatalogId").should.equal(database_catalog_id) - database.get("Description").should.be.none - database.get("LocationUri").should.be.none + assert database.get("CatalogId") == database_catalog_id + assert database.get("Description") is None + assert database.get("LocationUri") is None database_input = { "Name": database_name, @@ -119,9 +115,9 @@ def test_update_database(): response = helpers.get_database(client, database_name) database = response["Database"] - database.get("CatalogId").should.equal(database_catalog_id) - database.get("Description").should.equal("desc") - database.get("LocationUri").should.equal("s3://bucket/existingdatabase/") + assert database.get("CatalogId") == database_catalog_id + assert database.get("Description") == "desc" + assert database.get("LocationUri") == "s3://bucket/existingdatabase/" @mock_glue @@ -131,8 +127,8 @@ def test_update_unknown_database(): with pytest.raises(ClientError) as exc: client.update_database(Name="x", DatabaseInput={"Name": "x"}) err = exc.value.response["Error"] - err["Code"].should.equal("EntityNotFoundException") - err["Message"].should.equal("Database x not found.") + assert err["Code"] == "EntityNotFoundException" + assert err["Message"] == "Database x not found." @mock_glue @@ -148,7 +144,7 @@ def test_delete_database(): database_list = sorted( client.get_databases()["DatabaseList"], key=lambda x: x["Name"] ) - [db["Name"] for db in database_list].should.equal([database_name_2]) + assert [db["Name"] for db in database_list] == [database_name_2] @mock_glue @@ -158,8 +154,8 @@ def test_delete_unknown_database(): with pytest.raises(ClientError) as exc: client.delete_database(Name="x") err = exc.value.response["Error"] - err["Code"].should.equal("EntityNotFoundException") - err["Message"].should.equal("Database x not found.") + assert err["Code"] == "EntityNotFoundException" + assert err["Message"] == "Database x not found." @mock_glue @@ -177,11 +173,11 @@ def test_create_table(): table = response["Table"] if not settings.TEST_SERVER_MODE: - table["CreateTime"].timestamp().should.equal(FROZEN_CREATE_TIME.timestamp()) + assert table["CreateTime"].timestamp() == FROZEN_CREATE_TIME.timestamp() - table["Name"].should.equal(table_input["Name"]) - table["StorageDescriptor"].should.equal(table_input["StorageDescriptor"]) - table["PartitionKeys"].should.equal(table_input["PartitionKeys"]) + assert table["Name"] == table_input["Name"] + assert table["StorageDescriptor"] == table_input["StorageDescriptor"] + assert table["PartitionKeys"] == table_input["PartitionKeys"] @mock_glue @@ -196,7 +192,7 @@ def test_create_table_already_exists(): with pytest.raises(ClientError) as exc: helpers.create_table(client, database_name, table_name) - exc.value.response["Error"]["Code"].should.equal("AlreadyExistsException") + assert exc.value.response["Error"]["Code"] == "AlreadyExistsException" @mock_glue @@ -217,15 +213,15 @@ def test_get_tables(): tables = response["TableList"] - tables.should.have.length_of(3) + assert len(tables) == 3 for table in tables: table_name = table["Name"] - table_name.should.equal(table_inputs[table_name]["Name"]) - table["StorageDescriptor"].should.equal( - table_inputs[table_name]["StorageDescriptor"] + assert table_name == table_inputs[table_name]["Name"] + assert ( + table["StorageDescriptor"] == table_inputs[table_name]["StorageDescriptor"] ) - table["PartitionKeys"].should.equal(table_inputs[table_name]["PartitionKeys"]) + assert table["PartitionKeys"] == table_inputs[table_name]["PartitionKeys"] @mock_glue @@ -295,15 +291,15 @@ def test_get_tables_expression(): tables_star_expression5 = response_star_expression5["TableList"] tables_star_expression6 = response_star_expression6["TableList"] - tables_prefix.should.have.length_of(2) - tables_postfix.should.have.length_of(1) - tables_string_match.should.have.length_of(3) - tables_star_expression1.should.have.length_of(8) - tables_star_expression2.should.have.length_of(2) - tables_star_expression3.should.have.length_of(3) - tables_star_expression4.should.have.length_of(3) - tables_star_expression5.should.have.length_of(3) - tables_star_expression6.should.have.length_of(2) + assert len(tables_prefix) == 2 + assert len(tables_postfix) == 1 + assert len(tables_string_match) == 3 + assert len(tables_star_expression1) == 8 + assert len(tables_star_expression2) == 2 + assert len(tables_star_expression3) == 3 + assert len(tables_star_expression4) == 3 + assert len(tables_star_expression5) == 3 + assert len(tables_star_expression6) == 2 @mock_glue @@ -321,8 +317,8 @@ def test_get_table_versions(): # Get table should retrieve the first version table = client.get_table(DatabaseName=database_name, Name=table_name)["Table"] - table["StorageDescriptor"]["Columns"].should.equal([]) - table["VersionId"].should.equal("1") + assert table["StorageDescriptor"]["Columns"] == [] + assert table["VersionId"] == "1" columns = [{"Name": "country", "Type": "string"}] table_input = helpers.create_table_input(database_name, table_name, columns=columns) @@ -337,36 +333,36 @@ def test_get_table_versions(): vers = response["TableVersions"] - vers.should.have.length_of(3) - vers[0]["Table"]["StorageDescriptor"]["Columns"].should.equal([]) - vers[-1]["Table"]["StorageDescriptor"]["Columns"].should.equal(columns) + assert len(vers) == 3 + assert vers[0]["Table"]["StorageDescriptor"]["Columns"] == [] + assert vers[-1]["Table"]["StorageDescriptor"]["Columns"] == columns for n, ver in enumerate(vers): n = str(n + 1) - ver["VersionId"].should.equal(n) - ver["Table"]["VersionId"].should.equal(n) - ver["Table"]["Name"].should.equal(table_name) - ver["Table"]["StorageDescriptor"].should.equal( - version_inputs[n]["StorageDescriptor"] + assert ver["VersionId"] == n + assert ver["Table"]["VersionId"] == n + assert ver["Table"]["Name"] == table_name + assert ( + ver["Table"]["StorageDescriptor"] == version_inputs[n]["StorageDescriptor"] ) - ver["Table"]["PartitionKeys"].should.equal(version_inputs[n]["PartitionKeys"]) - ver["Table"].should.have.key("UpdateTime") + assert ver["Table"]["PartitionKeys"] == version_inputs[n]["PartitionKeys"] + assert "UpdateTime" in ver["Table"] response = helpers.get_table_version(client, database_name, table_name, "3") ver = response["TableVersion"] - ver["VersionId"].should.equal("3") - ver["Table"]["Name"].should.equal(table_name) - ver["Table"]["StorageDescriptor"]["Columns"].should.equal(columns) + assert ver["VersionId"] == "3" + assert ver["Table"]["Name"] == table_name + assert ver["Table"]["StorageDescriptor"]["Columns"] == columns # get_table should retrieve the latest version table = client.get_table(DatabaseName=database_name, Name=table_name)["Table"] - table["StorageDescriptor"]["Columns"].should.equal(columns) - table["VersionId"].should.equal("3") + assert table["StorageDescriptor"]["Columns"] == columns + assert table["VersionId"] == "3" table = client.get_tables(DatabaseName=database_name)["TableList"][0] - table["StorageDescriptor"]["Columns"].should.equal(columns) - table["VersionId"].should.equal("3") + assert table["StorageDescriptor"]["Columns"] == columns + assert table["VersionId"] == "3" @mock_glue @@ -380,8 +376,8 @@ def test_get_table_version_not_found(): with pytest.raises(ClientError) as exc: helpers.get_table_version(client, database_name, "myfirsttable", "20") - exc.value.response["Error"]["Code"].should.equal("EntityNotFoundException") - exc.value.response["Error"]["Message"].should.match("version", re.I) + assert exc.value.response["Error"]["Code"] == "EntityNotFoundException" + assert exc.value.response["Error"]["Message"] == "Version not found." @mock_glue @@ -395,7 +391,7 @@ def test_get_table_version_invalid_input(): with pytest.raises(ClientError) as exc: helpers.get_table_version(client, database_name, "myfirsttable", "10not-an-int") - exc.value.response["Error"]["Code"].should.equal("InvalidInputException") + assert exc.value.response["Error"]["Code"] == "InvalidInputException" @mock_glue @@ -422,7 +418,7 @@ def test_delete_table_version(): response = helpers.get_table_versions(client, database_name, table_name) vers = response["TableVersions"] - vers.should.have.length_of(3) + assert len(vers) == 3 client.delete_table_version( DatabaseName=database_name, TableName=table_name, VersionId="2" @@ -430,8 +426,8 @@ def test_delete_table_version(): response = helpers.get_table_versions(client, database_name, table_name) vers = response["TableVersions"] - vers.should.have.length_of(2) - [v["VersionId"] for v in vers].should.equal(["1", "3"]) + assert len(vers) == 2 + assert [v["VersionId"] for v in vers] == ["1", "3"] @mock_glue @@ -443,8 +439,8 @@ def test_get_table_not_exits(): with pytest.raises(ClientError) as exc: helpers.get_table(client, database_name, "myfirsttable") - exc.value.response["Error"]["Code"].should.equal("EntityNotFoundException") - exc.value.response["Error"]["Message"].should.match("Table myfirsttable not found") + assert exc.value.response["Error"]["Code"] == "EntityNotFoundException" + assert exc.value.response["Error"]["Message"] == "Table myfirsttable not found." @mock_glue @@ -455,9 +451,9 @@ def test_get_table_when_database_not_exits(): with pytest.raises(ClientError) as exc: helpers.get_table(client, database_name, "myfirsttable") - exc.value.response["Error"]["Code"].should.equal("EntityNotFoundException") - exc.value.response["Error"]["Message"].should.match( - "Database nosuchdatabase not found" + assert exc.value.response["Error"]["Code"] == "EntityNotFoundException" + assert ( + exc.value.response["Error"]["Message"] == "Database nosuchdatabase not found." ) @@ -472,16 +468,14 @@ def test_delete_table(): helpers.create_table(client, database_name, table_name, table_input) result = client.delete_table(DatabaseName=database_name, Name=table_name) - result["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert result["ResponseMetadata"]["HTTPStatusCode"] == 200 # confirm table is deleted with pytest.raises(ClientError) as exc: helpers.get_table(client, database_name, table_name) - exc.value.response["Error"]["Code"].should.equal("EntityNotFoundException") - exc.value.response["Error"]["Message"].should.match( - "Table myspecialtable not found" - ) + assert exc.value.response["Error"]["Code"] == "EntityNotFoundException" + assert exc.value.response["Error"]["Message"] == "Table myspecialtable not found." @mock_glue @@ -497,16 +491,14 @@ def test_batch_delete_table(): result = client.batch_delete_table( DatabaseName=database_name, TablesToDelete=[table_name] ) - result["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert result["ResponseMetadata"]["HTTPStatusCode"] == 200 # confirm table is deleted with pytest.raises(ClientError) as exc: helpers.get_table(client, database_name, table_name) - exc.value.response["Error"]["Code"].should.equal("EntityNotFoundException") - exc.value.response["Error"]["Message"].should.match( - "Table myspecialtable not found" - ) + assert exc.value.response["Error"]["Code"] == "EntityNotFoundException" + assert exc.value.response["Error"]["Message"] == "Table myspecialtable not found." @mock_glue @@ -520,7 +512,7 @@ def test_get_partitions_empty(): response = client.get_partitions(DatabaseName=database_name, TableName=table_name) - response["Partitions"].should.have.length_of(0) + assert len(response["Partitions"]) == 0 @mock_glue @@ -546,15 +538,15 @@ def test_create_partition(): partitions = response["Partitions"] - partitions.should.have.length_of(1) + assert len(partitions) == 1 partition = partitions[0] - partition["TableName"].should.equal(table_name) - partition["StorageDescriptor"].should.equal(part_input["StorageDescriptor"]) - partition["Values"].should.equal(values) - partition["CreationTime"].should.be.greater_than(before) - partition["CreationTime"].should.be.lower_than(after) + assert partition["TableName"] == table_name + assert partition["StorageDescriptor"] == part_input["StorageDescriptor"] + assert partition["Values"] == values + assert partition["CreationTime"] > before + assert partition["CreationTime"] < after @mock_glue @@ -572,7 +564,7 @@ def test_create_partition_already_exist(): with pytest.raises(ClientError) as exc: helpers.create_partition(client, database_name, table_name, values=values) - exc.value.response["Error"]["Code"].should.equal("AlreadyExistsException") + assert exc.value.response["Error"]["Code"] == "AlreadyExistsException" @mock_glue @@ -588,8 +580,8 @@ def test_get_partition_not_found(): with pytest.raises(ClientError) as exc: helpers.get_partition(client, database_name, table_name, values) - exc.value.response["Error"]["Code"].should.equal("EntityNotFoundException") - exc.value.response["Error"]["Message"].should.match("partition") + assert exc.value.response["Error"]["Code"] == "EntityNotFoundException" + assert "partition" in exc.value.response["Error"]["Message"] @mock_glue @@ -623,18 +615,16 @@ def test_batch_create_partition(): partitions = response["Partitions"] - partitions.should.have.length_of(20) + assert len(partitions) == 20 for idx, partition in enumerate(partitions): partition_input = partition_inputs[idx] - partition["TableName"].should.equal(table_name) - partition["StorageDescriptor"].should.equal( - partition_input["StorageDescriptor"] - ) - partition["Values"].should.equal(partition_input["Values"]) - partition["CreationTime"].should.be.greater_than(before) - partition["CreationTime"].should.be.lower_than(after) + assert partition["TableName"] == table_name + assert partition["StorageDescriptor"] == partition_input["StorageDescriptor"] + assert partition["Values"] == partition_input["Values"] + assert partition["CreationTime"] > before + assert partition["CreationTime"] < after @mock_glue @@ -659,12 +649,9 @@ def test_batch_create_partition_already_exist(): PartitionInputList=[partition_input], ) - response.should.have.key("Errors") - response["Errors"].should.have.length_of(1) - response["Errors"][0]["PartitionValues"].should.equal(values) - response["Errors"][0]["ErrorDetail"]["ErrorCode"].should.equal( - "AlreadyExistsException" - ) + assert len(response["Errors"]) == 1 + assert response["Errors"][0]["PartitionValues"] == values + assert response["Errors"][0]["ErrorDetail"]["ErrorCode"] == "AlreadyExistsException" @mock_glue @@ -687,8 +674,8 @@ def test_get_partition(): partition = response["Partition"] - partition["TableName"].should.equal(table_name) - partition["Values"].should.equal(values[1]) + assert partition["TableName"] == table_name + assert partition["Values"] == values[1] @mock_glue @@ -713,11 +700,11 @@ def test_batch_get_partition(): ) partitions = response["Partitions"] - partitions.should.have.length_of(2) + assert len(partitions) == 2 partition = partitions[1] - partition["TableName"].should.equal(table_name) - partition["Values"].should.equal(values[1]) + assert partition["TableName"] == table_name + assert partition["Values"] == values[1] @mock_glue @@ -746,10 +733,10 @@ def test_batch_get_partition_missing_partition(): ) partitions = response["Partitions"] - partitions.should.have.length_of(2) + assert len(partitions) == 2 - partitions[0]["Values"].should.equal(values[0]) - partitions[1]["Values"].should.equal(values[2]) + assert partitions[0]["Values"] == values[0] + assert partitions[1]["Values"] == values[2] @mock_glue @@ -770,8 +757,8 @@ def test_update_partition_not_found_moving(): values=["2018-10-02"], ) - exc.value.response["Error"]["Code"].should.equal("EntityNotFoundException") - exc.value.response["Error"]["Message"].should.match("partition") + assert exc.value.response["Error"]["Code"] == "EntityNotFoundException" + assert "partition" in exc.value.response["Error"]["Message"] @mock_glue @@ -789,8 +776,8 @@ def test_update_partition_not_found_change_in_place(): client, database_name, table_name, old_values=values, values=values ) - exc.value.response["Error"]["Code"].should.equal("EntityNotFoundException") - exc.value.response["Error"]["Message"].should.match("partition") + assert exc.value.response["Error"]["Code"] == "EntityNotFoundException" + assert "partition" in exc.value.response["Error"]["Message"] @mock_glue @@ -812,7 +799,7 @@ def test_update_partition_cannot_overwrite(): client, database_name, table_name, old_values=values[0], values=values[1] ) - exc.value.response["Error"]["Code"].should.equal("AlreadyExistsException") + assert exc.value.response["Error"]["Code"] == "AlreadyExistsException" @mock_glue @@ -840,10 +827,10 @@ def test_update_partition(): ) partition = response["Partition"] - partition["TableName"].should.equal(table_name) - partition["StorageDescriptor"]["Columns"].should.equal( - [{"Name": "country", "Type": "string"}] - ) + assert partition["TableName"] == table_name + assert partition["StorageDescriptor"]["Columns"] == [ + {"Name": "country", "Type": "string"} + ] @mock_glue @@ -871,17 +858,17 @@ def test_update_partition_move(): helpers.get_partition(client, database_name, table_name, values) # Old partition shouldn't exist anymore - exc.value.response["Error"]["Code"].should.equal("EntityNotFoundException") + assert exc.value.response["Error"]["Code"] == "EntityNotFoundException" response = client.get_partition( DatabaseName=database_name, TableName=table_name, PartitionValues=new_values ) partition = response["Partition"] - partition["TableName"].should.equal(table_name) - partition["StorageDescriptor"]["Columns"].should.equal( - [{"Name": "country", "Type": "string"}] - ) + assert partition["TableName"] == table_name + assert partition["StorageDescriptor"]["Columns"] == [ + {"Name": "country", "Type": "string"} + ] @mock_glue @@ -927,7 +914,7 @@ def test_batch_update_partition(): for value in values: with pytest.raises(ClientError) as exc: helpers.get_partition(client, database_name, table_name, value) - exc.value.response["Error"]["Code"].should.equal("EntityNotFoundException") + assert exc.value.response["Error"]["Code"] == "EntityNotFoundException" for value in new_values: response = client.get_partition( @@ -935,10 +922,10 @@ def test_batch_update_partition(): ) partition = response["Partition"] - partition["TableName"].should.equal(table_name) - partition["StorageDescriptor"]["Columns"].should.equal( - [{"Name": "country", "Type": "string"}] - ) + assert partition["TableName"] == table_name + assert partition["StorageDescriptor"]["Columns"] == [ + {"Name": "country", "Type": "string"} + ] @mock_glue @@ -992,9 +979,8 @@ def test_batch_update_partition_missing_partition(): DatabaseName=database_name, TableName=table_name, Entries=batch_update_values ) - response.should.have.key("Errors") - response["Errors"].should.have.length_of(1) - response["Errors"][0]["PartitionValueList"].should.equal(["2020-10-10"]) + assert len(response["Errors"]) == 1 + assert response["Errors"][0]["PartitionValueList"] == ["2020-10-10"] @mock_glue @@ -1017,7 +1003,7 @@ def test_delete_partition(): response = client.get_partitions(DatabaseName=database_name, TableName=table_name) partitions = response["Partitions"] - partitions.should.equal([]) + assert partitions == [] @mock_glue @@ -1034,7 +1020,7 @@ def test_delete_partition_bad_partition(): DatabaseName=database_name, TableName=table_name, PartitionValues=values ) - exc.value.response["Error"]["Code"].should.equal("EntityNotFoundException") + assert exc.value.response["Error"]["Code"] == "EntityNotFoundException" @mock_glue @@ -1067,7 +1053,7 @@ def test_batch_delete_partition(): PartitionsToDelete=partition_values, ) - response.should_not.have.key("Errors") + assert "Errors" not in response @mock_glue @@ -1104,12 +1090,11 @@ def test_batch_delete_partition_with_bad_partitions(): PartitionsToDelete=partition_values, ) - response.should.have.key("Errors") - response["Errors"].should.have.length_of(3) + assert len(response["Errors"]) == 3 error_partitions = map(lambda x: x["PartitionValues"], response["Errors"]) - ["2018-11-01"].should.be.within(error_partitions) - ["2018-11-02"].should.be.within(error_partitions) - ["2018-11-03"].should.be.within(error_partitions) + assert ["2018-11-01"] in error_partitions + assert ["2018-11-02"] in error_partitions + assert ["2018-11-03"] in error_partitions @mock_glue @@ -1168,36 +1153,28 @@ def test_create_crawler_scheduled(): response = client.get_crawler(Name=name) crawler = response["Crawler"] - crawler.get("Name").should.equal(name) - crawler.get("Role").should.equal(role) - crawler.get("DatabaseName").should.equal(database_name) - crawler.get("Description").should.equal(description) - crawler.get("Targets").should.equal(targets) - crawler.get("Schedule").should.equal( - {"ScheduleExpression": schedule, "State": "SCHEDULED"} - ) - crawler.get("Classifiers").should.equal(classifiers) - crawler.get("TablePrefix").should.equal(table_prefix) - crawler.get("SchemaChangePolicy").should.equal(schema_change_policy) - crawler.get("RecrawlPolicy").should.equal(recrawl_policy) - crawler.get("LineageConfiguration").should.equal(lineage_configuration) - crawler.get("Configuration").should.equal(configuration) - crawler.get("CrawlerSecurityConfiguration").should.equal( - crawler_security_configuration - ) + assert crawler.get("Name") == name + assert crawler.get("Role") == role + assert crawler.get("DatabaseName") == database_name + assert crawler.get("Description") == description + assert crawler.get("Targets") == targets + assert crawler["Schedule"] == {"ScheduleExpression": schedule, "State": "SCHEDULED"} + assert crawler.get("Classifiers") == classifiers + assert crawler.get("TablePrefix") == table_prefix + assert crawler.get("SchemaChangePolicy") == schema_change_policy + assert crawler.get("RecrawlPolicy") == recrawl_policy + assert crawler.get("LineageConfiguration") == lineage_configuration + assert crawler.get("Configuration") == configuration + assert crawler["CrawlerSecurityConfiguration"] == crawler_security_configuration - crawler.get("State").should.equal("READY") - crawler.get("CrawlElapsedTime").should.equal(0) - crawler.get("Version").should.equal(1) + assert crawler.get("State") == "READY" + assert crawler.get("CrawlElapsedTime") == 0 + assert crawler.get("Version") == 1 if not settings.TEST_SERVER_MODE: - crawler.get("CreationTime").timestamp().should.equal( - FROZEN_CREATE_TIME.timestamp() - ) - crawler.get("LastUpdated").timestamp().should.equal( - FROZEN_CREATE_TIME.timestamp() - ) + assert crawler["CreationTime"].timestamp() == FROZEN_CREATE_TIME.timestamp() + assert crawler["LastUpdated"].timestamp() == FROZEN_CREATE_TIME.timestamp() - crawler.should.not_have.key("LastCrawl") + assert "LastCrawl" not in crawler @mock_glue @@ -1254,34 +1231,28 @@ def test_create_crawler_unscheduled(): response = client.get_crawler(Name=name) crawler = response["Crawler"] - crawler.get("Name").should.equal(name) - crawler.get("Role").should.equal(role) - crawler.get("DatabaseName").should.equal(database_name) - crawler.get("Description").should.equal(description) - crawler.get("Targets").should.equal(targets) - crawler.should.not_have.key("Schedule") - crawler.get("Classifiers").should.equal(classifiers) - crawler.get("TablePrefix").should.equal(table_prefix) - crawler.get("SchemaChangePolicy").should.equal(schema_change_policy) - crawler.get("RecrawlPolicy").should.equal(recrawl_policy) - crawler.get("LineageConfiguration").should.equal(lineage_configuration) - crawler.get("Configuration").should.equal(configuration) - crawler.get("CrawlerSecurityConfiguration").should.equal( - crawler_security_configuration - ) + assert crawler.get("Name") == name + assert crawler.get("Role") == role + assert crawler.get("DatabaseName") == database_name + assert crawler.get("Description") == description + assert crawler.get("Targets") == targets + assert "Schedule" not in crawler + assert crawler.get("Classifiers") == classifiers + assert crawler.get("TablePrefix") == table_prefix + assert crawler.get("SchemaChangePolicy") == schema_change_policy + assert crawler.get("RecrawlPolicy") == recrawl_policy + assert crawler.get("LineageConfiguration") == lineage_configuration + assert crawler.get("Configuration") == configuration + assert crawler["CrawlerSecurityConfiguration"] == crawler_security_configuration - crawler.get("State").should.equal("READY") - crawler.get("CrawlElapsedTime").should.equal(0) - crawler.get("Version").should.equal(1) + assert crawler.get("State") == "READY" + assert crawler.get("CrawlElapsedTime") == 0 + assert crawler.get("Version") == 1 if not settings.TEST_SERVER_MODE: - crawler.get("CreationTime").timestamp().should.equal( - FROZEN_CREATE_TIME.timestamp() - ) - crawler.get("LastUpdated").timestamp().should.equal( - FROZEN_CREATE_TIME.timestamp() - ) + assert crawler["CreationTime"].timestamp() == FROZEN_CREATE_TIME.timestamp() + assert crawler["LastUpdated"].timestamp() == FROZEN_CREATE_TIME.timestamp() - crawler.should.not_have.key("LastCrawl") + assert "LastCrawl" not in crawler @mock_glue @@ -1293,7 +1264,7 @@ def test_create_crawler_already_exists(): with pytest.raises(ClientError) as exc: helpers.create_crawler(client, name) - exc.value.response["Error"]["Code"].should.equal("AlreadyExistsException") + assert exc.value.response["Error"]["Code"] == "AlreadyExistsException" @mock_glue @@ -1304,9 +1275,9 @@ def test_get_crawler_not_exits(): with pytest.raises(ClientError) as exc: client.get_crawler(Name=name) - exc.value.response["Error"]["Code"].should.equal("EntityNotFoundException") - exc.value.response["Error"]["Message"].should.match( - "Crawler my_crawler_name not found" + assert exc.value.response["Error"]["Code"] == "EntityNotFoundException" + assert ( + exc.value.response["Error"]["Message"] == "Crawler my_crawler_name not found." ) @@ -1314,7 +1285,7 @@ def test_get_crawler_not_exits(): def test_get_crawlers_empty(): client = boto3.client("glue", region_name="us-east-1") response = client.get_crawlers() - response["Crawlers"].should.have.length_of(0) + assert len(response["Crawlers"]) == 0 @mock_glue @@ -1326,9 +1297,9 @@ def test_get_crawlers_several_items(): helpers.create_crawler(client, name_2) crawlers = sorted(client.get_crawlers()["Crawlers"], key=lambda x: x["Name"]) - crawlers.should.have.length_of(2) - crawlers[0].get("Name").should.equal(name_1) - crawlers[1].get("Name").should.equal(name_2) + assert len(crawlers) == 2 + assert crawlers[0].get("Name") == name_1 + assert crawlers[1].get("Name") == name_2 @mock_glue @@ -1342,7 +1313,7 @@ def test_start_crawler(): response = client.get_crawler(Name=name) crawler = response["Crawler"] - crawler.get("State").should.equal("RUNNING") + assert crawler.get("State") == "RUNNING" @mock_glue @@ -1355,7 +1326,7 @@ def test_start_crawler_should_raise_exception_if_already_running(): with pytest.raises(ClientError) as exc: client.start_crawler(Name=name) - exc.value.response["Error"]["Code"].should.equal("CrawlerRunningException") + assert exc.value.response["Error"]["Code"] == "CrawlerRunningException" @mock_glue @@ -1370,7 +1341,7 @@ def test_stop_crawler(): response = client.get_crawler(Name=name) crawler = response["Crawler"] - crawler.get("State").should.equal("STOPPING") + assert crawler.get("State") == "STOPPING" @mock_glue @@ -1382,7 +1353,7 @@ def test_stop_crawler_should_raise_exception_if_not_running(): with pytest.raises(ClientError) as exc: client.stop_crawler(Name=name) - exc.value.response["Error"]["Code"].should.equal("CrawlerNotRunningException") + assert exc.value.response["Error"]["Code"] == "CrawlerNotRunningException" @mock_glue @@ -1392,15 +1363,15 @@ def test_delete_crawler(): helpers.create_crawler(client, name) result = client.delete_crawler(Name=name) - result["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert result["ResponseMetadata"]["HTTPStatusCode"] == 200 # confirm crawler is deleted with pytest.raises(ClientError) as exc: client.get_crawler(Name=name) - exc.value.response["Error"]["Code"].should.equal("EntityNotFoundException") - exc.value.response["Error"]["Message"].should.match( - "Crawler my_crawler_name not found" + assert exc.value.response["Error"]["Code"] == "EntityNotFoundException" + assert ( + exc.value.response["Error"]["Message"] == "Crawler my_crawler_name not found." ) @@ -1412,7 +1383,7 @@ def test_delete_crawler_not_exists(): with pytest.raises(ClientError) as exc: client.delete_crawler(Name=name) - exc.value.response["Error"]["Code"].should.equal("EntityNotFoundException") - exc.value.response["Error"]["Message"].should.match( - "Crawler my_crawler_name not found" + assert exc.value.response["Error"]["Code"] == "EntityNotFoundException" + assert ( + exc.value.response["Error"]["Message"] == "Crawler my_crawler_name not found." ) diff --git a/tests/test_glue/test_glue.py b/tests/test_glue/test_glue.py index a0014cdc1..144c4835b 100644 --- a/tests/test_glue/test_glue.py +++ b/tests/test_glue/test_glue.py @@ -4,7 +4,6 @@ from uuid import uuid4 import boto3 import pytest -import sure # noqa # pylint: disable=unused-import from botocore.exceptions import ParamValidationError from botocore.client import ClientError @@ -42,9 +41,7 @@ def test_create_job_default_argument_not_provided(): with pytest.raises(ParamValidationError) as exc: client.create_job(Role="test_role", Command=dict(Name="test_command")) - exc.value.kwargs["report"].should.equal( - 'Missing required parameter in input: "Name"' - ) + assert exc.value.kwargs["report"] == 'Missing required parameter in input: "Name"' @mock_glue @@ -53,8 +50,8 @@ def test_list_jobs(): expected_jobs = randint(1, 15) create_test_jobs(client, expected_jobs) response = client.list_jobs() - response["JobNames"].should.have.length_of(expected_jobs) - response.shouldnt.have.key("NextToken") + assert len(response["JobNames"]) == expected_jobs + assert "NextToken" not in response @mock_glue @@ -65,8 +62,8 @@ def test_get_job_not_exists(): with pytest.raises(ClientError) as exc: client.get_job(JobName=name) - exc.value.response["Error"]["Code"].should.equal("EntityNotFoundException") - exc.value.response["Error"]["Message"].should.match("Job my_job_name not found") + assert exc.value.response["Error"]["Code"] == "EntityNotFoundException" + assert exc.value.response["Error"]["Message"] == "Job my_job_name not found." @mock_glue @@ -135,8 +132,8 @@ def test_get_jobs_job_name_exists(): client = create_glue_client() test_job_name = create_test_job(client) response = client.get_jobs() - response["Jobs"].should.have.length_of(1) - response["Jobs"][0].should.have.key("Name").equals(test_job_name) + assert len(response["Jobs"]) == 1 + assert response["Jobs"][0]["Name"] == test_job_name @mock_glue @@ -144,8 +141,8 @@ def test_get_jobs_with_max_results(): client = create_glue_client() create_test_jobs(client, 4) response = client.get_jobs(MaxResults=2) - response["Jobs"].should.have.length_of(2) - response.should.have.key("NextToken") + assert len(response["Jobs"]) == 2 + assert "NextToken" in response @mock_glue @@ -154,7 +151,7 @@ def test_get_jobs_from_next_token(): create_test_jobs(client, 10) first_response = client.get_jobs(MaxResults=3) response = client.get_jobs(NextToken=first_response["NextToken"]) - response["Jobs"].should.have.length_of(7) + assert len(response["Jobs"]) == 7 @mock_glue @@ -162,7 +159,7 @@ def test_get_jobs_with_max_results_greater_than_actual_results(): client = create_glue_client() create_test_jobs(client, 4) response = client.get_jobs(MaxResults=10) - response["Jobs"].should.have.length_of(4) + assert len(response["Jobs"]) == 4 @mock_glue @@ -182,8 +179,8 @@ def test_list_jobs_with_max_results(): client = create_glue_client() create_test_jobs(client, 4) response = client.list_jobs(MaxResults=2) - response["JobNames"].should.have.length_of(2) - response.should.have.key("NextToken") + assert len(response["JobNames"]) == 2 + assert "NextToken" in response @mock_glue @@ -192,7 +189,7 @@ def test_list_jobs_from_next_token(): create_test_jobs(client, 10) first_response = client.list_jobs(MaxResults=3) response = client.list_jobs(NextToken=first_response["NextToken"]) - response["JobNames"].should.have.length_of(7) + assert len(response["JobNames"]) == 7 @mock_glue @@ -200,7 +197,7 @@ def test_list_jobs_with_max_results_greater_than_actual_results(): client = create_glue_client() create_test_jobs(client, 4) response = client.list_jobs(MaxResults=10) - response["JobNames"].should.have.length_of(4) + assert len(response["JobNames"]) == 4 @mock_glue @@ -209,7 +206,7 @@ def test_list_jobs_with_tags(): create_test_job(client) create_test_job(client, {"string": "string"}) response = client.list_jobs(Tags={"string": "string"}) - response["JobNames"].should.have.length_of(1) + assert len(response["JobNames"]) == 1 @mock_glue @@ -221,7 +218,7 @@ def test_list_jobs_after_tagging(): client.tag_resource(ResourceArn=resource_arn, TagsToAdd={"key1": "value1"}) response = client.list_jobs(Tags={"key1": "value1"}) - response["JobNames"].should.have.length_of(1) + assert len(response["JobNames"]) == 1 @mock_glue @@ -233,7 +230,7 @@ def test_list_jobs_after_removing_tag(): client.untag_resource(ResourceArn=resource_arn, TagsToRemove=["key1"]) response = client.list_jobs(Tags={"key1": "value1"}) - response["JobNames"].should.have.length_of(0) + assert len(response["JobNames"]) == 0 @mock_glue @@ -306,8 +303,8 @@ def test_list_crawlers_with_max_results(): client = create_glue_client() create_test_crawlers(client, 4) response = client.list_crawlers(MaxResults=2) - response["CrawlerNames"].should.have.length_of(2) - response.should.have.key("NextToken") + assert len(response["CrawlerNames"]) == 2 + assert "NextToken" in response @mock_glue @@ -316,7 +313,7 @@ def test_list_crawlers_from_next_token(): create_test_crawlers(client, 10) first_response = client.list_crawlers(MaxResults=3) response = client.list_crawlers(NextToken=first_response["NextToken"]) - response["CrawlerNames"].should.have.length_of(7) + assert len(response["CrawlerNames"]) == 7 @mock_glue @@ -324,7 +321,7 @@ def test_list_crawlers_with_max_results_greater_than_actual_results(): client = create_glue_client() create_test_crawlers(client, 4) response = client.list_crawlers(MaxResults=10) - response["CrawlerNames"].should.have.length_of(4) + assert len(response["CrawlerNames"]) == 4 @mock_glue @@ -333,7 +330,7 @@ def test_list_crawlers_with_tags(): create_test_crawler(client) create_test_crawler(client, {"string": "string"}) response = client.list_crawlers(Tags={"string": "string"}) - response["CrawlerNames"].should.have.length_of(1) + assert len(response["CrawlerNames"]) == 1 @mock_glue @@ -345,7 +342,7 @@ def test_list_crawlers_after_tagging(): client.tag_resource(ResourceArn=resource_arn, TagsToAdd={"key1": "value1"}) response = client.list_crawlers(Tags={"key1": "value1"}) - response["CrawlerNames"].should.have.length_of(1) + assert len(response["CrawlerNames"]) == 1 @mock_glue @@ -357,7 +354,7 @@ def test_list_crawlers_after_removing_tag(): client.untag_resource(ResourceArn=resource_arn, TagsToRemove=["key1"]) response = client.list_crawlers(Tags={"key1": "value1"}) - response["CrawlerNames"].should.have.length_of(0) + assert len(response["CrawlerNames"]) == 0 @mock_glue @@ -380,7 +377,7 @@ def test_get_tags_job(): resp = client.get_tags(ResourceArn=resource_arn) - resp.should.have.key("Tags").equals({"key1": "value1", "key2": "value2"}) + assert resp["Tags"] == {"key1": "value1", "key2": "value2"} @mock_glue @@ -391,7 +388,7 @@ def test_get_tags_jobs_no_tags(): resp = client.get_tags(ResourceArn=resource_arn) - resp.should.have.key("Tags").equals({}) + assert resp["Tags"] == {} @mock_glue @@ -406,7 +403,7 @@ def test_tag_glue_job(): resp = client.get_tags(ResourceArn=resource_arn) - resp.should.have.key("Tags").equals({"key1": "value1", "key2": "value2"}) + assert resp["Tags"] == {"key1": "value1", "key2": "value2"} @mock_glue @@ -424,7 +421,7 @@ def test_untag_glue_job(): resp = client.get_tags(ResourceArn=resource_arn) - resp.should.have.key("Tags").equals({"key1": "value1", "key3": "value3"}) + assert resp["Tags"] == {"key1": "value1", "key3": "value3"} @mock_glue @@ -435,7 +432,7 @@ def test_get_tags_crawler(): resp = client.get_tags(ResourceArn=resource_arn) - resp.should.have.key("Tags").equals({"key1": "value1", "key2": "value2"}) + assert resp["Tags"] == {"key1": "value1", "key2": "value2"} @mock_glue @@ -446,7 +443,7 @@ def test_get_tags_crawler_no_tags(): resp = client.get_tags(ResourceArn=resource_arn) - resp.should.have.key("Tags").equals({}) + assert resp["Tags"] == {} @mock_glue @@ -461,7 +458,7 @@ def test_tag_glue_crawler(): resp = client.get_tags(ResourceArn=resource_arn) - resp.should.have.key("Tags").equals({"key1": "value1", "key2": "value2"}) + assert resp["Tags"] == {"key1": "value1", "key2": "value2"} @mock_glue @@ -479,7 +476,7 @@ def test_untag_glue_crawler(): resp = client.get_tags(ResourceArn=resource_arn) - resp.should.have.key("Tags").equals({"key1": "value1", "key3": "value3"}) + assert resp["Tags"] == {"key1": "value1", "key3": "value3"} @mock_glue @@ -491,8 +488,8 @@ def test_batch_get_crawlers(): CrawlerNames=[crawler_name, "crawler-not-found"] ) - response["Crawlers"].should.have.length_of(1) - response["CrawlersNotFound"].should.have.length_of(1) + assert len(response["Crawlers"]) == 1 + assert len(response["CrawlersNotFound"]) == 1 @mock_glue diff --git a/tests/test_glue/test_glue_job_runs.py b/tests/test_glue/test_glue_job_runs.py index 98e323a9a..890e5d967 100644 --- a/tests/test_glue/test_glue_job_runs.py +++ b/tests/test_glue/test_glue_job_runs.py @@ -1,5 +1,4 @@ import pytest -import sure # noqa # pylint: disable=unused-import from botocore.client import ClientError from unittest import SkipTest @@ -42,9 +41,10 @@ def test_start_job_run__multiple_runs_allowed(): # The 6th should fail with pytest.raises(ClientError) as exc: glue.start_job_run(JobName="somejobname") - exc.value.response["Error"]["Code"].should.equal("ConcurrentRunsExceededException") - exc.value.response["Error"]["Message"].should.match( - "Job with name somejobname already running" + assert exc.value.response["Error"]["Code"] == "ConcurrentRunsExceededException" + assert ( + exc.value.response["Error"]["Message"] + == "Job with name somejobname already running" ) @@ -62,9 +62,10 @@ def test_start_job_run__single_run_allowed(): client.start_job_run(JobName=job_name) with pytest.raises(ClientError) as exc: client.start_job_run(JobName=job_name) - exc.value.response["Error"]["Code"].should.equal("ConcurrentRunsExceededException") - exc.value.response["Error"]["Message"].should.match( - f"Job with name {job_name} already running" + assert exc.value.response["Error"]["Code"] == "ConcurrentRunsExceededException" + assert ( + exc.value.response["Error"]["Message"] + == f"Job with name {job_name} already running" ) @@ -76,14 +77,14 @@ def test_get_job_run(): job_run_id = client.start_job_run(JobName=job_name)["JobRunId"] response = client.get_job_run(JobName=job_name, RunId=job_run_id) - response["JobRun"].should.have.key("Id").equals(job_run_id) + assert response["JobRun"]["Id"] == job_run_id assert response["JobRun"]["Attempt"] assert response["JobRun"]["PreviousRunId"] assert response["JobRun"]["TriggerName"] assert response["JobRun"]["StartedOn"] assert response["JobRun"]["LastModifiedOn"] assert response["JobRun"]["CompletedOn"] - response["JobRun"].should.have.key("JobRunState").equals("SUCCEEDED") + assert response["JobRun"]["JobRunState"] == "SUCCEEDED" assert response["JobRun"]["Arguments"] assert response["JobRun"]["ErrorMessage"] == "" assert response["JobRun"]["PredecessorRuns"] @@ -106,7 +107,7 @@ def test_get_job_run_that_doesnt_exist(): with pytest.raises(ClientError) as exc: client.get_job_run(JobName=job_name, RunId="unknown") err = exc.value.response["Error"] - err["Code"].should.equal("EntityNotFoundException") + assert err["Code"] == "EntityNotFoundException" @mock_glue @@ -135,6 +136,7 @@ def test_job_run_transition(): def expect_job_state(client, job_name, run_id, expected_state): - client.get_job_run(JobName=job_name, RunId=run_id)["JobRun"][ - "JobRunState" - ].should.equal(expected_state) + assert ( + client.get_job_run(JobName=job_name, RunId=run_id)["JobRun"]["JobRunState"] + == expected_state + ) diff --git a/tests/test_glue/test_partition_filter.py b/tests/test_glue/test_partition_filter.py index 12bf31fcd..18a219029 100644 --- a/tests/test_glue/test_partition_filter.py +++ b/tests/test_glue/test_partition_filter.py @@ -2,7 +2,6 @@ from unittest import SkipTest import boto3 import pytest -import sure # noqa # pylint: disable=unused-import from botocore.client import ClientError from moto import mock_glue, settings @@ -32,8 +31,8 @@ def test_get_partitions_expression_unknown_column(): Expression="unknown_col IS NULL", ) - exc.value.response["Error"]["Code"].should.equal("InvalidInputException") - exc.value.response["Error"]["Message"].should.match("Unknown column 'unknown_col'") + assert exc.value.response["Error"]["Code"] == "InvalidInputException" + assert "Unknown column 'unknown_col'" in exc.value.response["Error"]["Message"] @mock_glue @@ -55,7 +54,7 @@ def test_get_partitions_expression_int_column(): response = client.get_partitions(**kwargs) partitions = response["Partitions"] - partitions.should.have.length_of(3) + assert len(partitions) == 3 int_col_is_two_expressions = ( "int_col = 2", @@ -75,24 +74,25 @@ def test_get_partitions_expression_int_column(): for expression in int_col_is_two_expressions: response = client.get_partitions(**kwargs, Expression=expression) partitions = response["Partitions"] - partitions.should.have.length_of(1) + assert len(partitions) == 1 partition = partitions[0] - partition["Values"].should.equal(["2"]) + assert partition["Values"] == ["2"] bad_int_expressions = ("int_col = 'test'", "int_col in (2.5)") for expression in bad_int_expressions: with pytest.raises(ClientError) as exc: client.get_partitions(**kwargs, Expression=expression) - exc.value.response["Error"]["Code"].should.equal("InvalidInputException") - exc.value.response["Error"]["Message"].should.match("is not an integer") + assert exc.value.response["Error"]["Code"] == "InvalidInputException" + assert "is not an integer" in exc.value.response["Error"]["Message"] with pytest.raises(ClientError) as exc: client.get_partitions(**kwargs, Expression="int_col LIKE '2'") - exc.value.response["Error"]["Code"].should.equal("InvalidInputException") - exc.value.response["Error"]["Message"].should.match( + assert exc.value.response["Error"]["Code"] == "InvalidInputException" + assert ( "Integral data type doesn't support operation 'LIKE'" + in exc.value.response["Error"]["Message"] ) @@ -115,7 +115,7 @@ def test_get_partitions_expression_decimal_column(): response = client.get_partitions(**kwargs) partitions = response["Partitions"] - partitions.should.have.length_of(3) + assert len(partitions) == 3 decimal_col_is_two_point_six_expressions = ( "decimal_col = 2.6", @@ -130,24 +130,25 @@ def test_get_partitions_expression_decimal_column(): for expression in decimal_col_is_two_point_six_expressions: response = client.get_partitions(**kwargs, Expression=expression) partitions = response["Partitions"] - partitions.should.have.length_of(1) + assert len(partitions) == 1 partition = partitions[0] - partition["Values"].should.equal(["2.6"]) + assert partition["Values"] == ["2.6"] bad_decimal_expressions = ("decimal_col = 'test'",) for expression in bad_decimal_expressions: with pytest.raises(ClientError) as exc: client.get_partitions(**kwargs, Expression=expression) - exc.value.response["Error"]["Code"].should.equal("InvalidInputException") - exc.value.response["Error"]["Message"].should.match("is not a decimal") + assert exc.value.response["Error"]["Code"] == "InvalidInputException" + assert "is not a decimal" in exc.value.response["Error"]["Message"] with pytest.raises(ClientError) as exc: client.get_partitions(**kwargs, Expression="decimal_col LIKE '2'") - exc.value.response["Error"]["Code"].should.equal("InvalidInputException") - exc.value.response["Error"]["Message"].should.match( + assert exc.value.response["Error"]["Code"] == "InvalidInputException" + assert ( "Decimal data type doesn't support operation 'LIKE'" + in exc.value.response["Error"]["Message"] ) @@ -171,7 +172,7 @@ def test_get_partitions_expression_string_column(): response = client.get_partitions(**kwargs) partitions = response["Partitions"] - partitions.should.have.length_of(4) + assert len(partitions) == 4 string_col_is_two_expressions = ( "string_col = 'two'", @@ -191,15 +192,15 @@ def test_get_partitions_expression_string_column(): for expression in string_col_is_two_expressions: response = client.get_partitions(**kwargs, Expression=expression) partitions = response["Partitions"] - partitions.should.have.length_of(1) + assert len(partitions) == 1 partition = partitions[0] - partition["Values"].should.be.within((["two"], ["2"])) + assert partition["Values"] in [["two"], ["2"]] with pytest.raises(ClientError) as exc: client.get_partitions(**kwargs, Expression="unknown_col LIKE 'two'") - exc.value.response["Error"]["Code"].should.equal("InvalidInputException") - exc.value.response["Error"]["Message"].should.match("Unknown column 'unknown_col'") + assert exc.value.response["Error"]["Code"] == "InvalidInputException" + assert "Unknown column 'unknown_col'" in exc.value.response["Error"]["Message"] @mock_glue @@ -221,7 +222,7 @@ def test_get_partitions_expression_date_column(): response = client.get_partitions(**kwargs) partitions = response["Partitions"] - partitions.should.have.length_of(3) + assert len(partitions) == 3 date_col_is_february_expressions = ( "date_col = '2022-02-01'", @@ -234,24 +235,25 @@ def test_get_partitions_expression_date_column(): for expression in date_col_is_february_expressions: response = client.get_partitions(**kwargs, Expression=expression) partitions = response["Partitions"] - partitions.should.have.length_of(1) + assert len(partitions) == 1 partition = partitions[0] - partition["Values"].should.equal(["2022-02-01"]) + assert partition["Values"] == ["2022-02-01"] bad_date_expressions = ("date_col = 'test'", "date_col = '2022-02-32'") for expression in bad_date_expressions: with pytest.raises(ClientError) as exc: client.get_partitions(**kwargs, Expression=expression) - exc.value.response["Error"]["Code"].should.equal("InvalidInputException") - exc.value.response["Error"]["Message"].should.match("is not a date") + assert exc.value.response["Error"]["Code"] == "InvalidInputException" + assert "is not a date" in exc.value.response["Error"]["Message"] with pytest.raises(ClientError) as exc: client.get_partitions(**kwargs, Expression="date_col LIKE '2022-02-01'") - exc.value.response["Error"]["Code"].should.equal("InvalidInputException") - exc.value.response["Error"]["Message"].should.match( + assert exc.value.response["Error"]["Code"] == "InvalidInputException" + assert ( "Date data type doesn't support operation 'LIKE'" + in exc.value.response["Error"]["Message"] ) @@ -278,7 +280,7 @@ def test_get_partitions_expression_timestamp_column(): response = client.get_partitions(**kwargs) partitions = response["Partitions"] - partitions.should.have.length_of(3) + assert len(partitions) == 3 timestamp_col_is_february_expressions = ( "timestamp_col = '2022-02-01 00:00:00'", @@ -297,9 +299,9 @@ def test_get_partitions_expression_timestamp_column(): for expression in timestamp_col_is_february_expressions: response = client.get_partitions(**kwargs, Expression=expression) partitions = response["Partitions"] - partitions.should.have.length_of(1) + assert len(partitions) == 1 partition = partitions[0] - partition["Values"].should.equal(["2022-02-01 00:00:00.000000"]) + assert partition["Values"] == ["2022-02-01 00:00:00.000000"] bad_timestamp_expressions = ( "timestamp_col = '2022-02-01'", @@ -310,17 +312,18 @@ def test_get_partitions_expression_timestamp_column(): with pytest.raises(ClientError) as exc: client.get_partitions(**kwargs, Expression=expression) - exc.value.response["Error"]["Code"].should.equal("InvalidInputException") - exc.value.response["Error"]["Message"].should.match("is not a timestamp") + assert exc.value.response["Error"]["Code"] == "InvalidInputException" + assert "is not a timestamp" in exc.value.response["Error"]["Message"] with pytest.raises(ClientError) as exc: client.get_partitions( **kwargs, Expression="timestamp_col LIKE '2022-02-01 00:00:00'" ) - exc.value.response["Error"]["Code"].should.equal("InvalidInputException") - exc.value.response["Error"]["Message"].should.match( + assert exc.value.response["Error"]["Code"] == "InvalidInputException" + assert ( "Timestamp data type doesn't support operation 'LIKE'" + in exc.value.response["Error"]["Message"] ) @@ -348,32 +351,32 @@ def test_get_partition_expression_warnings_and_exceptions(): response = client.get_partitions(**kwargs, Expression="string_col = 'test'") partitions = response["Partitions"] - partitions.should.have.length_of(1) + assert len(partitions) == 1 partition = partitions[0] - partition["Values"].should.equal(["test", "int", "3.14"]) + assert partition["Values"] == ["test", "int", "3.14"] with pytest.raises(ClientError) as exc: client.get_partitions(**kwargs, Expression="float_col = 3.14") - exc.value.response["Error"]["Code"].should.equal("InvalidInputException") - exc.value.response["Error"]["Message"].should.match("Unknown type : 'float'") + assert exc.value.response["Error"]["Code"] == "InvalidInputException" + assert "Unknown type : 'float'" in exc.value.response["Error"]["Message"] with pytest.raises(ClientError) as exc: client.get_partitions(**kwargs, Expression="int_col = 2") - exc.value.response["Error"]["Code"].should.equal("InvalidStateException") - exc.value.response["Error"]["Message"].should.match('"int" is not an integer') + assert exc.value.response["Error"]["Code"] == "InvalidStateException" + assert '"int" is not an integer' in exc.value.response["Error"]["Message"] with pytest.raises(ClientError) as exc: client.get_partitions(**kwargs, Expression="unknown_col = 'test'") - exc.value.response["Error"]["Code"].should.equal("InvalidInputException") - exc.value.response["Error"]["Message"].should.match("Unknown column 'unknown_col'") + assert exc.value.response["Error"]["Code"] == "InvalidInputException" + assert "Unknown column 'unknown_col'" in exc.value.response["Error"]["Message"] with pytest.raises(ClientError) as exc: client.get_partitions( **kwargs, Expression="string_col IS test' AND not parsable" ) - exc.value.response["Error"]["Code"].should.equal("InvalidInputException") - exc.value.response["Error"]["Message"].should.match("Unsupported expression") + assert exc.value.response["Error"]["Code"] == "InvalidInputException" + assert "Unsupported expression" in exc.value.response["Error"]["Message"] diff --git a/tests/test_glue/test_schema_registry.py b/tests/test_glue/test_schema_registry.py index fb6040117..37ba98f96 100644 --- a/tests/test_glue/test_schema_registry.py +++ b/tests/test_glue/test_schema_registry.py @@ -1,7 +1,6 @@ """Unit tests for glue-schema-registry-supported APIs.""" import boto3 import pytest -import sure # noqa # pylint: disable=unused-import from botocore.client import ClientError from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID @@ -53,16 +52,16 @@ def test_create_registry_valid_input(client): response = client.create_registry( RegistryName=TEST_REGISTRY_NAME, Description=TEST_DESCRIPTION, Tags=TEST_TAGS ) - response.should.have.key("RegistryName").equals(TEST_REGISTRY_NAME) - response.should.have.key("Description").equals(TEST_DESCRIPTION) - response.should.have.key("Tags").equals(TEST_TAGS) - response.should.have.key("RegistryArn").equals(TEST_REGISTRY_ARN) + assert response["RegistryName"] == TEST_REGISTRY_NAME + assert response["Description"] == TEST_DESCRIPTION + assert response["Tags"] == TEST_TAGS + assert response["RegistryArn"] == TEST_REGISTRY_ARN def test_create_registry_valid_partial_input(client): response = client.create_registry(RegistryName=TEST_REGISTRY_NAME) - response.should.have.key("RegistryName").equals(TEST_REGISTRY_NAME) - response.should.have.key("RegistryArn").equals(TEST_REGISTRY_ARN) + assert response["RegistryName"] == TEST_REGISTRY_NAME + assert response["RegistryArn"] == TEST_REGISTRY_ARN def test_create_registry_invalid_registry_name_too_long(client): @@ -73,9 +72,10 @@ def test_create_registry_invalid_registry_name_too_long(client): with pytest.raises(ClientError) as exc: client.create_registry(RegistryName=registry_name) err = exc.value.response["Error"] - err["Code"].should.equal("InvalidInputException") - err["Message"].should.equal( - "The resource name contains too many or too few characters. Parameter Name: registryName" + assert err["Code"] == "InvalidInputException" + assert ( + err["Message"] + == "The resource name contains too many or too few characters. Parameter Name: registryName" ) @@ -87,9 +87,10 @@ def test_create_registry_more_than_allowed(client): client.create_registry(RegistryName=TEST_REGISTRY_NAME) err = exc.value.response["Error"] - err["Code"].should.equal("ResourceNumberLimitExceededException") - err["Message"].should.equal( - "More registries cannot be created. The maximum limit has been reached." + assert err["Code"] == "ResourceNumberLimitExceededException" + assert ( + err["Message"] + == "More registries cannot be created. The maximum limit has been reached." ) @@ -99,9 +100,10 @@ def test_create_registry_invalid_registry_name(client): with pytest.raises(ClientError) as exc: client.create_registry(RegistryName=invalid_registry_name) err = exc.value.response["Error"] - err["Code"].should.equal("InvalidInputException") - err["Message"].should.equal( - "The parameter value contains one or more characters that are not valid. Parameter Name: registryName" + assert err["Code"] == "InvalidInputException" + assert ( + err["Message"] + == "The parameter value contains one or more characters that are not valid. Parameter Name: registryName" ) @@ -111,9 +113,9 @@ def test_create_registry_already_exists(client): with pytest.raises(ClientError) as exc: client.create_registry(RegistryName=TEST_REGISTRY_NAME) err = exc.value.response["Error"] - err["Code"].should.equal("AlreadyExistsException") - err["Message"].should.equal( - "Registry already exists. RegistryName: " + TEST_REGISTRY_NAME + assert err["Code"] == "AlreadyExistsException" + assert ( + err["Message"] == "Registry already exists. RegistryName: " + TEST_REGISTRY_NAME ) @@ -128,9 +130,10 @@ def test_create_registry_invalid_description_too_long(client): Description=description, ) err = exc.value.response["Error"] - err["Code"].should.equal("InvalidInputException") - err["Message"].should.equal( - "The resource name contains too many or too few characters. Parameter Name: description" + assert err["Code"] == "InvalidInputException" + assert ( + err["Message"] + == "The resource name contains too many or too few characters. Parameter Name: description" ) @@ -147,8 +150,8 @@ def test_create_registry_invalid_number_of_tags(client): Tags=tags, ) err = exc.value.response["Error"] - err["Code"].should.equal("InvalidInputException") - err["Message"].should.equal("New Tags cannot be empty or more than 50") + assert err["Code"] == "InvalidInputException" + assert err["Message"] == "New Tags cannot be empty or more than 50" # Test create_schema @@ -164,20 +167,20 @@ def test_create_schema_valid_input_registry_name_avro(client): Description=TEST_DESCRIPTION, Tags=TEST_TAGS, ) - response.should.have.key("RegistryName").equals(TEST_REGISTRY_NAME) - response.should.have.key("RegistryArn").equals(TEST_REGISTRY_ARN) - response.should.have.key("SchemaName").equals(TEST_SCHEMA_NAME) - response.should.have.key("SchemaArn").equals(TEST_SCHEMA_ARN) - response.should.have.key("Description").equals(TEST_DESCRIPTION) - response.should.have.key("DataFormat").equals(TEST_AVRO_DATA_FORMAT) - response.should.have.key("Compatibility").equals(TEST_BACKWARD_COMPATIBILITY) - response.should.have.key("SchemaCheckpoint").equals(1) - response.should.have.key("LatestSchemaVersion").equals(1) - response.should.have.key("NextSchemaVersion").equals(2) - response.should.have.key("SchemaStatus").equals(TEST_AVAILABLE_STATUS) - response.should.have.key("Tags").equals(TEST_TAGS) - response.should.have.key("SchemaVersionId") - response.should.have.key("SchemaVersionStatus").equals(TEST_AVAILABLE_STATUS) + assert response["RegistryName"] == TEST_REGISTRY_NAME + assert response["RegistryArn"] == TEST_REGISTRY_ARN + assert response["SchemaName"] == TEST_SCHEMA_NAME + assert response["SchemaArn"] == TEST_SCHEMA_ARN + assert response["Description"] == TEST_DESCRIPTION + assert response["DataFormat"] == TEST_AVRO_DATA_FORMAT + assert response["Compatibility"] == TEST_BACKWARD_COMPATIBILITY + assert response["SchemaCheckpoint"] == 1 + assert response["LatestSchemaVersion"] == 1 + assert response["NextSchemaVersion"] == 2 + assert response["SchemaStatus"] == TEST_AVAILABLE_STATUS + assert response["Tags"] == TEST_TAGS + assert "SchemaVersionId" in response + assert response["SchemaVersionStatus"] == TEST_AVAILABLE_STATUS def test_create_schema_valid_input_registry_name_json(client): @@ -192,20 +195,20 @@ def test_create_schema_valid_input_registry_name_json(client): Description=TEST_DESCRIPTION, Tags=TEST_TAGS, ) - response.should.have.key("RegistryName").equals(TEST_REGISTRY_NAME) - response.should.have.key("RegistryArn").equals(TEST_REGISTRY_ARN) - response.should.have.key("SchemaName").equals(TEST_SCHEMA_NAME) - response.should.have.key("SchemaArn").equals(TEST_SCHEMA_ARN) - response.should.have.key("Description").equals(TEST_DESCRIPTION) - response.should.have.key("DataFormat").equals(TEST_JSON_DATA_FORMAT) - response.should.have.key("Compatibility").equals(TEST_BACKWARD_COMPATIBILITY) - response.should.have.key("SchemaCheckpoint").equals(1) - response.should.have.key("LatestSchemaVersion").equals(1) - response.should.have.key("NextSchemaVersion").equals(2) - response.should.have.key("SchemaStatus").equals(TEST_AVAILABLE_STATUS) - response.should.have.key("Tags").equals(TEST_TAGS) - response.should.have.key("SchemaVersionId") - response.should.have.key("SchemaVersionStatus").equals(TEST_AVAILABLE_STATUS) + assert response["RegistryName"] == TEST_REGISTRY_NAME + assert response["RegistryArn"] == TEST_REGISTRY_ARN + assert response["SchemaName"] == TEST_SCHEMA_NAME + assert response["SchemaArn"] == TEST_SCHEMA_ARN + assert response["Description"] == TEST_DESCRIPTION + assert response["DataFormat"] == TEST_JSON_DATA_FORMAT + assert response["Compatibility"] == TEST_BACKWARD_COMPATIBILITY + assert response["SchemaCheckpoint"] == 1 + assert response["LatestSchemaVersion"] == 1 + assert response["NextSchemaVersion"] == 2 + assert response["SchemaStatus"] == TEST_AVAILABLE_STATUS + assert response["Tags"] == TEST_TAGS + assert "SchemaVersionId" in response + assert response["SchemaVersionStatus"] == TEST_AVAILABLE_STATUS def test_create_schema_valid_input_registry_name_protobuf(client): @@ -220,20 +223,20 @@ def test_create_schema_valid_input_registry_name_protobuf(client): Description=TEST_DESCRIPTION, Tags=TEST_TAGS, ) - response.should.have.key("RegistryName").equals(TEST_REGISTRY_NAME) - response.should.have.key("RegistryArn").equals(TEST_REGISTRY_ARN) - response.should.have.key("SchemaName").equals(TEST_SCHEMA_NAME) - response.should.have.key("SchemaArn").equals(TEST_SCHEMA_ARN) - response.should.have.key("Description").equals(TEST_DESCRIPTION) - response.should.have.key("DataFormat").equals(TEST_PROTOBUF_DATA_FORMAT) - response.should.have.key("Compatibility").equals(TEST_BACKWARD_COMPATIBILITY) - response.should.have.key("SchemaCheckpoint").equals(1) - response.should.have.key("LatestSchemaVersion").equals(1) - response.should.have.key("NextSchemaVersion").equals(2) - response.should.have.key("SchemaStatus").equals(TEST_AVAILABLE_STATUS) - response.should.have.key("Tags").equals(TEST_TAGS) - response.should.have.key("SchemaVersionId") - response.should.have.key("SchemaVersionStatus").equals(TEST_AVAILABLE_STATUS) + assert response["RegistryName"] == TEST_REGISTRY_NAME + assert response["RegistryArn"] == TEST_REGISTRY_ARN + assert response["SchemaName"] == TEST_SCHEMA_NAME + assert response["SchemaArn"] == TEST_SCHEMA_ARN + assert response["Description"] == TEST_DESCRIPTION + assert response["DataFormat"] == TEST_PROTOBUF_DATA_FORMAT + assert response["Compatibility"] == TEST_BACKWARD_COMPATIBILITY + assert response["SchemaCheckpoint"] == 1 + assert response["LatestSchemaVersion"] == 1 + assert response["NextSchemaVersion"] == 2 + assert response["SchemaStatus"] == TEST_AVAILABLE_STATUS + assert response["Tags"] == TEST_TAGS + assert "SchemaVersionId" in response + assert response["SchemaVersionStatus"] == TEST_AVAILABLE_STATUS def test_create_schema_valid_input_registry_arn(client): @@ -249,39 +252,39 @@ def test_create_schema_valid_input_registry_arn(client): Description=TEST_DESCRIPTION, Tags=TEST_TAGS, ) - response.should.have.key("RegistryName").equals(TEST_REGISTRY_NAME) - response.should.have.key("RegistryArn").equals(TEST_REGISTRY_ARN) - response.should.have.key("SchemaName").equals(TEST_SCHEMA_NAME) - response.should.have.key("SchemaArn").equals(TEST_SCHEMA_ARN) - response.should.have.key("Description").equals(TEST_DESCRIPTION) - response.should.have.key("DataFormat").equals(TEST_AVRO_DATA_FORMAT) - response.should.have.key("Compatibility").equals(TEST_BACKWARD_COMPATIBILITY) - response.should.have.key("SchemaCheckpoint").equals(1) - response.should.have.key("LatestSchemaVersion").equals(1) - response.should.have.key("NextSchemaVersion").equals(2) - response.should.have.key("SchemaStatus").equals(TEST_AVAILABLE_STATUS) - response.should.have.key("Tags").equals(TEST_TAGS) - response.should.have.key("SchemaVersionId") - response.should.have.key("SchemaVersionStatus").equals(TEST_AVAILABLE_STATUS) + assert response["RegistryName"] == TEST_REGISTRY_NAME + assert response["RegistryArn"] == TEST_REGISTRY_ARN + assert response["SchemaName"] == TEST_SCHEMA_NAME + assert response["SchemaArn"] == TEST_SCHEMA_ARN + assert response["Description"] == TEST_DESCRIPTION + assert response["DataFormat"] == TEST_AVRO_DATA_FORMAT + assert response["Compatibility"] == TEST_BACKWARD_COMPATIBILITY + assert response["SchemaCheckpoint"] == 1 + assert response["LatestSchemaVersion"] == 1 + assert response["NextSchemaVersion"] == 2 + assert response["SchemaStatus"] == TEST_AVAILABLE_STATUS + assert response["Tags"] == TEST_TAGS + assert "SchemaVersionId" in response + assert response["SchemaVersionStatus"] == TEST_AVAILABLE_STATUS def test_create_schema_valid_partial_input(client): helpers.create_registry(client) response = helpers.create_schema(client, TEST_REGISTRY_ID) - response.should.have.key("RegistryName").equals(TEST_REGISTRY_NAME) - response.should.have.key("RegistryArn").equals(TEST_REGISTRY_ARN) - response.should.have.key("SchemaName").equals(TEST_SCHEMA_NAME) - response.should.have.key("SchemaArn").equals(TEST_SCHEMA_ARN) - response.should.have.key("DataFormat").equals(TEST_AVRO_DATA_FORMAT) - response.should.have.key("Compatibility").equals(TEST_BACKWARD_COMPATIBILITY) - response.should.have.key("SchemaCheckpoint").equals(1) - response.should.have.key("LatestSchemaVersion").equals(1) - response.should.have.key("NextSchemaVersion").equals(2) - response.should.have.key("SchemaStatus").equals(TEST_AVAILABLE_STATUS) - response.should.have.key("SchemaStatus") - response.should.have.key("SchemaVersionId") - response.should.have.key("SchemaVersionStatus").equals(TEST_AVAILABLE_STATUS) + assert response["RegistryName"] == TEST_REGISTRY_NAME + assert response["RegistryArn"] == TEST_REGISTRY_ARN + assert response["SchemaName"] == TEST_SCHEMA_NAME + assert response["SchemaArn"] == TEST_SCHEMA_ARN + assert response["DataFormat"] == TEST_AVRO_DATA_FORMAT + assert response["Compatibility"] == TEST_BACKWARD_COMPATIBILITY + assert response["SchemaCheckpoint"] == 1 + assert response["LatestSchemaVersion"] == 1 + assert response["NextSchemaVersion"] == 2 + assert response["SchemaStatus"] == TEST_AVAILABLE_STATUS + assert "SchemaStatus" in response + assert "SchemaVersionId" in response + assert response["SchemaVersionStatus"] == TEST_AVAILABLE_STATUS def test_create_schema_valid_default_registry(client): @@ -291,23 +294,25 @@ def test_create_schema_valid_default_registry(client): response = helpers.create_schema(client, registry_id=empty_registry_id) default_registry_name = "default-registry" - response.should.have.key("RegistryName").equals(default_registry_name) - response.should.have.key("RegistryArn").equals( - f"arn:aws:glue:us-east-1:{ACCOUNT_ID}:registry/{default_registry_name}" + assert response["RegistryName"] == default_registry_name + assert ( + response["RegistryArn"] + == f"arn:aws:glue:us-east-1:{ACCOUNT_ID}:registry/{default_registry_name}" ) - response.should.have.key("SchemaName").equals(TEST_SCHEMA_NAME) - response.should.have.key("SchemaArn").equals( - f"arn:aws:glue:us-east-1:{ACCOUNT_ID}:schema/{default_registry_name}/{TEST_SCHEMA_NAME}" + assert response["SchemaName"] == TEST_SCHEMA_NAME + assert ( + response["SchemaArn"] + == f"arn:aws:glue:us-east-1:{ACCOUNT_ID}:schema/{default_registry_name}/{TEST_SCHEMA_NAME}" ) - response.should.have.key("DataFormat").equals(TEST_AVRO_DATA_FORMAT) - response.should.have.key("Compatibility").equals(TEST_BACKWARD_COMPATIBILITY) - response.should.have.key("SchemaCheckpoint").equals(1) - response.should.have.key("LatestSchemaVersion").equals(1) - response.should.have.key("NextSchemaVersion").equals(2) - response.should.have.key("SchemaStatus").equals(TEST_AVAILABLE_STATUS) - response.should.have.key("SchemaStatus") - response.should.have.key("SchemaVersionId") - response.should.have.key("SchemaVersionStatus").equals(TEST_AVAILABLE_STATUS) + assert response["DataFormat"] == TEST_AVRO_DATA_FORMAT + assert response["Compatibility"] == TEST_BACKWARD_COMPATIBILITY + assert response["SchemaCheckpoint"] == 1 + assert response["LatestSchemaVersion"] == 1 + assert response["NextSchemaVersion"] == 2 + assert response["SchemaStatus"] == TEST_AVAILABLE_STATUS + assert "SchemaStatus" in response + assert "SchemaVersionId" in response + assert response["SchemaVersionStatus"] == TEST_AVAILABLE_STATUS def test_create_schema_valid_default_registry_in_registry_id(client): @@ -318,23 +323,25 @@ def test_create_schema_valid_default_registry_in_registry_id(client): response = helpers.create_schema(client, registry_id=registry_id_default_registry) - response.should.have.key("RegistryName").equals(default_registry_name) - response.should.have.key("RegistryArn").equals( - f"arn:aws:glue:us-east-1:{ACCOUNT_ID}:registry/{default_registry_name}" + assert response["RegistryName"] == default_registry_name + assert ( + response["RegistryArn"] + == f"arn:aws:glue:us-east-1:{ACCOUNT_ID}:registry/{default_registry_name}" ) - response.should.have.key("SchemaName").equals(TEST_SCHEMA_NAME) - response.should.have.key("SchemaArn").equals( - f"arn:aws:glue:us-east-1:{ACCOUNT_ID}:schema/{default_registry_name}/{TEST_SCHEMA_NAME}" + assert response["SchemaName"] == TEST_SCHEMA_NAME + assert ( + response["SchemaArn"] + == f"arn:aws:glue:us-east-1:{ACCOUNT_ID}:schema/{default_registry_name}/{TEST_SCHEMA_NAME}" ) - response.should.have.key("DataFormat").equals(TEST_AVRO_DATA_FORMAT) - response.should.have.key("Compatibility").equals(TEST_BACKWARD_COMPATIBILITY) - response.should.have.key("SchemaCheckpoint").equals(1) - response.should.have.key("LatestSchemaVersion").equals(1) - response.should.have.key("NextSchemaVersion").equals(2) - response.should.have.key("SchemaStatus").equals(TEST_AVAILABLE_STATUS) - response.should.have.key("SchemaStatus") - response.should.have.key("SchemaVersionId") - response.should.have.key("SchemaVersionStatus").equals(TEST_AVAILABLE_STATUS) + assert response["DataFormat"] == TEST_AVRO_DATA_FORMAT + assert response["Compatibility"] == TEST_BACKWARD_COMPATIBILITY + assert response["SchemaCheckpoint"] == 1 + assert response["LatestSchemaVersion"] == 1 + assert response["NextSchemaVersion"] == 2 + assert response["SchemaStatus"] == TEST_AVAILABLE_STATUS + assert "SchemaStatus" in response + assert "SchemaVersionId" in response + assert response["SchemaVersionStatus"] == TEST_AVAILABLE_STATUS def test_create_schema_invalid_registry_arn(client): @@ -348,9 +355,10 @@ def test_create_schema_invalid_registry_arn(client): with pytest.raises(ClientError) as exc: helpers.create_schema(client, registry_id=invalid_registry_id) err = exc.value.response["Error"] - err["Code"].should.equal("InvalidInputException") - err["Message"].should.equal( - "The parameter value contains one or more characters that are not valid. Parameter Name: registryArn" + assert err["Code"] == "InvalidInputException" + assert ( + err["Message"] + == "The parameter value contains one or more characters that are not valid. Parameter Name: registryArn" ) @@ -365,9 +373,10 @@ def test_create_schema_invalid_registry_id_both_params_provided(client): with pytest.raises(ClientError) as exc: helpers.create_schema(client, registry_id=invalid_registry_id) err = exc.value.response["Error"] - err["Code"].should.equal("InvalidInputException") - err["Message"].should.equal( - "One of registryName or registryArn has to be provided, both cannot be provided." + assert err["Code"] == "InvalidInputException" + assert ( + err["Message"] + == "One of registryName or registryArn has to be provided, both cannot be provided." ) @@ -385,9 +394,10 @@ def test_create_schema_invalid_schema_name(client): SchemaDefinition=TEST_AVRO_SCHEMA_DEFINITION, ) err = exc.value.response["Error"] - err["Code"].should.equal("InvalidInputException") - err["Message"].should.equal( - "The parameter value contains one or more characters that are not valid. Parameter Name: schemaName" + assert err["Code"] == "InvalidInputException" + assert ( + err["Message"] + == "The parameter value contains one or more characters that are not valid. Parameter Name: schemaName" ) @@ -407,9 +417,10 @@ def test_create_schema_invalid_schema_name_too_long(client): SchemaDefinition=TEST_AVRO_SCHEMA_DEFINITION, ) err = exc.value.response["Error"] - err["Code"].should.equal("InvalidInputException") - err["Message"].should.equal( - "The resource name contains too many or too few characters. Parameter Name: schemaName" + assert err["Code"] == "InvalidInputException" + assert ( + err["Message"] + == "The resource name contains too many or too few characters. Parameter Name: schemaName" ) @@ -421,8 +432,8 @@ def test_create_schema_invalid_data_format(client): with pytest.raises(ClientError) as exc: helpers.create_schema(client, TEST_REGISTRY_ID, data_format=invalid_data_format) err = exc.value.response["Error"] - err["Code"].should.equal("InvalidInputException") - err["Message"].should.equal("Data format is not valid.") + assert err["Code"] == "InvalidInputException" + assert err["Message"] == "Data format is not valid." def test_create_schema_invalid_compatibility(client): @@ -435,8 +446,8 @@ def test_create_schema_invalid_compatibility(client): client, TEST_REGISTRY_ID, compatibility=invalid_compatibility ) err = exc.value.response["Error"] - err["Code"].should.equal("InvalidInputException") - err["Message"].should.equal("Compatibility is not valid.") + assert err["Code"] == "InvalidInputException" + assert err["Message"] == "Compatibility is not valid." def test_create_schema_invalid_schema_definition(client): @@ -451,9 +462,10 @@ def test_create_schema_invalid_schema_definition(client): client, TEST_REGISTRY_ID, schema_definition=invalid_schema_definition ) err = exc.value.response["Error"] - err["Code"].should.equal("InvalidInputException") - err["Message"].should.have( + assert err["Code"] == "InvalidInputException" + assert ( f"Schema definition of {TEST_AVRO_DATA_FORMAT} data format is invalid" + in err["Message"] ) @@ -467,9 +479,9 @@ def test_register_schema_version_valid_input_avro(client): SchemaId=TEST_SCHEMA_ID, SchemaDefinition=TEST_NEW_AVRO_SCHEMA_DEFINITION ) - response.should.have.key("SchemaVersionId") - response.should.have.key("VersionNumber").equals(2) - response.should.have.key("Status").equals(TEST_AVAILABLE_STATUS) + assert "SchemaVersionId" in response + assert response["VersionNumber"] == 2 + assert response["Status"] == TEST_AVAILABLE_STATUS def test_register_schema_version_valid_input_json(client): @@ -486,9 +498,9 @@ def test_register_schema_version_valid_input_json(client): SchemaId=TEST_SCHEMA_ID, SchemaDefinition=TEST_NEW_JSON_SCHEMA_DEFINITION ) - response.should.have.key("SchemaVersionId") - response.should.have.key("VersionNumber").equals(2) - response.should.have.key("Status").equals(TEST_AVAILABLE_STATUS) + assert "SchemaVersionId" in response + assert response["VersionNumber"] == 2 + assert response["Status"] == TEST_AVAILABLE_STATUS def test_register_schema_version_valid_input_protobuf(client): @@ -505,9 +517,9 @@ def test_register_schema_version_valid_input_protobuf(client): SchemaId=TEST_SCHEMA_ID, SchemaDefinition=TEST_NEW_PROTOBUF_SCHEMA_DEFINITION ) - response.should.have.key("SchemaVersionId") - response.should.have.key("VersionNumber").equals(2) - response.should.have.key("Status").equals(TEST_AVAILABLE_STATUS) + assert "SchemaVersionId" in response + assert response["VersionNumber"] == 2 + assert response["Status"] == TEST_AVAILABLE_STATUS def test_register_schema_version_valid_input_schema_arn(client): @@ -520,9 +532,9 @@ def test_register_schema_version_valid_input_schema_arn(client): SchemaId=schema_id, SchemaDefinition=TEST_NEW_AVRO_SCHEMA_DEFINITION ) - response.should.have.key("SchemaVersionId") - response.should.have.key("VersionNumber").equals(2) - response.should.have.key("Status").equals(TEST_AVAILABLE_STATUS) + assert "SchemaVersionId" in response + assert response["VersionNumber"] == 2 + assert response["Status"] == TEST_AVAILABLE_STATUS def test_register_schema_version_identical_schema_version_avro(client): @@ -536,9 +548,9 @@ def test_register_schema_version_identical_schema_version_avro(client): SchemaId=TEST_SCHEMA_ID, SchemaDefinition=TEST_AVRO_SCHEMA_DEFINITION ) - response.should.have.key("SchemaVersionId").equals(version_id) - response.should.have.key("VersionNumber").equals(1) - response.should.have.key("Status").equals(TEST_AVAILABLE_STATUS) + assert response["SchemaVersionId"] == version_id + assert response["VersionNumber"] == 1 + assert response["Status"] == TEST_AVAILABLE_STATUS def test_register_schema_version_identical_schema_version_json(client): @@ -557,9 +569,9 @@ def test_register_schema_version_identical_schema_version_json(client): SchemaId=TEST_SCHEMA_ID, SchemaDefinition=TEST_JSON_SCHEMA_DEFINITION ) - response.should.have.key("SchemaVersionId").equals(version_id) - response.should.have.key("VersionNumber").equals(1) - response.should.have.key("Status").equals(TEST_AVAILABLE_STATUS) + assert response["SchemaVersionId"] == version_id + assert response["VersionNumber"] == 1 + assert response["Status"] == TEST_AVAILABLE_STATUS def test_register_schema_version_identical_schema_version_protobuf(client): @@ -578,9 +590,9 @@ def test_register_schema_version_identical_schema_version_protobuf(client): SchemaId=TEST_SCHEMA_ID, SchemaDefinition=TEST_PROTOBUF_SCHEMA_DEFINITION ) - response.should.have.key("SchemaVersionId").equals(version_id) - response.should.have.key("VersionNumber").equals(1) - response.should.have.key("Status").equals(TEST_AVAILABLE_STATUS) + assert response["SchemaVersionId"] == version_id + assert response["VersionNumber"] == 1 + assert response["Status"] == TEST_AVAILABLE_STATUS def test_register_schema_version_invalid_registry_schema_does_not_exist(client): @@ -595,8 +607,8 @@ def test_register_schema_version_invalid_registry_schema_does_not_exist(client): ) err = exc.value.response["Error"] - err["Code"].should.equal("EntityNotFoundException") - err["Message"].should.have("Schema is not found.") + assert err["Code"] == "EntityNotFoundException" + assert "Schema is not found." in err["Message"] def test_register_schema_version_invalid_schema_schema_does_not_exist(client): @@ -610,8 +622,8 @@ def test_register_schema_version_invalid_schema_schema_does_not_exist(client): SchemaDefinition=TEST_AVRO_SCHEMA_DEFINITION, ) err = exc.value.response["Error"] - err["Code"].should.equal("EntityNotFoundException") - err["Message"].should.have("Schema is not found.") + assert err["Code"] == "EntityNotFoundException" + assert "Schema is not found." in err["Message"] def test_register_schema_version_invalid_compatibility_disabled(client): @@ -626,14 +638,10 @@ def test_register_schema_version_invalid_compatibility_disabled(client): SchemaId=TEST_SCHEMA_ID, SchemaDefinition=TEST_AVRO_SCHEMA_DEFINITION ) err = exc.value.response["Error"] - err["Code"].should.equal("InvalidInputException") - err["Message"].should.equal( - "Compatibility DISABLED does not allow versioning. SchemaId: SchemaId(schemaArn=null" - + ", schemaName=" - + TEST_SCHEMA_NAME - + ", registryName=" - + TEST_REGISTRY_NAME - + ")" + assert err["Code"] == "InvalidInputException" + assert ( + err["Message"] + == f"Compatibility DISABLED does not allow versioning. SchemaId: SchemaId(schemaArn=null, schemaName={TEST_SCHEMA_NAME}, registryName={TEST_REGISTRY_NAME})" ) @@ -649,8 +657,8 @@ def test_register_schema_version_invalid_schema_definition(client): SchemaId=TEST_SCHEMA_ID, SchemaDefinition=TEST_AVRO_SCHEMA_DEFINITION ) err = exc.value.response["Error"] - err["Code"].should.equal("InvalidInputException") - err["Message"].should.have("Schema definition of JSON data format is invalid:") + assert err["Code"] == "InvalidInputException" + assert "Compatibility DISABLED does not allow versioning." in err["Message"] def test_register_schema_version_invalid_schema_id(client): @@ -668,9 +676,10 @@ def test_register_schema_version_invalid_schema_id(client): SchemaId=invalid_schema_id, SchemaDefinition=TEST_AVRO_SCHEMA_DEFINITION ) err = exc.value.response["Error"] - err["Code"].should.equal("InvalidInputException") - err["Message"].should.equal( - "One of (registryName and schemaName) or schemaArn has to be provided, both cannot be provided." + assert err["Code"] == "InvalidInputException" + assert ( + err["Message"] + == "One of (registryName and schemaName) or schemaArn has to be provided, both cannot be provided." ) @@ -685,13 +694,13 @@ def test_get_schema_version_valid_input_schema_version_id(client): SchemaVersionId=version_id, ) - response.should.have.key("SchemaVersionId").equals(version_id) - response.should.have.key("SchemaDefinition").equals(TEST_AVRO_SCHEMA_DEFINITION) - response.should.have.key("DataFormat").equals(TEST_AVRO_DATA_FORMAT) - response.should.have.key("SchemaArn").equals(TEST_SCHEMA_ARN) - response.should.have.key("VersionNumber").equals(1) - response.should.have.key("Status").equals(TEST_AVAILABLE_STATUS) - response.should.have.key("CreatedTime") + assert response["SchemaVersionId"] == version_id + assert response["SchemaDefinition"] == TEST_AVRO_SCHEMA_DEFINITION + assert response["DataFormat"] == TEST_AVRO_DATA_FORMAT + assert response["SchemaArn"] == TEST_SCHEMA_ARN + assert response["VersionNumber"] == 1 + assert response["Status"] == TEST_AVAILABLE_STATUS + assert "CreatedTime" in response def test_get_schema_version_valid_input_version_number(client): @@ -705,13 +714,13 @@ def test_get_schema_version_valid_input_version_number(client): SchemaVersionNumber=TEST_SCHEMA_VERSION_NUMBER, ) - response.should.have.key("SchemaVersionId").equals(version_id) - response.should.have.key("SchemaDefinition").equals(TEST_AVRO_SCHEMA_DEFINITION) - response.should.have.key("DataFormat").equals(TEST_AVRO_DATA_FORMAT) - response.should.have.key("SchemaArn").equals(TEST_SCHEMA_ARN) - response.should.have.key("VersionNumber").equals(1) - response.should.have.key("Status").equals(TEST_AVAILABLE_STATUS) - response.should.have.key("CreatedTime") + assert response["SchemaVersionId"] == version_id + assert response["SchemaDefinition"] == TEST_AVRO_SCHEMA_DEFINITION + assert response["DataFormat"] == TEST_AVRO_DATA_FORMAT + assert response["SchemaArn"] == TEST_SCHEMA_ARN + assert response["VersionNumber"] == 1 + assert response["Status"] == TEST_AVAILABLE_STATUS + assert "CreatedTime" in response def test_get_schema_version_valid_input_version_number_latest_version(client): @@ -727,13 +736,13 @@ def test_get_schema_version_valid_input_version_number_latest_version(client): SchemaVersionNumber=TEST_SCHEMA_VERSION_NUMBER_LATEST_VERSION, ) - response.should.have.key("SchemaVersionId").equals(version_id) - response.should.have.key("SchemaDefinition").equals(TEST_NEW_AVRO_SCHEMA_DEFINITION) - response.should.have.key("DataFormat").equals(TEST_AVRO_DATA_FORMAT) - response.should.have.key("SchemaArn").equals(TEST_SCHEMA_ARN) - response.should.have.key("VersionNumber").equals(2) - response.should.have.key("Status").equals(TEST_AVAILABLE_STATUS) - response.should.have.key("CreatedTime") + assert response["SchemaVersionId"] == version_id + assert response["SchemaDefinition"] == TEST_NEW_AVRO_SCHEMA_DEFINITION + assert response["DataFormat"] == TEST_AVRO_DATA_FORMAT + assert response["SchemaArn"] == TEST_SCHEMA_ARN + assert response["VersionNumber"] == 2 + assert response["Status"] == TEST_AVAILABLE_STATUS + assert "CreatedTime" in response def test_get_schema_version_empty_input(client): @@ -742,9 +751,10 @@ def test_get_schema_version_empty_input(client): client.get_schema_version() err = exc.value.response["Error"] - err["Code"].should.equal("InvalidInputException") - err["Message"].should.have( - "At least one of (registryName and schemaName) or schemaArn has to be provided." + assert err["Code"] == "InvalidInputException" + assert ( + err["Message"] + == "At least one of (registryName and schemaName) or schemaArn has to be provided." ) @@ -760,9 +770,10 @@ def test_get_schema_version_invalid_schema_id_schema_version_number_both_provide ) err = exc.value.response["Error"] - err["Code"].should.equal("InvalidInputException") - err["Message"].should.equal( - "No other input parameters can be specified when fetching by SchemaVersionId." + assert err["Code"] == "InvalidInputException" + assert ( + err["Message"] + == "No other input parameters can be specified when fetching by SchemaVersionId." ) @@ -772,15 +783,11 @@ def test_get_schema_version_insufficient_params_provided(client): helpers.create_schema(client, TEST_REGISTRY_ID) with pytest.raises(ClientError) as exc: - client.get_schema_version( - SchemaId=TEST_SCHEMA_ID, - ) + client.get_schema_version(SchemaId=TEST_SCHEMA_ID) err = exc.value.response["Error"] - err["Code"].should.equal("InvalidInputException") - err["Message"].should.equal( - "One of version number (or) latest version is required." - ) + assert err["Code"] == "InvalidInputException" + assert err["Message"] == "One of version number (or) latest version is required." def test_get_schema_version_invalid_schema_version_number(client): @@ -796,10 +803,8 @@ def test_get_schema_version_invalid_schema_version_number(client): ) err = exc.value.response["Error"] - err["Code"].should.equal("InvalidInputException") - err["Message"].should.equal( - "Only one of VersionNumber or LatestVersion is required." - ) + assert err["Code"] == "InvalidInputException" + assert err["Message"] == "Only one of VersionNumber or LatestVersion is required." def test_get_schema_version_invalid_version_number(client): @@ -815,8 +820,8 @@ def test_get_schema_version_invalid_version_number(client): ) err = exc.value.response["Error"] - err["Code"].should.equal("EntityNotFoundException") - err["Message"].should.have("Schema is not found.") + assert err["Code"] == "EntityNotFoundException" + assert "Schema version is not found." in err["Message"] def test_get_schema_version_invalid_schema_id_schema_name(client): @@ -831,9 +836,10 @@ def test_get_schema_version_invalid_schema_id_schema_name(client): ) err = exc.value.response["Error"] - err["Code"].should.equal("EntityNotFoundException") - err["Message"].should.equal( - f"Schema is not found. RegistryName: {TEST_REGISTRY_NAME}, SchemaName: {TEST_INVALID_SCHEMA_NAME_DOES_NOT_EXIST}, SchemaArn: null" + assert err["Code"] == "EntityNotFoundException" + assert ( + err["Message"] + == f"Schema is not found. RegistryName: {TEST_REGISTRY_NAME}, SchemaName: {TEST_INVALID_SCHEMA_NAME_DOES_NOT_EXIST}, SchemaArn: null" ) @@ -849,8 +855,8 @@ def test_get_schema_version_invalid_schema_id_registry_name(client): ) err = exc.value.response["Error"] - err["Code"].should.equal("EntityNotFoundException") - err["Message"].should.have("Schema is not found.") + assert err["Code"] == "EntityNotFoundException" + assert "Schema is not found." in err["Message"] def test_get_schema_version_invalid_schema_version(client): @@ -859,14 +865,13 @@ def test_get_schema_version_invalid_schema_version(client): helpers.create_schema(client, TEST_REGISTRY_ID) invalid_schema_version_id = "00000000-0000-0000-0000-00000000000p" with pytest.raises(ClientError) as exc: - client.get_schema_version( - SchemaVersionId=invalid_schema_version_id, - ) + client.get_schema_version(SchemaVersionId=invalid_schema_version_id) err = exc.value.response["Error"] - err["Code"].should.equal("InvalidInputException") - err["Message"].should.equal( - "The parameter value contains one or more characters that are not valid. Parameter Name: SchemaVersionId" + assert err["Code"] == "InvalidInputException" + assert ( + err["Message"] + == "The parameter value contains one or more characters that are not valid. Parameter Name: SchemaVersionId" ) @@ -882,11 +887,11 @@ def test_get_schema_by_definition_valid_input(client): SchemaDefinition=TEST_AVRO_SCHEMA_DEFINITION, ) - response.should.have.key("SchemaVersionId").equals(version_id) - response.should.have.key("SchemaArn").equals(TEST_SCHEMA_ARN) - response.should.have.key("DataFormat").equals(TEST_AVRO_DATA_FORMAT) - response.should.have.key("Status").equals(TEST_AVAILABLE_STATUS) - response.should.have.key("CreatedTime") + assert response["SchemaVersionId"] == version_id + assert response["SchemaArn"] == TEST_SCHEMA_ARN + assert response["DataFormat"] == TEST_AVRO_DATA_FORMAT + assert response["Status"] == TEST_AVAILABLE_STATUS + assert "CreatedTime" in response def test_get_schema_by_definition_invalid_schema_id_schema_does_not_exist(client): @@ -901,8 +906,8 @@ def test_get_schema_by_definition_invalid_schema_id_schema_does_not_exist(client ) err = exc.value.response["Error"] - err["Code"].should.equal("EntityNotFoundException") - err["Message"].should.have("Schema is not found.") + assert err["Code"] == "EntityNotFoundException" + assert "Schema is not found." in err["Message"] def test_get_schema_by_definition_invalid_schema_definition_does_not_exist(client): @@ -917,8 +922,8 @@ def test_get_schema_by_definition_invalid_schema_definition_does_not_exist(clien ) err = exc.value.response["Error"] - err["Code"].should.equal("EntityNotFoundException") - err["Message"].should.have("Schema is not found.") + assert err["Code"] == "EntityNotFoundException" + assert "Schema is not found." in err["Message"] # test put_schema_version_metadata @@ -933,16 +938,12 @@ def test_put_schema_version_metadata_valid_input_schema_version_number(client): MetadataKeyValue=TEST_METADATA_KEY_VALUE, ) - response.should.have.key("SchemaName").equals(TEST_SCHEMA_NAME) - response.should.have.key("RegistryName").equals(TEST_REGISTRY_NAME) - response.should.have.key("LatestVersion").equals(False) - response.should.have.key("VersionNumber").equals(1) - response.should.have.key("MetadataKey").equals( - TEST_METADATA_KEY_VALUE["MetadataKey"] - ) - response.should.have.key("MetadataValue").equals( - TEST_METADATA_KEY_VALUE["MetadataValue"] - ) + assert response["SchemaName"] == TEST_SCHEMA_NAME + assert response["RegistryName"] == TEST_REGISTRY_NAME + assert response["LatestVersion"] is False + assert response["VersionNumber"] == 1 + assert response["MetadataKey"] == TEST_METADATA_KEY_VALUE["MetadataKey"] + assert response["MetadataValue"] == TEST_METADATA_KEY_VALUE["MetadataValue"] def test_put_schema_version_metadata_valid_input_schema_version_id(client): @@ -956,11 +957,11 @@ def test_put_schema_version_metadata_valid_input_schema_version_id(client): MetadataKeyValue=TEST_METADATA_KEY_VALUE, ) - response.should.have.key("SchemaVersionId").equals(version_id) - response.should.have.key("LatestVersion").equals(False) - response.should.have.key("VersionNumber").equals(0) - response.should.have.key("MetadataKey").equals(TEST_METADATA_KEY) - response.should.have.key("MetadataValue").equals(TEST_METADATA_VALUE) + assert response["SchemaVersionId"] == version_id + assert response["LatestVersion"] is False + assert response["VersionNumber"] == 0 + assert response["MetadataKey"] == TEST_METADATA_KEY + assert response["MetadataValue"] == TEST_METADATA_VALUE def test_put_schema_version_metadata_more_than_allowed_schema_version_id(client): @@ -985,9 +986,10 @@ def test_put_schema_version_metadata_more_than_allowed_schema_version_id(client) ) err = exc.value.response["Error"] - err["Code"].should.equal("ResourceNumberLimitExceededException") - err["Message"].should.equal( - "Your resource limits for Schema Version Metadata have been exceeded." + assert err["Code"] == "ResourceNumberLimitExceededException" + assert ( + err["Message"] + == "Your resource limits for Schema Version Metadata have been exceeded." ) @@ -1015,9 +1017,10 @@ def test_put_schema_version_metadata_more_than_allowed_schema_version_id_same_ke ) err = exc.value.response["Error"] - err["Code"].should.equal("ResourceNumberLimitExceededException") - err["Message"].should.equal( - "Your resource limits for Schema Version Metadata have been exceeded." + assert err["Code"] == "ResourceNumberLimitExceededException" + assert ( + err["Message"] + == "Your resource limits for Schema Version Metadata have been exceeded." ) @@ -1039,9 +1042,10 @@ def test_put_schema_version_metadata_already_exists_schema_version_id(client): ) err = exc.value.response["Error"] - err["Code"].should.equal("AlreadyExistsException") - err["Message"].should.equal( - f"Resource already exist for schema version id: {version_id}, metadata key: {TEST_METADATA_KEY}, metadata value: {TEST_METADATA_VALUE}" + assert err["Code"] == "AlreadyExistsException" + assert ( + err["Message"] + == f"Resource already exist for schema version id: {version_id}, metadata key: {TEST_METADATA_KEY}, metadata value: {TEST_METADATA_VALUE}" ) @@ -1065,9 +1069,10 @@ def test_put_schema_version_metadata_invalid_characters_metadata_key_schema_vers ) err = exc.value.response["Error"] - err["Code"].should.equal("InvalidInputException") - err["Message"].should.have( - "key contains one or more characters that are not valid." + assert err["Code"] == "InvalidInputException" + assert ( + err["Message"] + == "The parameter value contains one or more characters that are not valid. Parameter Name: key" ) @@ -1091,10 +1096,8 @@ def test_put_schema_version_metadata_invalid_characters_metadata_value_schema_ve ) err = exc.value.response["Error"] - err["Code"].should.equal("InvalidInputException") - err["Message"].should.have( - "value contains one or more characters that are not valid." - ) + assert err["Code"] == "InvalidInputException" + assert "value contains one or more characters that are not valid." in err["Message"] def test_put_schema_version_metadata_more_than_allowed_schema_version_number(client): @@ -1120,9 +1123,10 @@ def test_put_schema_version_metadata_more_than_allowed_schema_version_number(cli ) err = exc.value.response["Error"] - err["Code"].should.equal("ResourceNumberLimitExceededException") - err["Message"].should.equal( - "Your resource limits for Schema Version Metadata have been exceeded." + assert err["Code"] == "ResourceNumberLimitExceededException" + assert ( + err["Message"] + == "Your resource limits for Schema Version Metadata have been exceeded." ) @@ -1146,9 +1150,10 @@ def test_put_schema_version_metadata_already_exists_schema_version_number(client ) err = exc.value.response["Error"] - err["Code"].should.equal("AlreadyExistsException") - err["Message"].should.equal( - f"Resource already exist for schema version id: {version_id}, metadata key: {TEST_METADATA_KEY}, metadata value: {TEST_METADATA_VALUE}" + assert err["Code"] == "AlreadyExistsException" + assert ( + err["Message"] + == f"Resource already exist for schema version id: {version_id}, metadata key: {TEST_METADATA_KEY}, metadata value: {TEST_METADATA_VALUE}" ) @@ -1172,9 +1177,10 @@ def test_put_schema_version_metadata_invalid_characters_metadata_key_schema_vers ) err = exc.value.response["Error"] - err["Code"].should.equal("InvalidInputException") - err["Message"].should.have( - "key contains one or more characters that are not valid." + assert err["Code"] == "InvalidInputException" + assert ( + "The parameter value contains one or more characters that are not valid." + in err["Message"] ) @@ -1198,10 +1204,8 @@ def test_put_schema_version_metadata_invalid_characters_metadata_value_schema_ve ) err = exc.value.response["Error"] - err["Code"].should.equal("InvalidInputException") - err["Message"].should.have( - "value contains one or more characters that are not valid." - ) + assert err["Code"] == "InvalidInputException" + assert "value contains one or more characters that are not valid." in err["Message"] def test_get_schema(client): @@ -1211,8 +1215,8 @@ def test_get_schema(client): response = client.get_schema( SchemaId={"RegistryName": TEST_REGISTRY_NAME, "SchemaName": TEST_SCHEMA_NAME} ) - response.should.have.key("SchemaArn").equals(TEST_SCHEMA_ARN) - response.should.have.key("SchemaName").equals(TEST_SCHEMA_NAME) + assert response["SchemaArn"] == TEST_SCHEMA_ARN + assert response["SchemaName"] == TEST_SCHEMA_NAME def test_update_schema(client): @@ -1228,10 +1232,10 @@ def test_update_schema(client): response = client.get_schema( SchemaId={"RegistryName": TEST_REGISTRY_NAME, "SchemaName": TEST_SCHEMA_NAME} ) - response.should.have.key("SchemaArn").equals(TEST_SCHEMA_ARN) - response.should.have.key("SchemaName").equals(TEST_SCHEMA_NAME) - response.should.have.key("Description").equals("updated schema") - response.should.have.key("Compatibility").equals("FORWARD") + assert response["SchemaArn"] == TEST_SCHEMA_ARN + assert response["SchemaName"] == TEST_SCHEMA_NAME + assert response["Description"] == "updated schema" + assert response["Compatibility"] == "FORWARD" # test delete_schema @@ -1240,13 +1244,11 @@ def test_delete_schema_valid_input(client): helpers.create_schema(client, TEST_REGISTRY_ID) - response = client.delete_schema( - SchemaId=TEST_SCHEMA_ID, - ) + response = client.delete_schema(SchemaId=TEST_SCHEMA_ID) - response.should.have.key("SchemaArn").equals(TEST_SCHEMA_ARN) - response.should.have.key("SchemaName").equals(TEST_SCHEMA_NAME) - response.should.have.key("Status").equals(TEST_DELETING_STATUS) + assert response["SchemaArn"] == TEST_SCHEMA_ARN + assert response["SchemaName"] == TEST_SCHEMA_NAME + assert response["Status"] == TEST_DELETING_STATUS def test_delete_schema_valid_input_schema_arn(client): @@ -1256,36 +1258,31 @@ def test_delete_schema_valid_input_schema_arn(client): version_id = response["SchemaVersionId"] schema_id = {"SchemaArn": f"{TEST_SCHEMA_ARN}"} - response = client.delete_schema( - SchemaId=schema_id, - ) + response = client.delete_schema(SchemaId=schema_id) - response.should.have.key("SchemaArn").equals(TEST_SCHEMA_ARN) - response.should.have.key("SchemaName").equals(TEST_SCHEMA_NAME) - response.should.have.key("Status").equals(TEST_DELETING_STATUS) + assert response["SchemaArn"] == TEST_SCHEMA_ARN + assert response["SchemaName"] == TEST_SCHEMA_NAME + assert response["Status"] == TEST_DELETING_STATUS with pytest.raises(ClientError) as exc: - client.get_schema_version( - SchemaVersionId=version_id, - ) + client.get_schema_version(SchemaVersionId=version_id) err = exc.value.response["Error"] - err["Code"].should.equal("EntityNotFoundException") - err["Message"].should.have("Schema is not found.") + assert err["Code"] == "EntityNotFoundException" + assert "Schema version is not found." in err["Message"] def test_delete_schema_schema_not_found(client): helpers.create_registry(client) with pytest.raises(ClientError) as exc: - client.delete_schema( - SchemaId=TEST_SCHEMA_ID, - ) + client.delete_schema(SchemaId=TEST_SCHEMA_ID) err = exc.value.response["Error"] - err["Code"].should.equal("EntityNotFoundException") - err["Message"].should.have( - f"Schema is not found. RegistryName: {TEST_REGISTRY_NAME}, SchemaName: {TEST_SCHEMA_NAME}, SchemaArn: null" + assert err["Code"] == "EntityNotFoundException" + assert ( + err["Message"] + == f"Schema is not found. RegistryName: {TEST_REGISTRY_NAME}, SchemaName: {TEST_SCHEMA_NAME}, SchemaArn: null" ) @@ -1294,7 +1291,7 @@ def test_list_registries(client): helpers.create_registry(client, registry_name="registry2") registries = client.list_registries()["Registries"] - registries.should.have.length_of(2) + assert len(registries) == 2 @pytest.mark.parametrize("name_or_arn", ["RegistryArn", "RegistryName"]) @@ -1302,8 +1299,8 @@ def test_get_registry(client, name_or_arn): x = helpers.create_registry(client) r = client.get_registry(RegistryId={name_or_arn: x[name_or_arn]}) - r.should.have.key("RegistryName").equals(x["RegistryName"]) - r.should.have.key("RegistryArn").equals(x["RegistryArn"]) + assert r["RegistryName"] == x["RegistryName"] + assert r["RegistryArn"] == x["RegistryArn"] @pytest.mark.parametrize("name_or_arn", ["RegistryArn", "RegistryName"]) @@ -1311,4 +1308,4 @@ def test_delete_registry(client, name_or_arn): x = helpers.create_registry(client) client.delete_registry(RegistryId={name_or_arn: x[name_or_arn]}) - client.list_registries()["Registries"].should.have.length_of(0) + assert len(client.list_registries()["Registries"]) == 0