Techdebt: Replace sure with regular assertions in servicequotas (#6604)
This commit is contained in:
parent
7a17e0f89d
commit
75d9082ef4
@ -1,9 +1,9 @@
|
|||||||
"""Unit tests for servicequotas-supported APIs."""
|
"""Unit tests for servicequotas-supported APIs."""
|
||||||
import boto3
|
import boto3
|
||||||
import pytest
|
|
||||||
import sure # noqa # pylint: disable=unused-import
|
|
||||||
from moto import mock_servicequotas
|
|
||||||
from botocore.exceptions import ClientError
|
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:
|
# 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
|
# 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")
|
client = boto3.client("service-quotas", region_name="eu-west-1")
|
||||||
resp = client.list_aws_default_service_quotas(ServiceCode="vpc")
|
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(
|
assert {
|
||||||
{
|
"Adjustable": True,
|
||||||
"Adjustable": True,
|
"GlobalQuota": False,
|
||||||
"GlobalQuota": False,
|
"QuotaArn": "arn:aws:servicequotas:eu-west-1::vpc/L-2AFB9258",
|
||||||
"QuotaArn": "arn:aws:servicequotas:eu-west-1::vpc/L-2AFB9258",
|
"QuotaCode": "L-2AFB9258",
|
||||||
"QuotaCode": "L-2AFB9258",
|
"QuotaName": "Security groups per network interface",
|
||||||
"QuotaName": "Security groups per network interface",
|
"ServiceCode": "vpc",
|
||||||
"ServiceCode": "vpc",
|
"ServiceName": "Amazon Virtual Private Cloud (Amazon VPC)",
|
||||||
"ServiceName": "Amazon Virtual Private Cloud (Amazon VPC)",
|
"Unit": "None",
|
||||||
"Unit": "None",
|
"Value": 5.0,
|
||||||
"Value": 5.0,
|
} in resp["Quotas"]
|
||||||
}
|
assert {
|
||||||
)
|
"Adjustable": True,
|
||||||
resp["Quotas"].should.contain(
|
"GlobalQuota": False,
|
||||||
{
|
"QuotaArn": "arn:aws:servicequotas:eu-west-1::vpc/L-F678F1CE",
|
||||||
"Adjustable": True,
|
"QuotaCode": "L-F678F1CE",
|
||||||
"GlobalQuota": False,
|
"QuotaName": "VPCs per Region",
|
||||||
"QuotaArn": "arn:aws:servicequotas:eu-west-1::vpc/L-F678F1CE",
|
"ServiceCode": "vpc",
|
||||||
"QuotaCode": "L-F678F1CE",
|
"ServiceName": "Amazon Virtual Private Cloud (Amazon VPC)",
|
||||||
"QuotaName": "VPCs per Region",
|
"Unit": "None",
|
||||||
"ServiceCode": "vpc",
|
"Value": 5.0,
|
||||||
"ServiceName": "Amazon Virtual Private Cloud (Amazon VPC)",
|
} in resp["Quotas"]
|
||||||
"Unit": "None",
|
|
||||||
"Value": 5.0,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@mock_servicequotas
|
@mock_servicequotas
|
||||||
@ -51,9 +47,10 @@ def test_list_defaults_for_unknown_service():
|
|||||||
with pytest.raises(ClientError) as exc:
|
with pytest.raises(ClientError) as exc:
|
||||||
client.list_aws_default_service_quotas(ServiceCode="unknown")
|
client.list_aws_default_service_quotas(ServiceCode="unknown")
|
||||||
err = exc.value.response["Error"]
|
err = exc.value.response["Error"]
|
||||||
err["Code"].should.equal("NoSuchResourceException")
|
assert err["Code"] == "NoSuchResourceException"
|
||||||
err["Message"].should.equal(
|
assert err["Message"] == (
|
||||||
"This service is not available in the current Region. Choose a different Region or a different service."
|
"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:
|
for quota in quotas:
|
||||||
resp = client.get_service_quota(ServiceCode="vpc", QuotaCode=quota["QuotaCode"])
|
resp = client.get_service_quota(ServiceCode="vpc", QuotaCode=quota["QuotaCode"])
|
||||||
quota.should.equal(resp["Quota"])
|
assert quota == resp["Quota"]
|
||||||
|
|
||||||
|
|
||||||
@mock_servicequotas
|
@mock_servicequotas
|
||||||
@ -74,4 +71,4 @@ def test_get_unknown_service_quota():
|
|||||||
with pytest.raises(ClientError) as exc:
|
with pytest.raises(ClientError) as exc:
|
||||||
client.get_service_quota(ServiceCode="vpc", QuotaCode="unknown")
|
client.get_service_quota(ServiceCode="vpc", QuotaCode="unknown")
|
||||||
err = exc.value.response["Error"]
|
err = exc.value.response["Error"]
|
||||||
err["Code"].should.equal("NoSuchResourceException")
|
assert err["Code"] == "NoSuchResourceException"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user