Finish porting from nose to pytest.
This commit is contained in:
parent
77dc60ea97
commit
ea489bce6c
72 changed files with 1289 additions and 1280 deletions
|
|
@ -96,7 +96,7 @@ def test_create_rest_api_invalid_apikeysource():
|
|||
description="this is my api",
|
||||
apiKeySource="not a valid api key source",
|
||||
)
|
||||
ex.exception.response["Error"]["Code"].should.equal("ValidationException")
|
||||
ex.value.response["Error"]["Code"].should.equal("ValidationException")
|
||||
|
||||
|
||||
@mock_apigateway
|
||||
|
|
@ -132,7 +132,7 @@ def test_create_rest_api_invalid_endpointconfiguration():
|
|||
description="this is my api",
|
||||
endpointConfiguration={"types": ["INVALID"]},
|
||||
)
|
||||
ex.exception.response["Error"]["Code"].should.equal("ValidationException")
|
||||
ex.value.response["Error"]["Code"].should.equal("ValidationException")
|
||||
|
||||
|
||||
@mock_apigateway
|
||||
|
|
@ -196,8 +196,8 @@ def test_create_resource__validate_name():
|
|||
for name in invalid_names:
|
||||
with pytest.raises(ClientError) as ex:
|
||||
client.create_resource(restApiId=api_id, parentId=root_id, pathPart=name)
|
||||
ex.exception.response["Error"]["Code"].should.equal("BadRequestException")
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["Error"]["Code"].should.equal("BadRequestException")
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"Resource's path part only allow a-zA-Z0-9._- and curly braces at the beginning and the end and an optional plus sign before the closing brace."
|
||||
)
|
||||
# All valid names should go through
|
||||
|
|
@ -1196,8 +1196,8 @@ def test_create_deployment_requires_REST_methods():
|
|||
|
||||
with pytest.raises(ClientError) as ex:
|
||||
client.create_deployment(restApiId=api_id, stageName=stage_name)["id"]
|
||||
ex.exception.response["Error"]["Code"].should.equal("BadRequestException")
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["Error"]["Code"].should.equal("BadRequestException")
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"The REST API doesn't contain any methods"
|
||||
)
|
||||
|
||||
|
|
@ -1219,8 +1219,8 @@ def test_create_deployment_requires_REST_method_integrations():
|
|||
|
||||
with pytest.raises(ClientError) as ex:
|
||||
client.create_deployment(restApiId=api_id, stageName=stage_name)["id"]
|
||||
ex.exception.response["Error"]["Code"].should.equal("BadRequestException")
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["Error"]["Code"].should.equal("BadRequestException")
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"No integration defined for method"
|
||||
)
|
||||
|
||||
|
|
@ -1277,8 +1277,8 @@ def test_put_integration_response_requires_responseTemplate():
|
|||
client.put_integration_response(
|
||||
restApiId=api_id, resourceId=root_id, httpMethod="GET", statusCode="200"
|
||||
)
|
||||
ex.exception.response["Error"]["Code"].should.equal("BadRequestException")
|
||||
ex.exception.response["Error"]["Message"].should.equal("Invalid request input")
|
||||
ex.value.response["Error"]["Code"].should.equal("BadRequestException")
|
||||
ex.value.response["Error"]["Message"].should.equal("Invalid request input")
|
||||
# Works fine if responseTemplate is defined
|
||||
client.put_integration_response(
|
||||
restApiId=api_id,
|
||||
|
|
@ -1319,8 +1319,8 @@ def test_put_integration_response_with_response_template():
|
|||
restApiId=api_id, resourceId=root_id, httpMethod="GET", statusCode="200"
|
||||
)
|
||||
|
||||
ex.exception.response["Error"]["Code"].should.equal("BadRequestException")
|
||||
ex.exception.response["Error"]["Message"].should.equal("Invalid request input")
|
||||
ex.value.response["Error"]["Code"].should.equal("BadRequestException")
|
||||
ex.value.response["Error"]["Message"].should.equal("Invalid request input")
|
||||
|
||||
client.put_integration_response(
|
||||
restApiId=api_id,
|
||||
|
|
@ -1380,8 +1380,8 @@ def test_put_integration_validation():
|
|||
type=type,
|
||||
uri="http://httpbin.org/robots.txt",
|
||||
)
|
||||
ex.exception.response["Error"]["Code"].should.equal("BadRequestException")
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["Error"]["Code"].should.equal("BadRequestException")
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"Enumeration value for HttpMethod must be non-empty"
|
||||
)
|
||||
for type in types_not_requiring_integration_method:
|
||||
|
|
@ -1440,8 +1440,8 @@ def test_put_integration_validation():
|
|||
uri="arn:aws:apigateway:us-west-2:s3:path/b/k",
|
||||
integrationHttpMethod="POST",
|
||||
)
|
||||
ex.exception.response["Error"]["Code"].should.equal("BadRequestException")
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["Error"]["Code"].should.equal("BadRequestException")
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"Integrations of type 'AWS_PROXY' currently only supports Lambda function and Firehose stream invocations."
|
||||
)
|
||||
for type in aws_types:
|
||||
|
|
@ -1456,8 +1456,8 @@ def test_put_integration_validation():
|
|||
uri="arn:aws:apigateway:us-west-2:s3:path/b/k",
|
||||
integrationHttpMethod="POST",
|
||||
)
|
||||
ex.exception.response["Error"]["Code"].should.equal("AccessDeniedException")
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["Error"]["Code"].should.equal("AccessDeniedException")
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"Cross-account pass role is not allowed."
|
||||
)
|
||||
for type in ["AWS"]:
|
||||
|
|
@ -1471,8 +1471,8 @@ def test_put_integration_validation():
|
|||
uri="arn:aws:apigateway:us-west-2:s3:path/b/k",
|
||||
integrationHttpMethod="POST",
|
||||
)
|
||||
ex.exception.response["Error"]["Code"].should.equal("BadRequestException")
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["Error"]["Code"].should.equal("BadRequestException")
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"Role ARN must be specified for AWS integrations"
|
||||
)
|
||||
for type in http_types:
|
||||
|
|
@ -1486,8 +1486,8 @@ def test_put_integration_validation():
|
|||
uri="non-valid-http",
|
||||
integrationHttpMethod="POST",
|
||||
)
|
||||
ex.exception.response["Error"]["Code"].should.equal("BadRequestException")
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["Error"]["Code"].should.equal("BadRequestException")
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"Invalid HTTP endpoint specified for URI"
|
||||
)
|
||||
for type in aws_types:
|
||||
|
|
@ -1501,8 +1501,8 @@ def test_put_integration_validation():
|
|||
uri="non-valid-arn",
|
||||
integrationHttpMethod="POST",
|
||||
)
|
||||
ex.exception.response["Error"]["Code"].should.equal("BadRequestException")
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["Error"]["Code"].should.equal("BadRequestException")
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"Invalid ARN specified in the request"
|
||||
)
|
||||
for type in aws_types:
|
||||
|
|
@ -1516,8 +1516,8 @@ def test_put_integration_validation():
|
|||
uri="arn:aws:iam::0000000000:role/service-role/asdf",
|
||||
integrationHttpMethod="POST",
|
||||
)
|
||||
ex.exception.response["Error"]["Code"].should.equal("BadRequestException")
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["Error"]["Code"].should.equal("BadRequestException")
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"AWS ARN for integration must contain path or action"
|
||||
)
|
||||
|
||||
|
|
@ -1635,8 +1635,8 @@ def test_create_domain_names():
|
|||
with pytest.raises(ClientError) as ex:
|
||||
client.create_domain_name(domainName="")
|
||||
|
||||
ex.exception.response["Error"]["Message"].should.equal("No Domain Name specified")
|
||||
ex.exception.response["Error"]["Code"].should.equal("BadRequestException")
|
||||
ex.value.response["Error"]["Message"].should.equal("No Domain Name specified")
|
||||
ex.value.response["Error"]["Code"].should.equal("BadRequestException")
|
||||
|
||||
|
||||
@mock_apigateway
|
||||
|
|
@ -1669,10 +1669,10 @@ def test_get_domain_name():
|
|||
with pytest.raises(ClientError) as ex:
|
||||
client.get_domain_name(domainName=domain_name)
|
||||
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"Invalid Domain Name specified"
|
||||
)
|
||||
ex.exception.response["Error"]["Code"].should.equal("NotFoundException")
|
||||
ex.value.response["Error"]["Code"].should.equal("NotFoundException")
|
||||
# adding a domain name
|
||||
client.create_domain_name(domainName=domain_name)
|
||||
# retrieving the data of added domain name.
|
||||
|
|
@ -1708,10 +1708,10 @@ def test_create_model():
|
|||
description=description,
|
||||
contentType=content_type,
|
||||
)
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"Invalid Rest API Id specified"
|
||||
)
|
||||
ex.exception.response["Error"]["Code"].should.equal("NotFoundException")
|
||||
ex.value.response["Error"]["Code"].should.equal("NotFoundException")
|
||||
|
||||
with pytest.raises(ClientError) as ex:
|
||||
client.create_model(
|
||||
|
|
@ -1721,8 +1721,8 @@ def test_create_model():
|
|||
contentType=content_type,
|
||||
)
|
||||
|
||||
ex.exception.response["Error"]["Message"].should.equal("No Model Name specified")
|
||||
ex.exception.response["Error"]["Code"].should.equal("BadRequestException")
|
||||
ex.value.response["Error"]["Message"].should.equal("No Model Name specified")
|
||||
ex.value.response["Error"]["Code"].should.equal("BadRequestException")
|
||||
|
||||
|
||||
@mock_apigateway
|
||||
|
|
@ -1772,10 +1772,10 @@ def test_get_model_by_name():
|
|||
|
||||
with pytest.raises(ClientError) as ex:
|
||||
client.get_model(restApiId=dummy_rest_api_id, modelName=model_name)
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"Invalid Rest API Id specified"
|
||||
)
|
||||
ex.exception.response["Error"]["Code"].should.equal("NotFoundException")
|
||||
ex.value.response["Error"]["Code"].should.equal("NotFoundException")
|
||||
|
||||
|
||||
@mock_apigateway
|
||||
|
|
@ -1786,10 +1786,10 @@ def test_get_model_with_invalid_name():
|
|||
# test with an invalid model name
|
||||
with pytest.raises(ClientError) as ex:
|
||||
client.get_model(restApiId=rest_api_id, modelName="fake")
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"Invalid Model Name specified"
|
||||
)
|
||||
ex.exception.response["Error"]["Code"].should.equal("NotFoundException")
|
||||
ex.value.response["Error"]["Code"].should.equal("NotFoundException")
|
||||
|
||||
|
||||
@mock_apigateway
|
||||
|
|
@ -1870,9 +1870,9 @@ def test_create_api_headers():
|
|||
client.create_api_key(**payload)
|
||||
with pytest.raises(ClientError) as ex:
|
||||
client.create_api_key(**payload)
|
||||
ex.exception.response["Error"]["Code"].should.equal("ConflictException")
|
||||
ex.value.response["Error"]["Code"].should.equal("ConflictException")
|
||||
if not settings.TEST_SERVER_MODE:
|
||||
ex.exception.response["ResponseMetadata"]["HTTPHeaders"].should.equal({})
|
||||
ex.value.response["ResponseMetadata"]["HTTPHeaders"].should.equal({})
|
||||
|
||||
|
||||
@mock_apigateway
|
||||
|
|
@ -1941,8 +1941,8 @@ def test_usage_plans():
|
|||
# # Try to get info about a non existing usage
|
||||
with pytest.raises(ClientError) as ex:
|
||||
client.get_usage_plan(usagePlanId="not_existing")
|
||||
ex.exception.response["Error"]["Code"].should.equal("NotFoundException")
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["Error"]["Code"].should.equal("NotFoundException")
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"Invalid Usage Plan ID specified"
|
||||
)
|
||||
|
||||
|
|
@ -2032,24 +2032,24 @@ def test_usage_plan_keys():
|
|||
# Try to get info about a non existing api key
|
||||
with pytest.raises(ClientError) as ex:
|
||||
client.get_usage_plan_key(usagePlanId=usage_plan_id, keyId="not_existing_key")
|
||||
ex.exception.response["Error"]["Code"].should.equal("NotFoundException")
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["Error"]["Code"].should.equal("NotFoundException")
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"Invalid API Key identifier specified"
|
||||
)
|
||||
|
||||
# Try to get info about an existing api key that has not jet added to a valid usage plan
|
||||
with pytest.raises(ClientError) as ex:
|
||||
client.get_usage_plan_key(usagePlanId=usage_plan_id, keyId=key_id)
|
||||
ex.exception.response["Error"]["Code"].should.equal("NotFoundException")
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["Error"]["Code"].should.equal("NotFoundException")
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"Invalid Usage Plan ID specified"
|
||||
)
|
||||
|
||||
# Try to get info about an existing api key that has not jet added to a valid usage plan
|
||||
with pytest.raises(ClientError) as ex:
|
||||
client.get_usage_plan_key(usagePlanId="not_existing_plan_id", keyId=key_id)
|
||||
ex.exception.response["Error"]["Code"].should.equal("NotFoundException")
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["Error"]["Code"].should.equal("NotFoundException")
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"Invalid Usage Plan ID specified"
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue