Techdebt: Replace sure with regular asserts in APIGatewayV2 tests (#6377)

This commit is contained in:
Bert Blommers 2023-06-08 11:40:10 +00:00 committed by GitHub
parent 681873d177
commit 12c82c3088
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 471 additions and 492 deletions

View File

@ -1,7 +1,6 @@
"""Unit tests for apigatewayv2-supported APIs.""" """Unit tests for apigatewayv2-supported APIs."""
import boto3 import boto3
import pytest import pytest
import sure # noqa # pylint: disable=unused-import
from botocore.exceptions import ClientError from botocore.exceptions import ClientError
from moto import mock_apigatewayv2 from moto import mock_apigatewayv2
@ -17,9 +16,9 @@ def test_create_api_with_unknown_protocol_type():
with pytest.raises(ClientError) as exc: with pytest.raises(ClientError) as exc:
client.create_api(Name="test-api", ProtocolType="?") client.create_api(Name="test-api", ProtocolType="?")
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("BadRequestException") assert err["Code"] == "BadRequestException"
err["Message"].should.equal( assert (
"Invalid protocol specified. Must be one of [HTTP, WEBSOCKET]" err["Message"] == "Invalid protocol specified. Must be one of [HTTP, WEBSOCKET]"
) )
@ -28,20 +27,17 @@ def test_create_api_minimal():
client = boto3.client("apigatewayv2", region_name="eu-west-1") client = boto3.client("apigatewayv2", region_name="eu-west-1")
resp = client.create_api(Name="test-api", ProtocolType="HTTP") resp = client.create_api(Name="test-api", ProtocolType="HTTP")
resp.should.have.key("ApiId") assert "ApiId" in resp
resp.should.have.key("ApiEndpoint").equals( assert (
f"https://{resp['ApiId']}.execute-api.eu-west-1.amazonaws.com" resp["ApiEndpoint"]
) == f"https://{resp['ApiId']}.execute-api.eu-west-1.amazonaws.com"
resp.should.have.key("ApiKeySelectionExpression").equals(
"$request.header.x-api-key"
)
resp.should.have.key("CreatedDate")
resp.should.have.key("DisableExecuteApiEndpoint").equals(False)
resp.should.have.key("Name").equals("test-api")
resp.should.have.key("ProtocolType").equals("HTTP")
resp.should.have.key("RouteSelectionExpression").equals(
"$request.method $request.path"
) )
assert resp["ApiKeySelectionExpression"] == "$request.header.x-api-key"
assert "CreatedDate" in resp
assert resp["DisableExecuteApiEndpoint"] is False
assert resp["Name"] == "test-api"
assert resp["ProtocolType"] == "HTTP"
assert resp["RouteSelectionExpression"] == "$request.method $request.path"
@mock_apigatewayv2 @mock_apigatewayv2
@ -66,14 +62,14 @@ def test_create_api():
Version="1.0", Version="1.0",
) )
resp.should.have.key("ApiId") assert "ApiId" in resp
resp.should.have.key("ApiEndpoint").equals( assert (
f"https://{resp['ApiId']}.execute-api.eu-west-1.amazonaws.com" resp["ApiEndpoint"]
== f"https://{resp['ApiId']}.execute-api.eu-west-1.amazonaws.com"
) )
resp.should.have.key("ApiKeySelectionExpression").equals("s3l3ction") assert resp["ApiKeySelectionExpression"] == "s3l3ction"
resp.should.have.key("CreatedDate") assert "CreatedDate" in resp
resp.should.have.key("CorsConfiguration").equals( assert resp["CorsConfiguration"] == {
{
"AllowCredentials": True, "AllowCredentials": True,
"AllowHeaders": ["x-header1"], "AllowHeaders": ["x-header1"],
"AllowMethods": ["GET", "PUT"], "AllowMethods": ["GET", "PUT"],
@ -81,14 +77,13 @@ def test_create_api():
"ExposeHeaders": ["x-header1"], "ExposeHeaders": ["x-header1"],
"MaxAge": 2, "MaxAge": 2,
} }
) assert resp["Description"] == "my first api"
resp.should.have.key("Description").equals("my first api") assert resp["DisableExecuteApiEndpoint"] is True
resp.should.have.key("DisableExecuteApiEndpoint").equals(True) assert resp["DisableSchemaValidation"] is True
resp.should.have.key("DisableSchemaValidation").equals(True) assert resp["Name"] == "test-api"
resp.should.have.key("Name").equals("test-api") assert resp["ProtocolType"] == "HTTP"
resp.should.have.key("ProtocolType").equals("HTTP") assert resp["RouteSelectionExpression"] == "route_s3l3ction"
resp.should.have.key("RouteSelectionExpression").equals("route_s3l3ction") assert resp["Version"] == "1.0"
resp.should.have.key("Version").equals("1.0")
@mock_apigatewayv2 @mock_apigatewayv2
@ -100,7 +95,7 @@ def test_delete_api():
with pytest.raises(ClientError) as exc: with pytest.raises(ClientError) as exc:
client.get_api(ApiId=api_id) client.get_api(ApiId=api_id)
exc.value.response["Error"]["Code"].should.equal("NotFoundException") assert exc.value.response["Error"]["Code"] == "NotFoundException"
@mock_apigatewayv2 @mock_apigatewayv2
@ -129,9 +124,9 @@ def test_delete_cors_configuration():
resp = client.get_api(ApiId=api_id) resp = client.get_api(ApiId=api_id)
resp.shouldnt.have.key("CorsConfiguration") assert "CorsConfiguration" not in resp
resp.should.have.key("Description").equals("my first api") assert resp["Description"] == "my first api"
resp.should.have.key("Name").equals("test-api") assert resp["Name"] == "test-api"
@mock_apigatewayv2 @mock_apigatewayv2
@ -141,8 +136,8 @@ def test_get_api_unknown():
client.get_api(ApiId="unknown") client.get_api(ApiId="unknown")
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("NotFoundException") assert err["Code"] == "NotFoundException"
err["Message"].should.equal("Invalid API identifier specified unknown") assert err["Message"] == "Invalid API identifier specified unknown"
@mock_apigatewayv2 @mock_apigatewayv2
@ -152,34 +147,31 @@ def test_get_api():
resp = client.get_api(ApiId=api_id) resp = client.get_api(ApiId=api_id)
resp.should.have.key("ApiId").equals(api_id) assert resp["ApiId"] == api_id
resp.should.have.key("ApiEndpoint").equals( assert (
f"https://{resp['ApiId']}.execute-api.ap-southeast-1.amazonaws.com" resp["ApiEndpoint"]
) == f"https://{resp['ApiId']}.execute-api.ap-southeast-1.amazonaws.com"
resp.should.have.key("ApiKeySelectionExpression").equals(
"$request.header.x-api-key"
)
resp.should.have.key("CreatedDate")
resp.should.have.key("DisableExecuteApiEndpoint").equals(False)
resp.should.have.key("Name").equals("test-get-api")
resp.should.have.key("ProtocolType").equals("WEBSOCKET")
resp.should.have.key("RouteSelectionExpression").equals(
"$request.method $request.path"
) )
assert resp["ApiKeySelectionExpression"] == "$request.header.x-api-key"
assert "CreatedDate" in resp
assert resp["DisableExecuteApiEndpoint"] is False
assert resp["Name"] == "test-get-api"
assert resp["ProtocolType"] == "WEBSOCKET"
assert resp["RouteSelectionExpression"] == "$request.method $request.path"
@mock_apigatewayv2 @mock_apigatewayv2
def test_get_apis(): def test_get_apis():
client = boto3.client("apigatewayv2", region_name="ap-southeast-1") client = boto3.client("apigatewayv2", region_name="ap-southeast-1")
client.get_apis().should.have.key("Items").length_of(0) assert len(client.get_apis()["Items"]) == 0
api_id_1 = client.create_api(Name="api1", ProtocolType="HTTP")["ApiId"] api_id_1 = client.create_api(Name="api1", ProtocolType="HTTP")["ApiId"]
api_id_2 = client.create_api(Name="api2", ProtocolType="WEBSOCKET")["ApiId"] api_id_2 = client.create_api(Name="api2", ProtocolType="WEBSOCKET")["ApiId"]
client.get_apis().should.have.key("Items").length_of(2) assert len(client.get_apis()["Items"]) == 2
api_ids = [i["ApiId"] for i in client.get_apis()["Items"]] api_ids = [i["ApiId"] for i in client.get_apis()["Items"]]
api_ids.should.contain(api_id_1) assert api_id_1 in api_ids
api_ids.should.contain(api_id_2) assert api_id_2 in api_ids
@mock_apigatewayv2 @mock_apigatewayv2
@ -216,14 +208,14 @@ def test_update_api_minimal():
}, },
) )
resp.should.have.key("ApiId") assert "ApiId" in resp
resp.should.have.key("ApiEndpoint").equals( assert (
f"https://{resp['ApiId']}.execute-api.eu-west-1.amazonaws.com" resp["ApiEndpoint"]
== f"https://{resp['ApiId']}.execute-api.eu-west-1.amazonaws.com"
) )
resp.should.have.key("ApiKeySelectionExpression").equals("s3l3ction") assert resp["ApiKeySelectionExpression"] == "s3l3ction"
resp.should.have.key("CreatedDate") assert "CreatedDate" in resp
resp.should.have.key("CorsConfiguration").equals( assert resp["CorsConfiguration"] == {
{
"AllowCredentials": False, "AllowCredentials": False,
"AllowHeaders": ["x-header2"], "AllowHeaders": ["x-header2"],
"AllowMethods": ["GET", "PUT"], "AllowMethods": ["GET", "PUT"],
@ -231,14 +223,13 @@ def test_update_api_minimal():
"ExposeHeaders": ["x-header2"], "ExposeHeaders": ["x-header2"],
"MaxAge": 2, "MaxAge": 2,
} }
) assert resp["Description"] == "my first api"
resp.should.have.key("Description").equals("my first api") assert resp["DisableExecuteApiEndpoint"] is True
resp.should.have.key("DisableExecuteApiEndpoint").equals(True) assert resp["DisableSchemaValidation"] is True
resp.should.have.key("DisableSchemaValidation").equals(True) assert resp["Name"] == "test-api"
resp.should.have.key("Name").equals("test-api") assert resp["ProtocolType"] == "HTTP"
resp.should.have.key("ProtocolType").equals("HTTP") assert resp["RouteSelectionExpression"] == "route_s3l3ction"
resp.should.have.key("RouteSelectionExpression").equals("route_s3l3ction") assert resp["Version"] == "1.0"
resp.should.have.key("Version").equals("1.0")
@mock_apigatewayv2 @mock_apigatewayv2
@ -265,18 +256,19 @@ def test_update_api_empty_fields():
resp = client.update_api(ApiId=api_id, Description="", Name="updated", Version="") resp = client.update_api(ApiId=api_id, Description="", Name="updated", Version="")
resp.should.have.key("ApiId") assert "ApiId" in resp
resp.should.have.key("ApiEndpoint").equals( assert (
f"https://{resp['ApiId']}.execute-api.eu-west-1.amazonaws.com" resp["ApiEndpoint"]
== f"https://{resp['ApiId']}.execute-api.eu-west-1.amazonaws.com"
) )
resp.should.have.key("ApiKeySelectionExpression").equals("s3l3ction") assert resp["ApiKeySelectionExpression"] == "s3l3ction"
resp.should.have.key("Description").equals("") assert resp["Description"] == ""
resp.should.have.key("DisableExecuteApiEndpoint").equals(True) assert resp["DisableExecuteApiEndpoint"] is True
resp.should.have.key("DisableSchemaValidation").equals(True) assert resp["DisableSchemaValidation"] is True
resp.should.have.key("Name").equals("updated") assert resp["Name"] == "updated"
resp.should.have.key("ProtocolType").equals("HTTP") assert resp["ProtocolType"] == "HTTP"
resp.should.have.key("RouteSelectionExpression").equals("route_s3l3ction") assert resp["RouteSelectionExpression"] == "route_s3l3ction"
resp.should.have.key("Version").equals("") assert resp["Version"] == ""
@mock_apigatewayv2 @mock_apigatewayv2
@ -303,23 +295,22 @@ def test_update_api():
Version="1.1", Version="1.1",
) )
resp.should.have.key("ApiId") assert "ApiId" in resp
resp.should.have.key("ApiEndpoint").equals( assert (
f"https://{resp['ApiId']}.execute-api.us-east-2.amazonaws.com" resp["ApiEndpoint"]
== f"https://{resp['ApiId']}.execute-api.us-east-2.amazonaws.com"
) )
resp.should.have.key("ApiKeySelectionExpression").equals("api_key_s3l3ction") assert resp["ApiKeySelectionExpression"] == "api_key_s3l3ction"
resp.should.have.key("CorsConfiguration").equals( assert resp["CorsConfiguration"] == {
{
"AllowCredentials": True, "AllowCredentials": True,
"AllowHeaders": ["X-Amz-Target"], "AllowHeaders": ["X-Amz-Target"],
"AllowMethods": ["GET"], "AllowMethods": ["GET"],
} }
) assert "CreatedDate" in resp
resp.should.have.key("CreatedDate") assert resp["Description"] == "updated API"
resp.should.have.key("Description").equals("updated API") assert resp["DisableSchemaValidation"] is True
resp.should.have.key("DisableSchemaValidation").equals(True) assert resp["DisableExecuteApiEndpoint"] is True
resp.should.have.key("DisableExecuteApiEndpoint").equals(True) assert resp["Name"] == "new name"
resp.should.have.key("Name").equals("new name") assert resp["ProtocolType"] == "HTTP"
resp.should.have.key("ProtocolType").equals("HTTP") assert resp["RouteSelectionExpression"] == "route_s3l3ction"
resp.should.have.key("RouteSelectionExpression").equals("route_s3l3ction") assert resp["Version"] == "1.1"
resp.should.have.key("Version").equals("1.1")

