Techdebt: Replace sure with regular asserts for DAX+DMS (#6435)

This commit is contained in:
Bert Blommers 2023-06-23 15:12:32 +00:00 committed by GitHub
parent 10106d76d9
commit dab6318f90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 42 deletions

View File

@ -149,9 +149,10 @@ def test_describe_clusters_invalid_name(name):
with pytest.raises(ClientError) as exc: with pytest.raises(ClientError) as exc:
client.describe_clusters(ClusterNames=[name]) client.describe_clusters(ClusterNames=[name])
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("InvalidParameterValueException") assert err["Code"] == "InvalidParameterValueException"
err["Message"].should.equal( assert (
"Cluster ID specified is not a valid identifier. Identifiers must begin with a letter; must contain only ASCII letters, digits, and hyphens; and must not end with a hyphen or contain two consecutive hyphens." err["Message"]
== "Cluster ID specified is not a valid identifier. Identifiers must begin with a letter; must contain only ASCII letters, digits, and hyphens; and must not end with a hyphen or contain two consecutive hyphens."
) )
@ -265,9 +266,9 @@ def test_describe_clusters_returns_nodes_after_some_time():
# Finished loading by now # Finished loading by now
cluster = client.describe_clusters(ClusterNames=["daxcluster"])["Clusters"][0] cluster = client.describe_clusters(ClusterNames=["daxcluster"])["Clusters"][0]
assert cluster["TotalNodes"].should.equal(3) assert cluster["TotalNodes"] == 3
assert cluster["ActiveNodes"].should.equal(0) assert cluster["ActiveNodes"] == 0
assert cluster["Status"].should.equal("available") assert cluster["Status"] == "available"
# Address Info is only available when the cluster is ready # Address Info is only available when the cluster is ready
endpoint = cluster["ClusterDiscoveryEndpoint"] endpoint = cluster["ClusterDiscoveryEndpoint"]

View File

@ -1,6 +1,5 @@
from botocore.exceptions import ClientError from botocore.exceptions import ClientError
import boto3 import boto3
import sure # noqa # pylint: disable=unused-import
import pytest import pytest
import json import json
@ -25,19 +24,19 @@ def test_create_and_get_replication_task():
Filters=[{"Name": "replication-task-id", "Values": ["test"]}] Filters=[{"Name": "replication-task-id", "Values": ["test"]}]
) )
tasks["ReplicationTasks"].should.have.length_of(1) assert len(tasks["ReplicationTasks"]) == 1
task = tasks["ReplicationTasks"][0] task = tasks["ReplicationTasks"][0]
task["ReplicationTaskIdentifier"].should.equal("test") assert task["ReplicationTaskIdentifier"] == "test"
task["SourceEndpointArn"].should.equal("source-endpoint-arn") assert task["SourceEndpointArn"] == "source-endpoint-arn"
task["TargetEndpointArn"].should.equal("target-endpoint-arn") assert task["TargetEndpointArn"] == "target-endpoint-arn"
task["ReplicationInstanceArn"].should.equal("replication-instance-arn") assert task["ReplicationInstanceArn"] == "replication-instance-arn"
task["MigrationType"].should.equal("full-load") assert task["MigrationType"] == "full-load"
task["Status"].should.equal("creating") assert task["Status"] == "creating"
task["TableMappings"].should.equal('{"rules":[]}') assert task["TableMappings"] == '{"rules":[]}'
json.loads(task["TableMappings"]).should.be.a(dict) assert isinstance(json.loads(task["TableMappings"]), dict)
task["ReplicationTaskSettings"].should.equal('{"Logging":{} }') assert task["ReplicationTaskSettings"] == '{"Logging":{} }'
json.loads(task["ReplicationTaskSettings"]).should.be.a(dict) assert isinstance(json.loads(task["ReplicationTaskSettings"]), dict)
@mock_dms @mock_dms
@ -63,10 +62,11 @@ def test_create_existing_replication_task_throws_error():
TableMappings='{"rules":[]}', TableMappings='{"rules":[]}',
) )
ex.value.operation_name.should.equal("CreateReplicationTask") assert ex.value.operation_name == "CreateReplicationTask"
ex.value.response["Error"]["Code"].should.equal("ResourceAlreadyExistsFault") assert ex.value.response["Error"]["Code"] == "ResourceAlreadyExistsFault"
ex.value.response["Error"]["Message"].should.equal( assert (
"The resource you are attempting to create already exists." ex.value.response["Error"]["Message"]
== "The resource you are attempting to create already exists."
) )
@ -90,7 +90,7 @@ def test_start_replication_task():
Filters=[{"Name": "replication-task-arn", "Values": [task_arn]}] Filters=[{"Name": "replication-task-arn", "Values": [task_arn]}]
) )
tasks["ReplicationTasks"][0]["Status"].should.equal("running") assert tasks["ReplicationTasks"][0]["Status"] == "running"
@mock_dms @mock_dms
@ -103,10 +103,10 @@ def test_start_replication_task_throws_resource_not_found_error():
StartReplicationTaskType="start-replication", StartReplicationTaskType="start-replication",
) )
ex.value.operation_name.should.equal("StartReplicationTask") assert ex.value.operation_name == "StartReplicationTask"
ex.value.response["Error"]["Code"].should.equal("ResourceNotFoundFault") assert ex.value.response["Error"]["Code"] == "ResourceNotFoundFault"
ex.value.response["Error"]["Message"].should.equal( assert (
"Replication task could not be found." ex.value.response["Error"]["Message"] == "Replication task could not be found."
) )
@ -127,11 +127,9 @@ def test_stop_replication_task_throws_invalid_state_error():
with pytest.raises(ClientError) as ex: with pytest.raises(ClientError) as ex:
client.stop_replication_task(ReplicationTaskArn=task_arn) client.stop_replication_task(ReplicationTaskArn=task_arn)
ex.value.operation_name.should.equal("StopReplicationTask") assert ex.value.operation_name == "StopReplicationTask"
ex.value.response["Error"]["Code"].should.equal("InvalidResourceStateFault") assert ex.value.response["Error"]["Code"] == "InvalidResourceStateFault"
ex.value.response["Error"]["Message"].should.equal( assert ex.value.response["Error"]["Message"] == "Replication task is not running"
"Replication task is not running"
)
@mock_dms @mock_dms
@ -141,10 +139,10 @@ def test_stop_replication_task_throws_resource_not_found_error():
with pytest.raises(ClientError) as ex: with pytest.raises(ClientError) as ex:
client.stop_replication_task(ReplicationTaskArn="does-not-exist") client.stop_replication_task(ReplicationTaskArn="does-not-exist")
ex.value.operation_name.should.equal("StopReplicationTask") assert ex.value.operation_name == "StopReplicationTask"
ex.value.response["Error"]["Code"].should.equal("ResourceNotFoundFault") assert ex.value.response["Error"]["Code"] == "ResourceNotFoundFault"
ex.value.response["Error"]["Message"].should.equal( assert (
"Replication task could not be found." ex.value.response["Error"]["Message"] == "Replication task could not be found."
) )
@ -169,7 +167,7 @@ def test_stop_replication_task():
Filters=[{"Name": "replication-task-arn", "Values": [task_arn]}] Filters=[{"Name": "replication-task-arn", "Values": [task_arn]}]
) )
tasks["ReplicationTasks"][0]["Status"].should.equal("stopped") assert tasks["ReplicationTasks"][0]["Status"] == "stopped"
@mock_dms @mock_dms
@ -190,7 +188,7 @@ def test_delete_replication_task():
Filters=[{"Name": "replication-task-arn", "Values": [task_arn]}] Filters=[{"Name": "replication-task-arn", "Values": [task_arn]}]
) )
tasks["ReplicationTasks"].should.have.length_of(0) assert len(tasks["ReplicationTasks"]) == 0
@mock_dms @mock_dms
@ -200,8 +198,8 @@ def test_delete_replication_task_throws_resource_not_found_error():
with pytest.raises(ClientError) as ex: with pytest.raises(ClientError) as ex:
client.delete_replication_task(ReplicationTaskArn="does-not-exist") client.delete_replication_task(ReplicationTaskArn="does-not-exist")
ex.value.operation_name.should.equal("DeleteReplicationTask") assert ex.value.operation_name == "DeleteReplicationTask"
ex.value.response["Error"]["Code"].should.equal("ResourceNotFoundFault") assert ex.value.response["Error"]["Code"] == "ResourceNotFoundFault"
ex.value.response["Error"]["Message"].should.equal( assert (
"Replication task could not be found." ex.value.response["Error"]["Message"] == "Replication task could not be found."
) )