diff --git a/tests/test_support/test_server.py b/tests/test_support/test_server.py index f9b7e6268..409f8b8cb 100644 --- a/tests/test_support/test_server.py +++ b/tests/test_support/test_server.py @@ -1,59 +1,46 @@ -import sure # noqa # pylint: disable=unused-import - +"""Test the different server responses for support.""" import moto.server as server -""" -Test the different server responses for support -""" - def test_describe_trusted_advisor_checks_returns_check_names(): - """ - Check that the correct names of checks are returned - """ + """Check that the correct names of checks are returned.""" backend = server.create_backend_app("support") test_client = backend.test_client() res = test_client.get("/?Action=DescribeTrustedAdvisorChecks&Version=2015-12-01") - res.data.should.contain(b"Low Utilization Amazon EC2 Instances") - res.data.should.contain(b"ELB Application Load Balancers") + assert b"Low Utilization Amazon EC2 Instances" in res.data + assert b"ELB Application Load Balancers" in res.data def test_describe_trusted_advisor_checks_does_not_return_wrong_check_names(): - """ - Check that the wrong names of checks are not returned - """ + """Check that the wrong names of checks are not returned.""" backend = server.create_backend_app("support") test_client = backend.test_client() res = test_client.get("/?Action=DescribeTrustedAdvisorChecks&Version=2015-12-01") - res.data.doesnot.contain(b"Low Utilization Amazon Foo Instances") - res.data.doesnot.contain(b"ELB Application Bar Balancers") + assert b"Low Utilization Amazon Foo Instances" not in res.data + assert b"ELB Application Bar Balancers" not in res.data def test_describe_trusted_advisor_checks_returns_check_ids(): - """ - Check that some random ids of checks are returned - """ + """Check that some random ids of checks are returned.""" backend = server.create_backend_app("support") test_client = backend.test_client() res = test_client.get("/?Action=DescribeTrustedAdvisorChecks&Version=2015-12-01") - res.data.should.contain(b"DAvU99Dc4C") - res.data.should.contain(b"zXCkfM1nI3") + assert b"DAvU99Dc4C" in res.data + assert b"zXCkfM1nI3" in res.data def test_describe_trusted_advisor_checks_does_not_return_wrong_id(): - """ - Check that some wrong ids of checks are not returned - """ + """Check that some wrong ids of checks are not returned.""" backend = server.create_backend_app("support") test_client = backend.test_client() res = test_client.get("/?Action=DescribeTrustedAdvisorChecks&Version=2015-12-01") - res.data.doesnot.contain(b"DAvU99DcBAR") - res.data.doesnot.contain(b"zXCkfM1nFOO") + assert b"DAvU99DcBAR" not in res.data + assert b"zXCkfM1nFOO" not in res.data diff --git a/tests/test_support/test_support.py b/tests/test_support/test_support.py index b7266f4fe..91549228e 100644 --- a/tests/test_support/test_support.py +++ b/tests/test_support/test_support.py @@ -1,72 +1,59 @@ import boto3 import pytest -import sure # noqa # pylint: disable=unused-import + from moto import mock_support @mock_support def test_describe_trusted_advisor_checks_returns_amount_of_checks(): - """ - test that the 104 checks that are listed under trusted advisor currently - are returned - """ + """Test that trusted advisor returns 104 checks.""" client = boto3.client("support", "us-east-1") response = client.describe_trusted_advisor_checks(language="en") - - response["checks"].should.be.length_of(104) + assert len(response["checks"]) == 104 @mock_support def test_describe_trusted_advisor_checks_returns_an_expected_id(): - """ - test that a random check id is returned - """ + """Test that a random check id is returned.""" client = boto3.client("support", "us-east-1") response = client.describe_trusted_advisor_checks(language="en") check_ids = [] for check in response["checks"]: check_ids.append(check["id"]) - check_ids.should.contain("zXCkfM1nI3") + assert "zXCkfM1nI3" in check_ids @mock_support def test_describe_trusted_advisor_checks_returns_an_expected_check_name(): - """ - test that a random check name is returned - """ + """Test that a random check name is returned.""" client = boto3.client("support", "us-east-1") response = client.describe_trusted_advisor_checks(language="en") check_names = [] for check in response["checks"]: check_names.append(check["name"]) - check_names.should.contain("Unassociated Elastic IP Addresses") + assert "Unassociated Elastic IP Addresses" in check_names @mock_support def test_refresh_trusted_advisor_check_returns_expected_check(): - """ - A refresh of a trusted advisor check returns the check id - in the response - """ + """Test refresh of a trusted advisor check returns check id in response.""" client = boto3.client("support", "us-east-1") check_name = "XXXIIIY" response = client.refresh_trusted_advisor_check(checkId=check_name) - response["status"]["checkId"].should.equal(check_name) + assert response["status"]["checkId"] == check_name @mock_support def test_refresh_trusted_advisor_check_returns_an_expected_status(): - """ - A refresh of a trusted advisor check returns an expected status - """ + """Test refresh of a trusted advisor check returns an expected status.""" client = boto3.client("support", "us-east-1") possible_statuses = ["none", "enqueued", "processing", "success", "abandoned"] check_name = "XXXIIIY" response = client.refresh_trusted_advisor_check(checkId=check_name) actual_status = response["status"]["status"] - possible_statuses.should.contain(actual_status) + assert actual_status in possible_statuses @pytest.mark.parametrize( @@ -80,9 +67,7 @@ def test_refresh_trusted_advisor_check_returns_an_expected_status(): def test_refresh_trusted_advisor_check_cycles_to_new_status_on_each_call( possible_statuses, ): - """ - Called only three times, only three expected statuses are returned - """ + """Test when check is called 3 times, 3 expected statuses are returned.""" client = boto3.client("support", "us-east-1") check_name = "XXXIIIY" actual_statuses = [] @@ -91,14 +76,12 @@ def test_refresh_trusted_advisor_check_cycles_to_new_status_on_each_call( response = client.refresh_trusted_advisor_check(checkId=check_name) actual_statuses.append(response["status"]["status"]) - actual_statuses.should.equal(possible_statuses) + assert actual_statuses == possible_statuses @mock_support def test_refresh_trusted_advisor_check_cycles_to_new_status_on_with_two_checks(): - """ - On each call, the next expected status is returned when additional checks are made - """ + """Test next expected status is returned when additional checks are made.""" client = boto3.client("support", "us-east-1") check_1_name = "XXXIIIY" check_2_name = "XXXIIIZ" @@ -120,17 +103,14 @@ def test_refresh_trusted_advisor_check_cycles_to_new_status_on_with_two_checks() response = client.refresh_trusted_advisor_check(checkId=check_2_name) check_2_statuses.append(response["status"]["status"]) - check_1_statuses.should.equal(possible_statuses) and check_2_statuses.should.equal( - possible_statuses + assert ( + check_1_statuses == possible_statuses and check_2_statuses == possible_statuses ) @mock_support def test_refresh_trusted_advisor_check_cycle_continues_on_full_cycle(): - """ - After cycling through all statuses, the check continues the cycle - """ - + """Test that after cycling through all statuses, check continues cycle.""" client = boto3.client("support", "us-east-1") check_name = "XXXIIIY" possible_statuses = [ @@ -146,14 +126,12 @@ def test_refresh_trusted_advisor_check_cycle_continues_on_full_cycle(): expected_none_response = client.refresh_trusted_advisor_check(checkId=check_name) - expected_none_response["status"]["status"].should.equal("none") + assert expected_none_response["status"]["status"] == "none" @mock_support def test_support_case_is_closed(): - """ - On closing a case, the correct resolved response is returned - """ + """Test that on closing a case, the correct response is returned.""" client = boto3.client("support", "us-east-1") create_case_response = client.create_case( subject="test_subject", @@ -181,17 +159,14 @@ def test_support_case_is_closed(): expected_initial_case = [resolve_case_response["initialCaseStatus"]] expected_final_case = "resolved" - set(expected_initial_case).issubset(possible_case_status).should.be.true + assert set(expected_initial_case).issubset(possible_case_status) is True - expected_final_case.should.equal("resolved") + assert expected_final_case == "resolved" @mock_support def test_support_case_created(): - """ - On creating a support request its response contains a case ID - """ - + """Test support request creation response contains case ID.""" client = boto3.client("support", "us-east-1") create_case_response = client.create_case( subject="test_subject", @@ -205,7 +180,7 @@ def test_support_case_created(): attachmentSetId="test_attachment_set_id", ) - len(create_case_response["caseId"]).should.equal(38) + assert len(create_case_response["caseId"]) == 38 @pytest.mark.parametrize( @@ -220,9 +195,7 @@ def test_support_case_created(): ) @mock_support def test_support_created_case_can_be_described(key, value): - """ - On creating a support request it can be described - """ + """Test support request creation can be described.""" client = boto3.client("support", "us-east-1") create_case_response = client.create_case( @@ -252,7 +225,7 @@ def test_support_created_case_can_be_described(key, value): actual_case_id = describe_cases_response["cases"][0][key] - actual_case_id.should.equal(value) + assert actual_case_id == value @pytest.mark.parametrize( @@ -267,9 +240,7 @@ def test_support_created_case_can_be_described(key, value): ) @mock_support def test_support_created_case_can_be_described_without_next_token(key, value): - """ - On creating a support request it can be described without next token - """ + """Test support request creation can be described without next token.""" client = boto3.client("support", "us-east-1") create_case_response = client.create_case( @@ -298,7 +269,7 @@ def test_support_created_case_can_be_described_without_next_token(key, value): actual_case_id = describe_cases_response["cases"][0][key] - actual_case_id.should.equal(value) + assert actual_case_id == value @pytest.mark.parametrize( @@ -313,9 +284,7 @@ def test_support_created_case_can_be_described_without_next_token(key, value): ) @mock_support def test_support_created_case_can_be_described_without_max_results(key, value): - """ - On creating a support request it can be described without max_results - """ + """Test support request creation can be described without max_results.""" client = boto3.client("support", "us-east-1") create_case_response = client.create_case( @@ -344,7 +313,7 @@ def test_support_created_case_can_be_described_without_max_results(key, value): actual_case_id = describe_cases_response["cases"][0][key] - actual_case_id.should.equal(value) + assert actual_case_id == value @pytest.mark.parametrize( @@ -361,9 +330,7 @@ def test_support_created_case_can_be_described_without_max_results(key, value): def test_support_created_case_can_be_described_without_max_results_or_next_token( key, value ): - """ - On creating a support request it can be described without max_results - """ + """Test support request creation can be described without next token.""" client = boto3.client("support", "us-east-1") create_case_response = client.create_case( @@ -391,19 +358,17 @@ def test_support_created_case_can_be_described_without_max_results_or_next_token actual_case_id = describe_cases_response["cases"][0][key] - actual_case_id.should.equal(value) + assert actual_case_id == value @mock_support def test_support_created_case_can_be_described_without_params(): - """ - On creating a support request it can be described - """ + """Test support request creation without params can be described.""" client = boto3.client("support", "us-east-1") describe_cases_response = client.describe_cases() - describe_cases_response["cases"].should.equal([]) + assert describe_cases_response["cases"] == [] client.create_case( subject="test_subject", @@ -418,15 +383,12 @@ def test_support_created_case_can_be_described_without_params(): ) describe_cases_response = client.describe_cases() - describe_cases_response["cases"].should.have.length_of(1) + assert len(describe_cases_response["cases"]) == 1 @mock_support def test_support_created_case_cc_email_correct(): - """ - On creating a support request it can be described with - the correct cc email - """ + """Test a support request can be described with correct cc email.""" client = boto3.client("support", "us-east-1") create_case_response = client.create_case( @@ -456,16 +418,12 @@ def test_support_created_case_cc_email_correct(): actual_case_id = describe_cases_response["cases"][0]["ccEmailAddresses"][0] - actual_case_id.should.equal("test_email_cc") + assert actual_case_id == "test_email_cc" @mock_support def test_support_case_include_resolved_defaults_to_false(): - """ - On creating a support request it can be described and it - defaults to not include resolved cases - """ - + """Test support request description doesn't include resolved cases.""" client = boto3.client("support", "us-east-1") create_case_response = client.create_case( subject="test_subject", @@ -494,16 +452,12 @@ def test_support_case_include_resolved_defaults_to_false(): ) actual = describe_cases_response["cases"] - actual.should_not.contain(case_id_list) + assert case_id_list not in actual @mock_support def test_support_case_include_communications_defaults_to_true(): - """ - On creating a support request it can be described and it - defaults to include communcations cases - """ - + """Test support request description includes communications cases.""" client = boto3.client("support", "us-east-1") create_case_response = client.create_case( subject="test_subject", @@ -531,15 +485,12 @@ def test_support_case_include_communications_defaults_to_true(): actual = describe_cases_response["cases"][0] - actual.should.contain("recentCommunications") + assert "recentCommunications" in actual @mock_support def test_multiple_support_created_cases_can_be_described(): - """ - On creating multiple support requests they can be described - """ - + """Test creation of multiple support requests descriptions.""" client = boto3.client("support", "us-east-1") create_case_response_1 = client.create_case( subject="test_subject", @@ -581,17 +532,16 @@ def test_multiple_support_created_cases_can_be_described(): actual_case_id_1 = describe_cases_response["cases"][0]["caseId"] actual_case_id_2 = describe_cases_response["cases"][1]["caseId"] - actual_case_id_1.should.equal(case_id_list[0]) - actual_case_id_2.should.equal(case_id_list[1]) + assert actual_case_id_1 == case_id_list[0] + assert actual_case_id_2 == case_id_list[1] @mock_support def test_support_created_case_can_be_described_and_contains_communications_when_set_to_true(): - """ - On creating a support request it can be described and contains comms - when includeResolvedCases=True - """ + """Test support request description when includeResolvedCases=True. + The suport request description should includes comms. + """ client = boto3.client("support", "us-east-1") create_case_response = client.create_case( subject="test_subject", @@ -619,15 +569,12 @@ def test_support_created_case_can_be_described_and_contains_communications_when_ ) actual_recent_comm = describe_cases_response["cases"][0] - actual_recent_comm.should.contain("recentCommunications") + assert "recentCommunications" in actual_recent_comm @mock_support def test_support_created_case_can_be_described_and_does_not_contain_communications_when_false(): - """ - On creating a support request it does not include - comms when includeCommunications=False - """ + """Test support request creation when includeCommunications=False.""" client = boto3.client("support", "us-east-1") create_case_response = client.create_case( @@ -656,17 +603,12 @@ def test_support_created_case_can_be_described_and_does_not_contain_communicatio ) actual_recent_comm = describe_cases_response["cases"][0] - - actual_recent_comm.should_not.contain("recentCommunications") + assert "recentCommunications" not in actual_recent_comm @mock_support def test_support_created_case_can_be_described_and_contains_resolved_cases_when_true(): - """ - On creating a support request it does contain resolved cases when - includeResolvedCases=true - """ - + """Test support request creation when includeResolvedCases=true.""" client = boto3.client("support", "us-east-1") create_case_response = client.create_case( subject="test_subject", @@ -696,17 +638,12 @@ def test_support_created_case_can_be_described_and_contains_resolved_cases_when_ ) actual = describe_cases_response["cases"][0]["caseId"] - - actual.should.equal(case_id_list) + assert actual == case_id_list @mock_support def test_support_created_case_can_be_described_and_does_not_contain_resolved_cases_when_false(): - """ - On creating a support request it does not contain resolved cases when - includeResolvedCases=false - """ - + """Test support request when includeResolvedCases=false.""" client = boto3.client("support", "us-east-1") create_case_response = client.create_case( subject="test_subject", @@ -736,15 +673,12 @@ def test_support_created_case_can_be_described_and_does_not_contain_resolved_cas ) actual = describe_cases_response["cases"] - actual.should_not.contain(case_id_list) + assert case_id_list not in actual @mock_support def test_support_created_case_can_be_described_and_can_cycle_case_severities(): - """ - On creating a support request it can be described and cycles case severities - """ - + """Test support request creation cycles case severities.""" client = boto3.client("support", "us-east-1") create_case_response = client.create_case( subject="test_subject", @@ -774,5 +708,4 @@ def test_support_created_case_can_be_described_and_can_cycle_case_severities(): ) actual = describe_cases_response["cases"][0]["severityCode"] - - actual.should.equal("urgent") + assert actual == "urgent"