View File

@ -18,9 +18,9 @@ def test_create_authorizer_minimum():
AuthorizerPayloadFormatVersion="2.0", AuthorizerPayloadFormatVersion="2.0",
) )
resp.should.have.key("AuthorizerId") assert "AuthorizerId" in resp
resp.should.have.key("AuthorizerType").equals("REQUEST") assert resp["AuthorizerType"] == "REQUEST"
resp.should.have.key("Name").equals("auth1") assert resp["Name"] == "auth1"
@mock_apigatewayv2 @mock_apigatewayv2
@ -42,20 +42,18 @@ def test_create_authorizer():
Name="auth1", Name="auth1",
) )
resp.should.have.key("AuthorizerId") assert "AuthorizerId" in resp
resp.should.have.key("AuthorizerCredentialsArn").equals("auth:creds:arn") assert resp["AuthorizerCredentialsArn"] == "auth:creds:arn"
resp.should.have.key("AuthorizerPayloadFormatVersion").equals("2.0") assert resp["AuthorizerPayloadFormatVersion"] == "2.0"
resp.should.have.key("AuthorizerResultTtlInSeconds").equals(3) assert resp["AuthorizerResultTtlInSeconds"] == 3
resp.should.have.key("AuthorizerType").equals("REQUEST") assert resp["AuthorizerType"] == "REQUEST"
resp.should.have.key("AuthorizerUri").equals("auth_uri") assert resp["AuthorizerUri"] == "auth_uri"
resp.should.have.key("EnableSimpleResponses").equals(True) assert resp["EnableSimpleResponses"] is True
resp.should.have.key("IdentitySource").equals(["$request.header.Authorization"]) assert resp["IdentitySource"] == ["$request.header.Authorization"]
resp.should.have.key("IdentityValidationExpression").equals("ive") assert resp["IdentityValidationExpression"] == "ive"
resp.should.have.key("JwtConfiguration").equals( assert resp["JwtConfiguration"] == {"Audience": ["a1"], "Issuer": "moto.com"}
{"Audience": ["a1"], "Issuer": "moto.com"} assert resp["Name"] == "auth1"
) assert resp["AuthorizerPayloadFormatVersion"] == "2.0"
resp.should.have.key("Name").equals("auth1")
resp.should.have.key("AuthorizerPayloadFormatVersion").equals("2.0")
@mock_apigatewayv2 @mock_apigatewayv2
@ -73,9 +71,10 @@ def test_create_authorizer_without_payloadformatversion():
) )
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("BadRequestException") assert err["Code"] == "BadRequestException"
err["Message"].should.equal( assert (
"AuthorizerPayloadFormatVersion is a required parameter for REQUEST authorizer" err["Message"]
== "AuthorizerPayloadFormatVersion is a required parameter for REQUEST authorizer"
) )
@ -94,10 +93,10 @@ def test_get_authorizer():
resp = client.get_authorizer(ApiId=api_id, AuthorizerId=authorizer_id) resp = client.get_authorizer(ApiId=api_id, AuthorizerId=authorizer_id)
resp.should.have.key("AuthorizerId") assert "AuthorizerId" in resp
resp.should.have.key("AuthorizerType").equals("REQUEST") assert resp["AuthorizerType"] == "REQUEST"
resp.should.have.key("Name").equals("auth1") assert resp["Name"] == "auth1"
resp.should.have.key("AuthorizerPayloadFormatVersion").equals("2.0") assert resp["AuthorizerPayloadFormatVersion"] == "2.0"
@mock_apigatewayv2 @mock_apigatewayv2
@ -115,7 +114,7 @@ def test_delete_authorizer():
client.get_authorizer(ApiId=api_id, AuthorizerId="unknown") client.get_authorizer(ApiId=api_id, AuthorizerId="unknown")
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("NotFoundException") assert err["Code"] == "NotFoundException"
@mock_apigatewayv2 @mock_apigatewayv2
@ -127,7 +126,7 @@ def test_get_authorizer_unknown():
client.get_authorizer(ApiId=api_id, AuthorizerId="unknown") client.get_authorizer(ApiId=api_id, AuthorizerId="unknown")
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("NotFoundException") assert err["Code"] == "NotFoundException"
@mock_apigatewayv2 @mock_apigatewayv2
@ -151,19 +150,17 @@ def test_update_authorizer_single():
resp = client.update_authorizer(ApiId=api_id, AuthorizerId=auth_id, Name="auth2") resp = client.update_authorizer(ApiId=api_id, AuthorizerId=auth_id, Name="auth2")
resp.should.have.key("AuthorizerId") assert "AuthorizerId" in resp
resp.should.have.key("AuthorizerCredentialsArn").equals("auth:creds:arn") assert resp["AuthorizerCredentialsArn"] == "auth:creds:arn"
resp.should.have.key("AuthorizerPayloadFormatVersion").equals("2.0") assert resp["AuthorizerPayloadFormatVersion"] == "2.0"
resp.should.have.key("AuthorizerResultTtlInSeconds").equals(3) assert resp["AuthorizerResultTtlInSeconds"] == 3
resp.should.have.key("AuthorizerType").equals("REQUEST") assert resp["AuthorizerType"] == "REQUEST"
resp.should.have.key("AuthorizerUri").equals("auth_uri") assert resp["AuthorizerUri"] == "auth_uri"
resp.should.have.key("EnableSimpleResponses").equals(True) assert resp["EnableSimpleResponses"] is True
resp.should.have.key("IdentitySource").equals(["$request.header.Authorization"]) assert resp["IdentitySource"] == ["$request.header.Authorization"]
resp.should.have.key("IdentityValidationExpression").equals("ive") assert resp["IdentityValidationExpression"] == "ive"
resp.should.have.key("JwtConfiguration").equals( assert resp["JwtConfiguration"] == {"Audience": ["a1"], "Issuer": "moto.com"}
{"Audience": ["a1"], "Issuer": "moto.com"} assert resp["Name"] == "auth2"
)
resp.should.have.key("Name").equals("auth2")
@mock_apigatewayv2 @mock_apigatewayv2
@ -196,16 +193,14 @@ def test_update_authorizer_all_attributes():
resp = client.update_authorizer(ApiId=api_id, AuthorizerId=auth_id, Name="auth2") resp = client.update_authorizer(ApiId=api_id, AuthorizerId=auth_id, Name="auth2")
resp.should.have.key("AuthorizerId") assert "AuthorizerId" in resp
resp.should.have.key("AuthorizerCredentialsArn").equals("") assert resp["AuthorizerCredentialsArn"] == ""
resp.should.have.key("AuthorizerPayloadFormatVersion").equals("3.0") assert resp["AuthorizerPayloadFormatVersion"] == "3.0"
resp.should.have.key("AuthorizerResultTtlInSeconds").equals(5) assert resp["AuthorizerResultTtlInSeconds"] == 5
resp.should.have.key("AuthorizerType").equals("REQUEST") assert resp["AuthorizerType"] == "REQUEST"
resp.should.have.key("AuthorizerUri").equals("auth_uri") assert resp["AuthorizerUri"] == "auth_uri"
resp.should.have.key("EnableSimpleResponses").equals(False) assert resp["EnableSimpleResponses"] is False
resp.should.have.key("IdentitySource").equals(["$request.header.Authentication"]) assert resp["IdentitySource"] == ["$request.header.Authentication"]
resp.should.have.key("IdentityValidationExpression").equals("ive2") assert resp["IdentityValidationExpression"] == "ive2"
resp.should.have.key("JwtConfiguration").equals( assert resp["JwtConfiguration"] == {"Audience": ["a2"], "Issuer": "moto.com"}
{"Audience": ["a2"], "Issuer": "moto.com"} assert resp["Name"] == "auth2"
)
resp.should.have.key("Name").equals("auth2")

