Techdebt: Replace sure with regular assertions in servicequotas (#6604)

This commit is contained in:
kbalk 2023-08-06 06:59:41 -04:00 committed by GitHub
parent 7a17e0f89d
commit 75d9082ef4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,9 +1,9 @@
"""Unit tests for servicequotas-supported APIs."""
import boto3
import pytest
import sure # noqa # pylint: disable=unused-import
from moto import mock_servicequotas
from botocore.exceptions import ClientError
import pytest
from moto import mock_servicequotas
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
@ -14,34 +14,30 @@ def test_list_aws_default_service_quotas():
client = boto3.client("service-quotas", region_name="eu-west-1")
resp = client.list_aws_default_service_quotas(ServiceCode="vpc")
resp.should.have.key("Quotas").length_of(25)
assert len(resp["Quotas"]) == 25
resp["Quotas"].should.contain(
{
"Adjustable": True,
"GlobalQuota": False,
"QuotaArn": "arn:aws:servicequotas:eu-west-1::vpc/L-2AFB9258",
"QuotaCode": "L-2AFB9258",
"QuotaName": "Security groups per network interface",
"ServiceCode": "vpc",
"ServiceName": "Amazon Virtual Private Cloud (Amazon VPC)",
"Unit": "None",
"Value": 5.0,
}
)
resp["Quotas"].should.contain(
{
"Adjustable": True,
"GlobalQuota": False,
"QuotaArn": "arn:aws:servicequotas:eu-west-1::vpc/L-F678F1CE",
"QuotaCode": "L-F678F1CE",
"QuotaName": "VPCs per Region",
"ServiceCode": "vpc",
"ServiceName": "Amazon Virtual Private Cloud (Amazon VPC)",
"Unit": "None",
"Value": 5.0,
}
)
assert {
"Adjustable": True,
"GlobalQuota": False,
"QuotaArn": "arn:aws:servicequotas:eu-west-1::vpc/L-2AFB9258",
"QuotaCode": "L-2AFB9258",
"QuotaName": "Security groups per network interface",
"ServiceCode": "vpc",
"ServiceName": "Amazon Virtual Private Cloud (Amazon VPC)",
"Unit": "None",
"Value": 5.0,
} in resp["Quotas"]
assert {
"Adjustable": True,
"GlobalQuota": False,
"QuotaArn": "arn:aws:servicequotas:eu-west-1::vpc/L-F678F1CE",
"QuotaCode": "L-F678F1CE",
"QuotaName": "VPCs per Region",
"ServiceCode": "vpc",
"ServiceName": "Amazon Virtual Private Cloud (Amazon VPC)",
"Unit": "None",
"Value": 5.0,
} in resp["Quotas"]
@mock_servicequotas
@ -51,9 +47,10 @@ def test_list_defaults_for_unknown_service():
with pytest.raises(ClientError) as exc:
client.list_aws_default_service_quotas(ServiceCode="unknown")
err = exc.value.response["Error"]
err["Code"].should.equal("NoSuchResourceException")
err["Message"].should.equal(
"This service is not available in the current Region. Choose a different Region or a different service."
assert err["Code"] == "NoSuchResourceException"
assert err["Message"] == (
"This service is not available in the current Region. Choose a "
"different Region or a different service."
)
@ -64,7 +61,7 @@ def test_get_service_quota():
for quota in quotas:
resp = client.get_service_quota(ServiceCode="vpc", QuotaCode=quota["QuotaCode"])
quota.should.equal(resp["Quota"])
assert quota == resp["Quota"]
@mock_servicequotas
@ -74,4 +71,4 @@ def test_get_unknown_service_quota():
with pytest.raises(ClientError) as exc:
client.get_service_quota(ServiceCode="vpc", QuotaCode="unknown")
err = exc.value.response["Error"]
err["Code"].should.equal("NoSuchResourceException")
assert err["Code"] == "NoSuchResourceException"