diff --git a/tests/test_guardduty/test_guardduty.py b/tests/test_guardduty/test_guardduty.py index 8ec945b43..4087b79ad 100644 --- a/tests/test_guardduty/test_guardduty.py +++ b/tests/test_guardduty/test_guardduty.py @@ -1,6 +1,5 @@ import boto3 import pytest -import sure # noqa # pylint: disable=unused-import from botocore.exceptions import ClientError from moto import mock_guardduty @@ -16,16 +15,16 @@ def test_create_detector(): DataSources={"S3Logs": {"Enable": True}}, Tags={}, ) - response.should.have.key("DetectorId") - response["DetectorId"].shouldnt.equal(None) + assert "DetectorId" in response + assert response["DetectorId"] is not None @mock_guardduty def test_create_detector_with_minimal_params(): client = boto3.client("guardduty", region_name="us-east-1") response = client.create_detector(Enable=True) - response.should.have.key("DetectorId") - response["DetectorId"].shouldnt.equal(None) + assert "DetectorId" in response + assert response["DetectorId"] is not None @mock_guardduty @@ -40,10 +39,9 @@ def test_get_detector_with_s3(): )["DetectorId"] resp = client.get_detector(DetectorId=detector_id) - resp.should.have.key("FindingPublishingFrequency").equals("ONE_HOUR") - resp.should.have.key("DataSources") - resp["DataSources"].should.have.key("S3Logs").equals({"Status": "ENABLED"}) - resp.should.have.key("CreatedAt") + assert resp["FindingPublishingFrequency"] == "ONE_HOUR" + assert resp["DataSources"]["S3Logs"] == {"Status": "ENABLED"} + assert "CreatedAt" in resp @mock_guardduty @@ -61,14 +59,10 @@ def test_get_detector_with_all_data_sources(): )["DetectorId"] resp = client.get_detector(DetectorId=detector_id) - resp.should.have.key("FindingPublishingFrequency").equals("ONE_HOUR") - resp.should.have.key("DataSources") - resp["DataSources"].should.have.key("S3Logs").equals({"Status": "ENABLED"}) - resp["DataSources"].should.have.key("Kubernetes") - resp["DataSources"]["Kubernetes"].should.have.key("AuditLogs").equals( - {"Status": "ENABLED"} - ) - resp.should.have.key("CreatedAt") + assert resp["FindingPublishingFrequency"] == "ONE_HOUR" + assert resp["DataSources"]["S3Logs"] == {"Status": "ENABLED"} + assert resp["DataSources"]["Kubernetes"]["AuditLogs"] == {"Status": "ENABLED"} + assert "CreatedAt" in resp @mock_guardduty @@ -92,13 +86,9 @@ def test_update_detector(): ) resp = client.get_detector(DetectorId=detector_id) - resp.should.have.key("FindingPublishingFrequency").equals("SIX_HOURS") - resp.should.have.key("DataSources") - resp["DataSources"].should.have.key("S3Logs").equals({"Status": "ENABLED"}) - resp["DataSources"].should.have.key("Kubernetes") - resp["DataSources"]["Kubernetes"].should.have.key("AuditLogs").equals( - {"Status": "DISABLED"} - ) + assert resp["FindingPublishingFrequency"] == "SIX_HOURS" + assert resp["DataSources"]["S3Logs"] == {"Status": "ENABLED"} + assert resp["DataSources"]["Kubernetes"]["AuditLogs"] == {"Status": "DISABLED"} @mock_guardduty @@ -106,7 +96,7 @@ def test_list_detectors_initial(): client = boto3.client("guardduty", region_name="us-east-1") response = client.list_detectors() - response.should.have.key("DetectorIds").equals([]) + assert response["DetectorIds"] == [] @mock_guardduty @@ -122,8 +112,7 @@ def test_list_detectors(): d2 = client.create_detector(Enable=False)["DetectorId"] response = client.list_detectors() - response.should.have.key("DetectorIds") - set(response["DetectorIds"]).should.equal({d1, d2}) + assert set(response["DetectorIds"]) == {d1, d2} @mock_guardduty @@ -147,9 +136,10 @@ def test_delete_detector(): with pytest.raises(ClientError) as exc: client.get_detector(DetectorId=detector_id) err = exc.value.response["Error"] - err["Code"].should.equal("BadRequestException") - err["Message"].should.equal( - "The request is rejected because the input detectorId is not owned by the current account." + assert err["Code"] == "BadRequestException" + assert ( + err["Message"] + == "The request is rejected because the input detectorId is not owned by the current account." ) - client.list_detectors().should.have.key("DetectorIds").equals([]) + assert client.list_detectors()["DetectorIds"] == [] diff --git a/tests/test_guardduty/test_guardduty_filters.py b/tests/test_guardduty/test_guardduty_filters.py index d3e1335d9..2726c9898 100644 --- a/tests/test_guardduty/test_guardduty_filters.py +++ b/tests/test_guardduty/test_guardduty_filters.py @@ -1,6 +1,5 @@ import boto3 import pytest -import sure # noqa # pylint: disable=unused-import from botocore.exceptions import ClientError from moto import mock_guardduty @@ -16,7 +15,7 @@ def test_create_filter(): Name="my first filter", FindingCriteria={"Criterion": {"x": {"Eq": ["y"]}}}, ) - resp.should.have.key("Name").equals("my first filter") + assert resp["Name"] == "my first filter" @mock_guardduty @@ -31,7 +30,7 @@ def test_create_filter__defaults(): ) resp = client.get_filter(DetectorId=detector_id, FilterName="my first filter") - resp.should.have.key("Rank").equals(1) + assert resp["Rank"] == 1 @mock_guardduty @@ -46,8 +45,8 @@ def test_get_filter(): ) resp = client.get_filter(DetectorId=detector_id, FilterName="my first filter") - resp.should.have.key("Name").equals("my first filter") - resp.should.have.key("FindingCriteria").equals({"Criterion": {"x": {"Eq": ["y"]}}}) + assert resp["Name"] == "my first filter" + assert resp["FindingCriteria"] == {"Criterion": {"x": {"Eq": ["y"]}}} @mock_guardduty @@ -68,14 +67,14 @@ def test_update_filter(): Rank=21, Action="NOOP", ) - resp.should.have.key("Name").equals("my first filter") + assert resp["Name"] == "my first filter" resp = client.get_filter(DetectorId=detector_id, FilterName="my first filter") - resp.should.have.key("Name").equals("my first filter") - resp.should.have.key("Description").equals("with desc") - resp.should.have.key("Rank").equals(21) - resp.should.have.key("Action").equals("NOOP") - resp.should.have.key("FindingCriteria").equals({"Criterion": {"x": {"Eq": ["y"]}}}) + assert resp["Name"] == "my first filter" + assert resp["Description"] == "with desc" + assert resp["Rank"] == 21 + assert resp["Action"] == "NOOP" + assert resp["FindingCriteria"] == {"Criterion": {"x": {"Eq": ["y"]}}} @mock_guardduty @@ -94,4 +93,4 @@ def test_delete_filter(): with pytest.raises(ClientError) as exc: client.get_filter(DetectorId=detector_id, FilterName="my first filter") err = exc.value.response["Error"] - err["Code"].should.equal("BadRequestException") + assert err["Code"] == "BadRequestException" diff --git a/tests/test_guardduty/test_guardduty_organization.py b/tests/test_guardduty/test_guardduty_organization.py index 71227462d..e523f490e 100644 --- a/tests/test_guardduty/test_guardduty_organization.py +++ b/tests/test_guardduty/test_guardduty_organization.py @@ -1,5 +1,4 @@ import boto3 -import sure # noqa # pylint: disable=unused-import from moto import mock_guardduty @@ -8,8 +7,7 @@ from moto import mock_guardduty def test_enable_organization_admin_account(): client = boto3.client("guardduty", region_name="us-east-1") resp = client.enable_organization_admin_account(AdminAccountId="") - resp.should.have.key("ResponseMetadata") - resp["ResponseMetadata"].should.have.key("HTTPStatusCode").equals(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 @mock_guardduty @@ -18,7 +16,7 @@ def test_list_organization_admin_accounts(): client.enable_organization_admin_account(AdminAccountId="someaccount") resp = client.list_organization_admin_accounts() - resp.should.have.key("AdminAccounts").length_of(1) - resp["AdminAccounts"].should.contain( - {"AdminAccountId": "someaccount", "AdminStatus": "ENABLED"} - ) + assert len(resp["AdminAccounts"]) == 1 + assert {"AdminAccountId": "someaccount", "AdminStatus": "ENABLED"} in resp[ + "AdminAccounts" + ] diff --git a/tests/test_guardduty/test_server.py b/tests/test_guardduty/test_server.py index 4a09532fa..8a24804ca 100644 --- a/tests/test_guardduty/test_server.py +++ b/tests/test_guardduty/test_server.py @@ -1,5 +1,4 @@ import json -import sure # noqa # pylint: disable=unused-import import moto.server as server @@ -10,5 +9,5 @@ def test_create_without_enable_option(): body = {"enable": "True"} response = test_client.post("/detector", data=json.dumps(body)) - response.status_code.should.equal(200) - json.loads(response.data).should.have.key("detectorId") + assert response.status_code == 200 + assert "detectorId" in json.loads(response.data)