View File

@ -1,5 +1,4 @@
import boto3 import boto3
import sure # noqa # pylint: disable=unused-import
import pytest import pytest
import botocore.exceptions import botocore.exceptions
from moto import mock_apigatewayv2 from moto import mock_apigatewayv2
@ -23,19 +22,19 @@ def test_create_domain_name():
# check post response has all keys # check post response has all keys
for key in expected_keys: for key in expected_keys:
post_resp.should.have.key(key) assert key in post_resp
# check get response has all keys # check get response has all keys
for key in expected_keys: for key in expected_keys:
get_resp.should.have.key(key) assert key in get_resp
# check that values are equal for post and get of same resource # check that values are equal for post and get of same resource
for key in expected_keys: for key in expected_keys:
post_resp.get(key).should.equal(get_resp.get(key)) assert post_resp.get(key) == get_resp.get(key)
# ensure known values are set correct in post response # ensure known values are set correct in post response
post_resp.get("DomainName").should.equal(domain_name) assert post_resp.get("DomainName") == domain_name
post_resp.get("Tags").should.equal(tags) assert post_resp.get("Tags") == tags
@mock_apigatewayv2 @mock_apigatewayv2
@ -47,8 +46,8 @@ def test_create_domain_name_already_exists():
client.create_domain_name(DomainName="exists.io") client.create_domain_name(DomainName="exists.io")
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("ConflictException") assert err["Code"] == "ConflictException"
err["Message"].should.equal("The domain name resource already exists.") assert err["Message"] == "The domain name resource already exists."
@mock_apigatewayv2 @mock_apigatewayv2
@ -58,17 +57,17 @@ def test_get_domain_names():
prod_domain = client.create_domain_name(DomainName="prod.service.io") prod_domain = client.create_domain_name(DomainName="prod.service.io")
# sanity check responses # sanity check responses
dev_domain.should.have.key("DomainName").equals("dev.service.io") assert dev_domain["DomainName"] == "dev.service.io"
prod_domain.should.have.key("DomainName").equals("prod.service.io") assert prod_domain["DomainName"] == "prod.service.io"
# make comparable # make comparable
del dev_domain["ResponseMetadata"] del dev_domain["ResponseMetadata"]
del prod_domain["ResponseMetadata"] del prod_domain["ResponseMetadata"]
get_resp = client.get_domain_names() get_resp = client.get_domain_names()
get_resp.should.have.key("Items") assert "Items" in get_resp
get_resp.get("Items").should.contain(dev_domain) assert dev_domain in get_resp.get("Items")
get_resp.get("Items").should.contain(prod_domain) assert prod_domain in get_resp.get("Items")
@mock_apigatewayv2 @mock_apigatewayv2
@ -79,8 +78,8 @@ def test_delete_domain_name():
get_resp = client.get_domain_names() get_resp = client.get_domain_names()
del post_resp["ResponseMetadata"] del post_resp["ResponseMetadata"]
get_resp.should.have.key("Items") assert "Items" in get_resp
get_resp.get("Items").should_not.contain(post_resp) assert post_resp not in get_resp.get("Items")
@mock_apigatewayv2 @mock_apigatewayv2
@ -90,7 +89,8 @@ def test_delete_domain_name_dne():
client.delete_domain_name(DomainName="dne.io") client.delete_domain_name(DomainName="dne.io")
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("NotFoundException") assert err["Code"] == "NotFoundException"
err["Message"].should.equal( assert (
"The domain name resource specified in the request was not found." err["Message"]
== "The domain name resource specified in the request was not found."
) )

View File

@ -14,7 +14,7 @@ def test_get_integration_responses_empty():
] ]
resp = client.get_integration_responses(ApiId=api_id, IntegrationId=int_id) resp = client.get_integration_responses(ApiId=api_id, IntegrationId=int_id)
resp.should.have.key("Items").equals([]) assert resp["Items"] == []
@mock_apigatewayv2 @mock_apigatewayv2
@ -36,12 +36,12 @@ def test_create_integration_response():
TemplateSelectionExpression="tse", TemplateSelectionExpression="tse",
) )
int_res.should.have.key("ContentHandlingStrategy").equals("CONVERT_TO_BINARY") assert int_res["ContentHandlingStrategy"] == "CONVERT_TO_BINARY"
int_res.should.have.key("IntegrationResponseId") assert "IntegrationResponseId" in int_res
int_res.should.have.key("IntegrationResponseKey").equals("int_res_key") assert int_res["IntegrationResponseKey"] == "int_res_key"
int_res.should.have.key("ResponseParameters").equals({"x-header": "header-value"}) assert int_res["ResponseParameters"] == {"x-header": "header-value"}
int_res.should.have.key("ResponseTemplates").equals({"t": "template"}) assert int_res["ResponseTemplates"] == {"t": "template"}
int_res.should.have.key("TemplateSelectionExpression").equals("tse") assert int_res["TemplateSelectionExpression"] == "tse"
@mock_apigatewayv2 @mock_apigatewayv2
@ -66,12 +66,12 @@ def test_get_integration_response():
ApiId=api_id, IntegrationId=int_id, IntegrationResponseId=int_res_id ApiId=api_id, IntegrationId=int_id, IntegrationResponseId=int_res_id
) )
int_res.should.have.key("ContentHandlingStrategy").equals("CONVERT_TO_BINARY") assert int_res["ContentHandlingStrategy"] == "CONVERT_TO_BINARY"
int_res.should.have.key("IntegrationResponseId") assert "IntegrationResponseId" in int_res
int_res.should.have.key("IntegrationResponseKey").equals("int_res_key") assert int_res["IntegrationResponseKey"] == "int_res_key"
int_res.should.have.key("ResponseParameters").equals({"x-header": "header-value"}) assert int_res["ResponseParameters"] == {"x-header": "header-value"}
int_res.should.have.key("ResponseTemplates").equals({"t": "template"}) assert int_res["ResponseTemplates"] == {"t": "template"}
int_res.should.have.key("TemplateSelectionExpression").equals("tse") assert int_res["TemplateSelectionExpression"] == "tse"
@mock_apigatewayv2 @mock_apigatewayv2
@ -87,10 +87,8 @@ def test_get_integration_response_unknown():
ApiId=api_id, IntegrationId=int_id, IntegrationResponseId="unknown" ApiId=api_id, IntegrationId=int_id, IntegrationResponseId="unknown"
) )
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("NotFoundException") assert err["Code"] == "NotFoundException"
err["Message"].should.equal( assert err["Message"] == "Invalid IntegrationResponse identifier specified unknown"
"Invalid IntegrationResponse identifier specified unknown"
)
@mock_apigatewayv2 @mock_apigatewayv2
@ -114,7 +112,7 @@ def test_delete_integration_response():
ApiId=api_id, IntegrationId=int_id, IntegrationResponseId=int_res_id ApiId=api_id, IntegrationId=int_id, IntegrationResponseId=int_res_id
) )
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("NotFoundException") assert err["Code"] == "NotFoundException"
@mock_apigatewayv2 @mock_apigatewayv2
@ -136,9 +134,9 @@ def test_update_integration_response_single_attr():
ContentHandlingStrategy="CONVERT_TO_BINARY", ContentHandlingStrategy="CONVERT_TO_BINARY",
) )
res.should.have.key("ContentHandlingStrategy").equals("CONVERT_TO_BINARY") assert res["ContentHandlingStrategy"] == "CONVERT_TO_BINARY"
res.should.have.key("IntegrationResponseId") assert "IntegrationResponseId" in res
res.should.have.key("IntegrationResponseKey").equals("int_res_key") assert res["IntegrationResponseKey"] == "int_res_key"
@mock_apigatewayv2 @mock_apigatewayv2
@ -166,9 +164,9 @@ def test_update_integration_response_multiple_attrs():
TemplateSelectionExpression="tse", TemplateSelectionExpression="tse",
) )
res.should.have.key("ContentHandlingStrategy").equals("CONVERT_TO_BINARY") assert res["ContentHandlingStrategy"] == "CONVERT_TO_BINARY"
res.should.have.key("IntegrationResponseId") assert "IntegrationResponseId" in res
res.should.have.key("IntegrationResponseKey").equals("int_res_key2") assert res["IntegrationResponseKey"] == "int_res_key2"
res.should.have.key("ResponseParameters").equals({"x-header": "header-value"}) assert res["ResponseParameters"] == {"x-header": "header-value"}
res.should.have.key("ResponseTemplates").equals({"t": "template"}) assert res["ResponseTemplates"] == {"t": "template"}
res.should.have.key("TemplateSelectionExpression").equals("tse") assert res["TemplateSelectionExpression"] == "tse"

View File

@ -11,7 +11,7 @@ def test_get_integrations_empty():
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"] api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
resp = client.get_integrations(ApiId=api_id) resp = client.get_integrations(ApiId=api_id)
resp.should.have.key("Items").equals([]) assert resp["Items"] == []
@mock_apigatewayv2 @mock_apigatewayv2
@ -21,8 +21,8 @@ def test_create_integration_minimum():
resp = client.create_integration(ApiId=api_id, IntegrationType="HTTP") resp = client.create_integration(ApiId=api_id, IntegrationType="HTTP")
resp.should.have.key("IntegrationId") assert "IntegrationId" in resp
resp.should.have.key("IntegrationType").equals("HTTP") assert resp["IntegrationType"] == "HTTP"
@mock_apigatewayv2 @mock_apigatewayv2
@ -34,10 +34,11 @@ def test_create_integration_for_internet_mock():
ApiId=api_id, ConnectionType="INTERNET", IntegrationType="MOCK" ApiId=api_id, ConnectionType="INTERNET", IntegrationType="MOCK"
) )
resp.should.have.key("IntegrationId") assert "IntegrationId" in resp
resp.should.have.key("IntegrationType").equals("MOCK") assert resp["IntegrationType"] == "MOCK"
resp.should.have.key("IntegrationResponseSelectionExpression").equals( assert (
"${integration.response.statuscode}" resp["IntegrationResponseSelectionExpression"]
== "${integration.response.statuscode}"
) )
@ -66,23 +67,23 @@ def test_create_integration_full():
TlsConfig={"ServerNameToVerify": "server"}, TlsConfig={"ServerNameToVerify": "server"},
) )
resp.should.have.key("IntegrationId") assert "IntegrationId" in resp
resp.should.have.key("ConnectionId").equals("conn_id") assert resp["ConnectionId"] == "conn_id"
resp.should.have.key("ConnectionType").equals("INTERNET") assert resp["ConnectionType"] == "INTERNET"
resp.should.have.key("ContentHandlingStrategy").equals("CONVERT_TO_BINARY") assert resp["ContentHandlingStrategy"] == "CONVERT_TO_BINARY"
resp.should.have.key("CredentialsArn").equals("cred:arn") assert resp["CredentialsArn"] == "cred:arn"
resp.should.have.key("Description").equals("my full integration") assert resp["Description"] == "my full integration"
resp.should.have.key("IntegrationMethod").equals("PUT") assert resp["IntegrationMethod"] == "PUT"
resp.should.have.key("IntegrationType").equals("HTTP") assert resp["IntegrationType"] == "HTTP"
resp.should.have.key("IntegrationSubtype").equals("n/a") assert resp["IntegrationSubtype"] == "n/a"
resp.should.have.key("PassthroughBehavior").equals("WHEN_NO_MATCH") assert resp["PassthroughBehavior"] == "WHEN_NO_MATCH"
resp.should.have.key("PayloadFormatVersion").equals("1.0") assert resp["PayloadFormatVersion"] == "1.0"
resp.should.have.key("RequestParameters").equals({"r": "p"}) assert resp["RequestParameters"] == {"r": "p"}
resp.should.have.key("RequestTemplates").equals({"r": "t"}) assert resp["RequestTemplates"] == {"r": "t"}
resp.should.have.key("ResponseParameters").equals({"res": {"par": "am"}}) assert resp["ResponseParameters"] == {"res": {"par": "am"}}
resp.should.have.key("TemplateSelectionExpression").equals("tse") assert resp["TemplateSelectionExpression"] == "tse"
resp.should.have.key("TimeoutInMillis").equals(123) assert resp["TimeoutInMillis"] == 123
resp.should.have.key("TlsConfig").equals({"ServerNameToVerify": "server"}) assert resp["TlsConfig"] == {"ServerNameToVerify": "server"}
@mock_apigatewayv2 @mock_apigatewayv2
@ -96,8 +97,8 @@ def test_get_integration():
resp = client.get_integration(ApiId=api_id, IntegrationId=integration_id) resp = client.get_integration(ApiId=api_id, IntegrationId=integration_id)
resp.should.have.key("IntegrationId") assert "IntegrationId" in resp
resp.should.have.key("IntegrationType").equals("HTTP") assert resp["IntegrationType"] == "HTTP"
@mock_apigatewayv2 @mock_apigatewayv2
@ -108,8 +109,8 @@ def test_get_integration_unknown():
with pytest.raises(ClientError) as exc: with pytest.raises(ClientError) as exc:
client.get_integration(ApiId=api_id, IntegrationId="unknown") client.get_integration(ApiId=api_id, IntegrationId="unknown")
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("NotFoundException") assert err["Code"] == "NotFoundException"
err["Message"].should.equal("Invalid Integration identifier specified unknown") assert err["Message"] == "Invalid Integration identifier specified unknown"
@mock_apigatewayv2 @mock_apigatewayv2
@ -122,8 +123,8 @@ def test_get_integrations():
] ]
resp = client.get_integrations(ApiId=api_id) resp = client.get_integrations(ApiId=api_id)
resp.should.have.key("Items").length_of(1) assert len(resp["Items"]) == 1
resp["Items"][0].should.have.key("IntegrationId").equals(integration_id) assert resp["Items"][0]["IntegrationId"] == integration_id
@mock_apigatewayv2 @mock_apigatewayv2
@ -140,7 +141,7 @@ def test_delete_integration():
with pytest.raises(ClientError) as exc: with pytest.raises(ClientError) as exc:
client.get_integration(ApiId=api_id, IntegrationId=integration_id) client.get_integration(ApiId=api_id, IntegrationId=integration_id)
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("NotFoundException") assert err["Code"] == "NotFoundException"
@mock_apigatewayv2 @mock_apigatewayv2
@ -172,23 +173,23 @@ def test_update_integration_single_attr():
ApiId=api_id, IntegrationId=int_id, Description="updated int" ApiId=api_id, IntegrationId=int_id, Description="updated int"
) )
resp.should.have.key("IntegrationId") assert "IntegrationId" in resp
resp.should.have.key("ConnectionId").equals("conn_id") assert resp["ConnectionId"] == "conn_id"
resp.should.have.key("ConnectionType").equals("INTERNET") assert resp["ConnectionType"] == "INTERNET"
resp.should.have.key("ContentHandlingStrategy").equals("CONVERT_TO_BINARY") assert resp["ContentHandlingStrategy"] == "CONVERT_TO_BINARY"
resp.should.have.key("CredentialsArn").equals("cred:arn") assert resp["CredentialsArn"] == "cred:arn"
resp.should.have.key("Description").equals("updated int") assert resp["Description"] == "updated int"
resp.should.have.key("IntegrationMethod").equals("PUT") assert resp["IntegrationMethod"] == "PUT"
resp.should.have.key("IntegrationType").equals("HTTP") assert resp["IntegrationType"] == "HTTP"
resp.should.have.key("IntegrationSubtype").equals("n/a") assert resp["IntegrationSubtype"] == "n/a"
resp.should.have.key("PassthroughBehavior").equals("WHEN_NO_MATCH") assert resp["PassthroughBehavior"] == "WHEN_NO_MATCH"
resp.should.have.key("PayloadFormatVersion").equals("1.0") assert resp["PayloadFormatVersion"] == "1.0"
resp.should.have.key("RequestParameters").equals({"r": "p"}) assert resp["RequestParameters"] == {"r": "p"}
resp.should.have.key("RequestTemplates").equals({"r": "t"}) assert resp["RequestTemplates"] == {"r": "t"}
resp.should.have.key("ResponseParameters").equals({"res": {"par": "am"}}) assert resp["ResponseParameters"] == {"res": {"par": "am"}}
resp.should.have.key("TemplateSelectionExpression").equals("tse") assert resp["TemplateSelectionExpression"] == "tse"
resp.should.have.key("TimeoutInMillis").equals(123) assert resp["TimeoutInMillis"] == 123
resp.should.have.key("TlsConfig").equals({"ServerNameToVerify": "server"}) assert resp["TlsConfig"] == {"ServerNameToVerify": "server"}
@mock_apigatewayv2 @mock_apigatewayv2
@ -227,23 +228,23 @@ def test_update_integration_all_attrs():
PassthroughBehavior="NEVER", PassthroughBehavior="NEVER",
) )
resp.should.have.key("IntegrationId") assert "IntegrationId" in resp
resp.should.have.key("ConnectionId").equals("conn_id") assert resp["ConnectionId"] == "conn_id"
resp.should.have.key("ConnectionType").equals("VPC_LINK") assert resp["ConnectionType"] == "VPC_LINK"
resp.should.have.key("ContentHandlingStrategy").equals("CONVERT_TO_TEXT") assert resp["ContentHandlingStrategy"] == "CONVERT_TO_TEXT"
resp.should.have.key("CredentialsArn").equals("") assert resp["CredentialsArn"] == ""
resp.should.have.key("Description").equals("my full integration") assert resp["Description"] == "my full integration"
resp.should.have.key("IntegrationMethod").equals("PATCH") assert resp["IntegrationMethod"] == "PATCH"
resp.should.have.key("IntegrationType").equals("AWS") assert resp["IntegrationType"] == "AWS"
resp.should.have.key("IntegrationSubtype").equals("n/a") assert resp["IntegrationSubtype"] == "n/a"
resp.should.have.key("PassthroughBehavior").equals("NEVER") assert resp["PassthroughBehavior"] == "NEVER"
resp.should.have.key("PayloadFormatVersion").equals("1.0") assert resp["PayloadFormatVersion"] == "1.0"
resp.should.have.key("RequestParameters").equals({"r": "p"}) assert resp["RequestParameters"] == {"r": "p"}
resp.should.have.key("RequestTemplates").equals({"r": "t"}) assert resp["RequestTemplates"] == {"r": "t"}
resp.should.have.key("ResponseParameters").equals({"res": {"par": "am"}}) assert resp["ResponseParameters"] == {"res": {"par": "am"}}
resp.should.have.key("TemplateSelectionExpression").equals("tse") assert resp["TemplateSelectionExpression"] == "tse"
resp.should.have.key("TimeoutInMillis").equals(123) assert resp["TimeoutInMillis"] == 123
resp.should.have.key("TlsConfig").equals({"ServerNameToVerify": "server"}) assert resp["TlsConfig"] == {"ServerNameToVerify": "server"}
@mock_apigatewayv2 @mock_apigatewayv2
@ -273,9 +274,10 @@ def test_update_integration_request_parameters():
int_id = resp["IntegrationId"] int_id = resp["IntegrationId"]
# Having an empty value between quotes ("''") is valid # Having an empty value between quotes ("''") is valid
resp["RequestParameters"].should.equal( assert resp["RequestParameters"] == {
{"append:header.header1": "$context.requestId", "remove:querystring.qs1": "''"} "append:header.header1": "$context.requestId",
) "remove:querystring.qs1": "''",
}
resp = client.update_integration( resp = client.update_integration(
ApiId=api_id, ApiId=api_id,
@ -295,23 +297,19 @@ def test_update_integration_request_parameters():
}, },
) )
resp.should.have.key("IntegrationId") assert "IntegrationId" in resp
resp.should.have.key("IntegrationMethod").equals("ANY") assert resp["IntegrationMethod"] == "ANY"
resp.should.have.key("IntegrationType").equals("HTTP_PROXY") assert resp["IntegrationType"] == "HTTP_PROXY"
resp.should.have.key("PayloadFormatVersion").equals("1.0") assert resp["PayloadFormatVersion"] == "1.0"
# Having no value ("") is not valid, so that param should not be persisted # Having no value ("") is not valid, so that param should not be persisted
resp.should.have.key("RequestParameters").equals( assert resp["RequestParameters"] == {
{
"append:header.header1": "$context.accountId", "append:header.header1": "$context.accountId",
"overwrite:header.header2": "$stageVariables.environmentId", "overwrite:header.header2": "$stageVariables.environmentId",
} }
) assert resp["ResponseParameters"] == {
resp.should.have.key("ResponseParameters").equals(
{
"404": {}, "404": {},
"500": { "500": {
"append:header.header1": "$context.requestId", "append:header.header1": "$context.requestId",
"overwrite:statuscode": "403", "overwrite:statuscode": "403",
}, },
} }
)

View File

@ -1,5 +1,4 @@
import boto3 import boto3
import sure # noqa # pylint: disable=unused-import
import pytest import pytest
import botocore.exceptions import botocore.exceptions
from moto import mock_apigatewayv2 from moto import mock_apigatewayv2
@ -25,21 +24,21 @@ def test_create_api_mapping():
# check post response has all expected keys # check post response has all expected keys
for key in expected_keys: for key in expected_keys:
post_resp.should.have.key(key) assert key in post_resp
# check get response has all expected keys # check get response has all expected keys
for key in expected_keys: for key in expected_keys:
get_resp.should.have.key(key) assert key in get_resp
# check that values are equal for post and get of same resource # check that values are equal for post and get of same resource
for key in expected_keys: for key in expected_keys:
post_resp.get(key).should.equal(get_resp.get(key)) assert post_resp.get(key) == get_resp.get(key)
# ensure known values are set correct in post response # ensure known values are set correct in post response
post_resp.get("ApiId").should_not.equal(None) assert post_resp.get("ApiId") is not None
post_resp.get("ApiMappingId").should_not.equal(None) assert post_resp.get("ApiMappingId") is not None
post_resp.get("ApiMappingKey").should.equal("v1/api") assert post_resp.get("ApiMappingKey") == "v1/api"
post_resp.get("Stage").should.equal("$default") assert post_resp.get("Stage") == "$default"
@mock_apigatewayv2 @mock_apigatewayv2
@ -54,9 +53,10 @@ def test_create_api_mapping_missing_api():
) )
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("NotFoundException") assert err["Code"] == "NotFoundException"
err["Message"].should.equal( assert (
"Invalid API identifier specified The resource specified in the request was not found." err["Message"]
== "Invalid API identifier specified The resource specified in the request was not found."
) )
@ -73,9 +73,10 @@ def test_create_api_mapping_missing_domain():
) )
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("NotFoundException") assert err["Code"] == "NotFoundException"
err["Message"].should.equal( assert (
"The domain name resource specified in the request was not found." err["Message"]
== "The domain name resource specified in the request was not found."
) )
@ -100,8 +101,8 @@ def test_create_api_mapping_bad_mapping_keys():
) )
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("BadRequestException") assert err["Code"] == "BadRequestException"
err["Message"].should.equal(message) assert err["Message"] == message
@mock_apigatewayv2 @mock_apigatewayv2
@ -133,9 +134,9 @@ def test_get_api_mappings():
) )
# sanity check responses # sanity check responses
v1_mapping.should.have.key("ApiMappingKey").equals("v1/api") assert v1_mapping["ApiMappingKey"] == "v1/api"
v2_mapping.should.have.key("ApiMappingKey").equals("v2/api") assert v2_mapping["ApiMappingKey"] == "v2/api"
hr_mapping.should.have.key("ApiMappingKey").equals("hr/api") assert hr_mapping["ApiMappingKey"] == "hr/api"
# make comparable # make comparable
del v1_mapping["ResponseMetadata"] del v1_mapping["ResponseMetadata"]
@ -143,10 +144,10 @@ def test_get_api_mappings():
del hr_mapping["ResponseMetadata"] del hr_mapping["ResponseMetadata"]
get_resp = client.get_api_mappings(DomainName=included_domain["DomainName"]) get_resp = client.get_api_mappings(DomainName=included_domain["DomainName"])
get_resp.should.have.key("Items") assert "Items" in get_resp
get_resp.get("Items").should.contain(v1_mapping) assert v1_mapping in get_resp.get("Items")
get_resp.get("Items").should.contain(v2_mapping) assert v2_mapping in get_resp.get("Items")
get_resp.get("Items").should_not.contain(hr_mapping) assert hr_mapping not in get_resp.get("Items")
@mock_apigatewayv2 @mock_apigatewayv2
@ -165,16 +166,16 @@ def test_delete_api_mapping():
del v1_mapping["ResponseMetadata"] del v1_mapping["ResponseMetadata"]
get_resp = client.get_api_mappings(DomainName=api_domain["DomainName"]) get_resp = client.get_api_mappings(DomainName=api_domain["DomainName"])
get_resp.should.have.key("Items") assert "Items" in get_resp
get_resp.get("Items").should.contain(v1_mapping) assert v1_mapping in get_resp.get("Items")
client.delete_api_mapping( client.delete_api_mapping(
DomainName=api_domain["DomainName"], ApiMappingId=v1_mapping["ApiMappingId"] DomainName=api_domain["DomainName"], ApiMappingId=v1_mapping["ApiMappingId"]
) )
get_resp = client.get_api_mappings(DomainName=api_domain["DomainName"]) get_resp = client.get_api_mappings(DomainName=api_domain["DomainName"])
get_resp.should.have.key("Items") assert "Items" in get_resp
get_resp.get("Items").should_not.contain(v1_mapping) assert v1_mapping not in get_resp.get("Items")
@mock_apigatewayv2 @mock_apigatewayv2
@ -189,7 +190,8 @@ def test_delete_api_mapping_dne():
) )
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("NotFoundException") assert err["Code"] == "NotFoundException"
err["Message"].should.equal( assert (
"The api mapping resource specified in the request was not found." err["Message"]
== "The api mapping resource specified in the request was not found."
) )

View File

@ -14,11 +14,11 @@ def test_create_model():
ApiId=api_id, ContentType="app/xml", Description="desc", Name="nm", Schema="cs" ApiId=api_id, ContentType="app/xml", Description="desc", Name="nm", Schema="cs"
) )
resp.should.have.key("ContentType").equals("app/xml") assert resp["ContentType"] == "app/xml"
resp.should.have.key("Description").equals("desc") assert resp["Description"] == "desc"
resp.should.have.key("ModelId") assert "ModelId" in resp
resp.should.have.key("Name").equals("nm") assert resp["Name"] == "nm"
resp.should.have.key("Schema").equals("cs") assert resp["Schema"] == "cs"
@mock_apigatewayv2 @mock_apigatewayv2
@ -32,11 +32,11 @@ def test_get_model():
resp = client.get_model(ApiId=api_id, ModelId=model_id) resp = client.get_model(ApiId=api_id, ModelId=model_id)
resp.should.have.key("ContentType").equals("app/xml") assert resp["ContentType"] == "app/xml"
resp.should.have.key("Description").equals("desc") assert resp["Description"] == "desc"
resp.should.have.key("ModelId") assert "ModelId" in resp
resp.should.have.key("Name").equals("nm") assert resp["Name"] == "nm"
resp.should.have.key("Schema").equals("cs") assert resp["Schema"] == "cs"
@mock_apigatewayv2 @mock_apigatewayv2
@ -54,7 +54,7 @@ def test_delete_model():
client.get_model(ApiId=api_id, ModelId=model_id) client.get_model(ApiId=api_id, ModelId=model_id)
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("NotFoundException") assert err["Code"] == "NotFoundException"
@mock_apigatewayv2 @mock_apigatewayv2
@ -66,7 +66,7 @@ def test_get_model_unknown():
client.get_model(ApiId=api_id, ModelId="unknown") client.get_model(ApiId=api_id, ModelId="unknown")
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("NotFoundException") assert err["Code"] == "NotFoundException"
@mock_apigatewayv2 @mock_apigatewayv2
@ -82,11 +82,11 @@ def test_update_model_single_attr():
resp = client.update_model(ApiId=api_id, ModelId=model_id, Schema="cs2") resp = client.update_model(ApiId=api_id, ModelId=model_id, Schema="cs2")
resp.should.have.key("ContentType").equals("app/xml") assert resp["ContentType"] == "app/xml"
resp.should.have.key("Description").equals("desc") assert resp["Description"] == "desc"
resp.should.have.key("ModelId") assert "ModelId" in resp
resp.should.have.key("Name").equals("nm") assert resp["Name"] == "nm"
resp.should.have.key("Schema").equals("cs2") assert resp["Schema"] == "cs2"
@mock_apigatewayv2 @mock_apigatewayv2
@ -109,7 +109,7 @@ def test_update_model_all_attrs():
Schema="cs2", Schema="cs2",
) )
resp.should.have.key("ContentType").equals("app/html") assert resp["ContentType"] == "app/html"
resp.should.have.key("Description").equals("html2.x") assert resp["Description"] == "html2.x"
resp.should.have.key("Name").equals("html-schema") assert resp["Name"] == "html-schema"
resp.should.have.key("Schema").equals("cs2") assert resp["Schema"] == "cs2"

View File

@ -1,6 +1,5 @@
import boto3 import boto3
import pytest import pytest
import sure # noqa # pylint: disable=unused-import
from botocore.exceptions import ClientError from botocore.exceptions import ClientError
from moto import mock_apigatewayv2 from moto import mock_apigatewayv2
@ -16,9 +15,9 @@ def test_reimport_api_standard_fields():
Body="---\nopenapi: 3.0.1\ninfo:\n title: tf-acc-test-2983214806752144669_DIFFERENT\n version: 2.0\nx-amazon-apigateway-cors:\n allow_methods:\n - delete\n allow_origins:\n - https://www.google.de\npaths:\n \"/test\":\n get:\n x-amazon-apigateway-integration:\n type: HTTP_PROXY\n httpMethod: GET\n payloadFormatVersion: '1.0'\n uri: https://www.google.de\n", Body="---\nopenapi: 3.0.1\ninfo:\n title: tf-acc-test-2983214806752144669_DIFFERENT\n version: 2.0\nx-amazon-apigateway-cors:\n allow_methods:\n - delete\n allow_origins:\n - https://www.google.de\npaths:\n \"/test\":\n get:\n x-amazon-apigateway-integration:\n type: HTTP_PROXY\n httpMethod: GET\n payloadFormatVersion: '1.0'\n uri: https://www.google.de\n",
) )
resp.should.have.key("CorsConfiguration").equals({}) assert resp["CorsConfiguration"] == {}
resp.should.have.key("Name").equals("tf-acc-test-2983214806752144669_DIFFERENT") assert resp["Name"] == "tf-acc-test-2983214806752144669_DIFFERENT"
resp.should.have.key("Version").equals("2.0") assert resp["Version"] == "2.0"
@mock_apigatewayv2 @mock_apigatewayv2
@ -33,14 +32,15 @@ def test_reimport_api_failonwarnings():
FailOnWarnings=True, FailOnWarnings=True,
) )
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("BadRequestException") assert err["Code"] == "BadRequestException"
err["Message"].should.equal( assert (
"Warnings found during import:\n\tParse issue: attribute paths.'/update'(get).responses.200.content.schema.#/components/schemas/ModelThatDoesNotExist is missing" err["Message"]
== "Warnings found during import:\n\tParse issue: attribute paths.'/update'(get).responses.200.content.schema.#/components/schemas/ModelThatDoesNotExist is missing"
) )
# Title should not have been updated # Title should not have been updated
resp = client.get_api(ApiId=api_id) resp = client.get_api(ApiId=api_id)
resp.should.have.key("Name").equals("test-import-api") assert resp["Name"] == "test-import-api"
@mock_apigatewayv2 @mock_apigatewayv2
@ -56,7 +56,7 @@ def test_reimport_api_do_not_failonwarnings():
# Title should have been updated # Title should have been updated
resp = client.get_api(ApiId=api_id) resp = client.get_api(ApiId=api_id)
resp.should.have.key("Name").equals("Title test") assert resp["Name"] == "Title test"
@mock_apigatewayv2 @mock_apigatewayv2
@ -71,24 +71,22 @@ def test_reimport_api_routes_and_integrations():
) )
resp = client.get_integrations(ApiId=api_id) resp = client.get_integrations(ApiId=api_id)
resp.should.have.key("Items").length_of(1) assert len(resp["Items"]) == 1
integration = resp["Items"][0] integration = resp["Items"][0]
integration.should.have.key("ConnectionType").equals("INTERNET") assert integration["ConnectionType"] == "INTERNET"
integration.should.have.key("IntegrationId") assert "IntegrationId" in integration
integration.should.have.key("IntegrationMethod").equals("GET") assert integration["IntegrationMethod"] == "GET"
integration.should.have.key("IntegrationType").equals("HTTP_PROXY") assert integration["IntegrationType"] == "HTTP_PROXY"
integration.should.have.key("IntegrationUri").equals("https://www.google.de") assert integration["IntegrationUri"] == "https://www.google.de"
integration.should.have.key("PayloadFormatVersion").equals("1.0") assert integration["PayloadFormatVersion"] == "1.0"
integration.should.have.key("TimeoutInMillis").equals(30000) assert integration["TimeoutInMillis"] == 30000
resp = client.get_routes(ApiId=api_id) resp = client.get_routes(ApiId=api_id)
resp.should.have.key("Items").length_of(1) assert len(resp["Items"]) == 1
route = resp["Items"][0] route = resp["Items"][0]
route.should.have.key("ApiKeyRequired").equals(False) assert route["ApiKeyRequired"] is False
route.should.have.key("AuthorizationScopes").equals([]) assert route["AuthorizationScopes"] == []
route.should.have.key("RequestParameters").equals({}) assert route["RequestParameters"] == {}
route.should.have.key("RouteId") assert "RouteId" in route
route.should.have.key("RouteKey").equals("GET /test") assert route["RouteKey"] == "GET /test"
route.should.have.key("Target").should.equal( assert route["Target"] == f"integrations/{integration['IntegrationId']}"
f"integrations/{integration['IntegrationId']}"
)

View File

@ -11,7 +11,7 @@ def test_get_routes_empty():
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"] api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
resp = client.get_routes(ApiId=api_id) resp = client.get_routes(ApiId=api_id)
resp.should.have.key("Items").equals([]) assert resp["Items"] == []
@mock_apigatewayv2 @mock_apigatewayv2
@ -20,18 +20,18 @@ def test_create_route_minimal():
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"] api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
resp = client.create_route(ApiId=api_id, RouteKey="GET /") resp = client.create_route(ApiId=api_id, RouteKey="GET /")
resp.should.have.key("ApiKeyRequired").equals(False) assert resp["ApiKeyRequired"] is False
resp.should.have.key("AuthorizationType").equals("NONE") assert resp["AuthorizationType"] == "NONE"
resp.should.have.key("RouteId") assert "RouteId" in resp
resp.should.have.key("RouteKey").equals("GET /") assert resp["RouteKey"] == "GET /"
resp.shouldnt.have.key("AuthorizationScopes") assert "AuthorizationScopes" not in resp
resp.shouldnt.have.key("AuthorizerId") assert "AuthorizerId" not in resp
resp.shouldnt.have.key("ModelSelectionExpression") assert "ModelSelectionExpression" not in resp
resp.shouldnt.have.key("OperationName") assert "OperationName" not in resp
resp.shouldnt.have.key("RequestModels") assert "RequestModels" not in resp
resp.shouldnt.have.key("RouteResponseSelectionExpression") assert "RouteResponseSelectionExpression" not in resp
resp.shouldnt.have.key("Target") assert "Target" not in resp
@mock_apigatewayv2 @mock_apigatewayv2
@ -57,19 +57,19 @@ def test_create_route_full():
Target="t", Target="t",
) )
resp.should.have.key("ApiKeyRequired").equals(True) assert resp["ApiKeyRequired"] is True
resp.should.have.key("AuthorizationType").equals("CUSTOM") assert resp["AuthorizationType"] == "CUSTOM"
resp.should.have.key("AuthorizationScopes").equals(["scope1", "scope2"]) assert resp["AuthorizationScopes"] == ["scope1", "scope2"]
resp.should.have.key("AuthorizerId").equals("auth_id") assert resp["AuthorizerId"] == "auth_id"
resp.should.have.key("RouteId") assert "RouteId" in resp
resp.should.have.key("RouteKey").equals("GET /") assert resp["RouteKey"] == "GET /"
resp.should.have.key("ModelSelectionExpression").equals("mse") assert resp["ModelSelectionExpression"] == "mse"
resp.should.have.key("OperationName").equals("OP") assert resp["OperationName"] == "OP"
resp.should.have.key("RequestModels").equals({"req": "uest"}) assert resp["RequestModels"] == {"req": "uest"}
resp.should.have.key("RequestParameters").equals({"action": {"Required": True}}) assert resp["RequestParameters"] == {"action": {"Required": True}}
resp.should.have.key("RouteResponseSelectionExpression").equals("$default") assert resp["RouteResponseSelectionExpression"] == "$default"
resp.should.have.key("Target").equals("t") assert resp["Target"] == "t"
@mock_apigatewayv2 @mock_apigatewayv2
@ -81,7 +81,7 @@ def test_delete_route():
client.delete_route(ApiId=api_id, RouteId=route_id) client.delete_route(ApiId=api_id, RouteId=route_id)
resp = client.get_routes(ApiId=api_id) resp = client.get_routes(ApiId=api_id)
resp.should.have.key("Items").length_of(0) assert len(resp["Items"]) == 0
@mock_apigatewayv2 @mock_apigatewayv2
@ -92,17 +92,17 @@ def test_get_route():
resp = client.get_route(ApiId=api_id, RouteId=route_id) resp = client.get_route(ApiId=api_id, RouteId=route_id)
resp.should.have.key("ApiKeyRequired").equals(False) assert resp["ApiKeyRequired"] is False
resp.should.have.key("AuthorizationType").equals("NONE") assert resp["AuthorizationType"] == "NONE"
resp.should.have.key("RouteId") assert "RouteId" in resp
resp.should.have.key("RouteKey").equals("GET /") assert resp["RouteKey"] == "GET /"
resp.shouldnt.have.key("AuthorizationScopes") assert "AuthorizationScopes" not in resp
resp.shouldnt.have.key("AuthorizerId") assert "AuthorizerId" not in resp
resp.shouldnt.have.key("ModelSelectionExpression") assert "ModelSelectionExpression" not in resp
resp.shouldnt.have.key("OperationName") assert "OperationName" not in resp
resp.shouldnt.have.key("RouteResponseSelectionExpression") assert "RouteResponseSelectionExpression" not in resp
resp.shouldnt.have.key("Target") assert "Target" not in resp
@mock_apigatewayv2 @mock_apigatewayv2
@ -113,8 +113,8 @@ def test_get_route_unknown():
client.get_route(ApiId=api_id, RouteId="unknown") client.get_route(ApiId=api_id, RouteId="unknown")
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("NotFoundException") assert err["Code"] == "NotFoundException"
err["Message"].should.equal("Invalid Route identifier specified unknown") assert err["Message"] == "Invalid Route identifier specified unknown"
@mock_apigatewayv2 @mock_apigatewayv2
@ -124,7 +124,7 @@ def test_get_routes():
client.create_route(ApiId=api_id, RouteKey="GET /") client.create_route(ApiId=api_id, RouteKey="GET /")
resp = client.get_routes(ApiId=api_id) resp = client.get_routes(ApiId=api_id)
resp.should.have.key("Items").length_of(1) assert len(resp["Items"]) == 1
@mock_apigatewayv2 @mock_apigatewayv2
@ -135,10 +135,10 @@ def test_update_route_single_attribute():
resp = client.update_route(ApiId=api_id, RouteId=route_id, RouteKey="POST /") resp = client.update_route(ApiId=api_id, RouteId=route_id, RouteKey="POST /")
resp.should.have.key("ApiKeyRequired").equals(False) assert resp["ApiKeyRequired"] is False
resp.should.have.key("AuthorizationType").equals("NONE") assert resp["AuthorizationType"] == "NONE"
resp.should.have.key("RouteId").equals(route_id) assert resp["RouteId"] == route_id
resp.should.have.key("RouteKey").equals("POST /") assert resp["RouteKey"] == "POST /"
@mock_apigatewayv2 @mock_apigatewayv2
@ -164,18 +164,18 @@ def test_update_route_all_attributes():
Target="t", Target="t",
) )
resp.should.have.key("ApiKeyRequired").equals(False) assert resp["ApiKeyRequired"] is False
resp.should.have.key("AuthorizationType").equals("JWT") assert resp["AuthorizationType"] == "JWT"
resp.should.have.key("AuthorizationScopes").equals(["scope"]) assert resp["AuthorizationScopes"] == ["scope"]
resp.should.have.key("AuthorizerId").equals("auth_id") assert resp["AuthorizerId"] == "auth_id"
resp.should.have.key("RouteId") assert "RouteId" in resp
resp.should.have.key("RouteKey").equals("GET /") assert resp["RouteKey"] == "GET /"
resp.should.have.key("ModelSelectionExpression").equals("mse") assert resp["ModelSelectionExpression"] == "mse"
resp.should.have.key("OperationName").equals("OP") assert resp["OperationName"] == "OP"
resp.should.have.key("RequestModels").equals({"req": "uest"}) assert resp["RequestModels"] == {"req": "uest"}
resp.should.have.key("RequestParameters").equals({"action": {"Required": True}}) assert resp["RequestParameters"] == {"action": {"Required": True}}
resp.should.have.key("RouteResponseSelectionExpression").equals("$default") assert resp["RouteResponseSelectionExpression"] == "$default"
resp.should.have.key("Target").equals("t") assert resp["Target"] == "t"
@mock_apigatewayv2 @mock_apigatewayv2
@ -195,7 +195,7 @@ def test_delete_route_request_parameter():
request_params = client.get_route(ApiId=api_id, RouteId=route_id)[ request_params = client.get_route(ApiId=api_id, RouteId=route_id)[
"RequestParameters" "RequestParameters"
] ]
request_params.keys().should.have.length_of(3) assert len(request_params.keys()) == 3
client.delete_route_request_parameter( client.delete_route_request_parameter(
ApiId=api_id, ApiId=api_id,
@ -206,9 +206,9 @@ def test_delete_route_request_parameter():
request_params = client.get_route(ApiId=api_id, RouteId=route_id)[ request_params = client.get_route(ApiId=api_id, RouteId=route_id)[
"RequestParameters" "RequestParameters"
] ]
request_params.keys().should.have.length_of(2) assert len(request_params.keys()) == 2
request_params.should.have.key("action") assert "action" in request_params
request_params.should.have.key("zparam") assert "zparam" in request_params
@mock_apigatewayv2 @mock_apigatewayv2
@ -221,8 +221,8 @@ def test_create_route_response_minimal():
ApiId=api_id, RouteId=route_id, RouteResponseKey="$default" ApiId=api_id, RouteId=route_id, RouteResponseKey="$default"
) )
resp.should.have.key("RouteResponseId") assert "RouteResponseId" in resp
resp.should.have.key("RouteResponseKey").equals("$default") assert resp["RouteResponseKey"] == "$default"
@mock_apigatewayv2 @mock_apigatewayv2
@ -239,12 +239,10 @@ def test_create_route_response():
RouteResponseKey="$default", RouteResponseKey="$default",
) )
resp.should.have.key("RouteResponseId") assert "RouteResponseId" in resp
resp.should.have.key("RouteResponseKey").equals("$default") assert resp["RouteResponseKey"] == "$default"
resp.should.have.key("ModelSelectionExpression").equals("mse") assert resp["ModelSelectionExpression"] == "mse"
resp.should.have.key("ResponseModels").equals( assert resp["ResponseModels"] == {"test": "tfacctest5832545056931060873"}
{"test": "tfacctest5832545056931060873"}
)
@mock_apigatewayv2 @mock_apigatewayv2
@ -261,8 +259,8 @@ def test_get_route_response():
ApiId=api_id, RouteId=route_id, RouteResponseId=route_response_id ApiId=api_id, RouteId=route_id, RouteResponseId=route_response_id
) )
resp.should.have.key("RouteResponseId") assert "RouteResponseId" in resp
resp.should.have.key("RouteResponseKey").equals("$default") assert resp["RouteResponseKey"] == "$default"
@mock_apigatewayv2 @mock_apigatewayv2
@ -277,7 +275,7 @@ def test_get_route_response_unknown():
) )
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("NotFoundException") assert err["Code"] == "NotFoundException"
@mock_apigatewayv2 @mock_apigatewayv2
@ -295,4 +293,4 @@ def test_delete_route_response_unknown():
client.get_route_response(ApiId=api_id, RouteId=r_id, RouteResponseId=rr_id) client.get_route_response(ApiId=api_id, RouteId=r_id, RouteResponseId=rr_id)
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("NotFoundException") assert err["Code"] == "NotFoundException"

View File

@ -10,7 +10,7 @@ def test_create_api_with_tags():
Name="test-api", ProtocolType="HTTP", Tags={"key1": "value1", "key2": "value2"} Name="test-api", ProtocolType="HTTP", Tags={"key1": "value1", "key2": "value2"}
) )
resp.should.have.key("Tags").equals({"key1": "value1", "key2": "value2"}) assert resp["Tags"] == {"key1": "value1", "key2": "value2"}
@mock_apigatewayv2 @mock_apigatewayv2
@ -25,7 +25,7 @@ def test_tag_resource():
resp = client.get_api(ApiId=api_id) resp = client.get_api(ApiId=api_id)
resp.should.have.key("Tags").equals({"key1": "value1", "key2": "value2"}) assert resp["Tags"] == {"key1": "value1", "key2": "value2"}
@mock_apigatewayv2 @mock_apigatewayv2
@ -40,7 +40,7 @@ def test_get_tags():
resp = client.get_tags(ResourceArn=resource_arn) resp = client.get_tags(ResourceArn=resource_arn)
resp.should.have.key("Tags").equals({"key1": "value1", "key2": "value2"}) assert resp["Tags"] == {"key1": "value1", "key2": "value2"}
@mock_apigatewayv2 @mock_apigatewayv2
@ -59,4 +59,4 @@ def test_untag_resource():
resp = client.get_tags(ResourceArn=resource_arn) resp = client.get_tags(ResourceArn=resource_arn)
resp.should.have.key("Tags").equals({"key1": "value1", "key3": "value3"}) assert resp["Tags"] == {"key1": "value1", "key3": "value3"}

View File

@ -10,7 +10,7 @@ def test_get_vpc_links_empty():
client = boto3.client("apigatewayv2", region_name="eu-west-1") client = boto3.client("apigatewayv2", region_name="eu-west-1")
resp = client.get_vpc_links() resp = client.get_vpc_links()
resp.should.have.key("Items").equals([]) assert resp["Items"] == []
@mock_apigatewayv2 @mock_apigatewayv2
@ -24,14 +24,14 @@ def test_create_vpc_links():
Tags={"key1": "value1"}, Tags={"key1": "value1"},
) )
resp.should.have.key("CreatedDate") assert "CreatedDate" in resp
resp.should.have.key("Name").equals("vpcl") assert resp["Name"] == "vpcl"
resp.should.have.key("SecurityGroupIds").equals(["sg1", "sg2"]) assert resp["SecurityGroupIds"] == ["sg1", "sg2"]
resp.should.have.key("SubnetIds").equals(["sid1", "sid2"]) assert resp["SubnetIds"] == ["sid1", "sid2"]
resp.should.have.key("Tags").equals({"key1": "value1"}) assert resp["Tags"] == {"key1": "value1"}
resp.should.have.key("VpcLinkId") assert "VpcLinkId" in resp
resp.should.have.key("VpcLinkStatus").equals("AVAILABLE") assert resp["VpcLinkStatus"] == "AVAILABLE"
resp.should.have.key("VpcLinkVersion").equals("V2") assert resp["VpcLinkVersion"] == "V2"
@mock_apigatewayv2 @mock_apigatewayv2
@ -47,14 +47,14 @@ def test_get_vpc_link():
resp = client.get_vpc_link(VpcLinkId=vpc_link_id) resp = client.get_vpc_link(VpcLinkId=vpc_link_id)
resp.should.have.key("CreatedDate") assert "CreatedDate" in resp
resp.should.have.key("Name").equals("vpcl") assert resp["Name"] == "vpcl"
resp.should.have.key("SecurityGroupIds").equals(["sg1", "sg2"]) assert resp["SecurityGroupIds"] == ["sg1", "sg2"]
resp.should.have.key("SubnetIds").equals(["sid1", "sid2"]) assert resp["SubnetIds"] == ["sid1", "sid2"]
resp.should.have.key("Tags").equals({"key1": "value1"}) assert resp["Tags"] == {"key1": "value1"}
resp.should.have.key("VpcLinkId") assert "VpcLinkId" in resp
resp.should.have.key("VpcLinkStatus").equals("AVAILABLE") assert resp["VpcLinkStatus"] == "AVAILABLE"
resp.should.have.key("VpcLinkVersion").equals("V2") assert resp["VpcLinkVersion"] == "V2"
@mock_apigatewayv2 @mock_apigatewayv2
@ -64,8 +64,8 @@ def test_get_vpc_link_unknown():
with pytest.raises(ClientError) as exc: with pytest.raises(ClientError) as exc:
client.get_vpc_link(VpcLinkId="unknown") client.get_vpc_link(VpcLinkId="unknown")
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("NotFoundException") assert err["Code"] == "NotFoundException"
err["Message"].should.equal("Invalid VpcLink identifier specified unknown") assert err["Message"] == "Invalid VpcLink identifier specified unknown"
@mock_apigatewayv2 @mock_apigatewayv2
@ -80,8 +80,8 @@ def test_get_vpc_links():
)["VpcLinkId"] )["VpcLinkId"]
links = client.get_vpc_links()["Items"] links = client.get_vpc_links()["Items"]
links.should.have.length_of(1) assert len(links) == 1
links[0]["VpcLinkId"].should.equal(vpc_link_id) assert links[0]["VpcLinkId"] == vpc_link_id
client.create_vpc_link( client.create_vpc_link(
Name="vpcl", Name="vpcl",
@ -91,7 +91,7 @@ def test_get_vpc_links():
) )
links = client.get_vpc_links()["Items"] links = client.get_vpc_links()["Items"]
links.should.have.length_of(2) assert len(links) == 2
@mock_apigatewayv2 @mock_apigatewayv2
@ -106,12 +106,12 @@ def test_delete_vpc_link():
)["VpcLinkId"] )["VpcLinkId"]
links = client.get_vpc_links()["Items"] links = client.get_vpc_links()["Items"]
links.should.have.length_of(1) assert len(links) == 1
client.delete_vpc_link(VpcLinkId=vpc_link_id) client.delete_vpc_link(VpcLinkId=vpc_link_id)
links = client.get_vpc_links()["Items"] links = client.get_vpc_links()["Items"]
links.should.have.length_of(0) assert len(links) == 0
@mock_apigatewayv2 @mock_apigatewayv2
@ -126,14 +126,14 @@ def test_update_vpc_link():
resp = client.update_vpc_link(VpcLinkId=vpc_link_id, Name="vpcl2") resp = client.update_vpc_link(VpcLinkId=vpc_link_id, Name="vpcl2")
resp.should.have.key("CreatedDate") assert "CreatedDate" in resp
resp.should.have.key("Name").equals("vpcl2") assert resp["Name"] == "vpcl2"
resp.should.have.key("SecurityGroupIds").equals(["sg1", "sg2"]) assert resp["SecurityGroupIds"] == ["sg1", "sg2"]
resp.should.have.key("SubnetIds").equals(["sid1", "sid2"]) assert resp["SubnetIds"] == ["sid1", "sid2"]
resp.should.have.key("Tags").equals({"key1": "value1"}) assert resp["Tags"] == {"key1": "value1"}
resp.should.have.key("VpcLinkId") assert "VpcLinkId" in resp
resp.should.have.key("VpcLinkStatus").equals("AVAILABLE") assert resp["VpcLinkStatus"] == "AVAILABLE"
resp.should.have.key("VpcLinkVersion").equals("V2") assert resp["VpcLinkVersion"] == "V2"
@mock_apigatewayv2 @mock_apigatewayv2
@ -152,11 +152,11 @@ def test_untag_vpc_link():
resp = client.get_vpc_link(VpcLinkId=vpc_link_id) resp = client.get_vpc_link(VpcLinkId=vpc_link_id)
resp.should.have.key("CreatedDate") assert "CreatedDate" in resp
resp.should.have.key("Name").equals("vpcl") assert resp["Name"] == "vpcl"
resp.should.have.key("SecurityGroupIds").equals(["sg1", "sg2"]) assert resp["SecurityGroupIds"] == ["sg1", "sg2"]
resp.should.have.key("SubnetIds").equals(["sid1", "sid2"]) assert resp["SubnetIds"] == ["sid1", "sid2"]
resp.should.have.key("Tags").equals({"key2": "val2"}) assert resp["Tags"] == {"key2": "val2"}
resp.should.have.key("VpcLinkId") assert "VpcLinkId" in resp
resp.should.have.key("VpcLinkStatus").equals("AVAILABLE") assert resp["VpcLinkStatus"] == "AVAILABLE"
resp.should.have.key("VpcLinkVersion").equals("V2") assert resp["VpcLinkVersion"] == "V2"

View File

@ -1,5 +1,4 @@
import json import json
import sure # noqa # pylint: disable=unused-import
import moto.server as server import moto.server as server
@ -9,5 +8,5 @@ def test_apigatewayv2_list_apis():
test_client = backend.test_client() test_client = backend.test_client()
resp = test_client.get("/v2/apis") resp = test_client.get("/v2/apis")
resp.status_code.should.equal(200) assert resp.status_code == 200
json.loads(resp.data).should.equal({"items": []}) assert json.loads(resp.data) == {"items": []}