Back to Black
This commit is contained in:
parent
ea489bce6c
commit
5697ff87a8
112 changed files with 1803 additions and 977 deletions
|
|
@ -22,8 +22,10 @@ SERVER_CRT = _GET_RESOURCE("star_moto_com.pem")
|
|||
SERVER_COMMON_NAME = "*.moto.com"
|
||||
SERVER_CRT_BAD = _GET_RESOURCE("star_moto_com-bad.pem")
|
||||
SERVER_KEY = _GET_RESOURCE("star_moto_com.key")
|
||||
BAD_ARN = "arn:aws:acm:us-east-2:{}:certificate/_0000000-0000-0000-0000-000000000000".format(
|
||||
ACCOUNT_ID
|
||||
BAD_ARN = (
|
||||
"arn:aws:acm:us-east-2:{}:certificate/_0000000-0000-0000-0000-000000000000".format(
|
||||
ACCOUNT_ID
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -56,7 +58,10 @@ def test_import_certificate_with_tags():
|
|||
Certificate=SERVER_CRT,
|
||||
PrivateKey=SERVER_KEY,
|
||||
CertificateChain=CA_CRT,
|
||||
Tags=[{"Key": "Environment", "Value": "QA"}, {"Key": "KeyOnly"},],
|
||||
Tags=[
|
||||
{"Key": "Environment", "Value": "QA"},
|
||||
{"Key": "KeyOnly"},
|
||||
],
|
||||
)
|
||||
arn = resp["CertificateArn"]
|
||||
|
||||
|
|
@ -368,7 +373,10 @@ def test_request_certificate_with_tags():
|
|||
DomainName="google.com",
|
||||
IdempotencyToken=token,
|
||||
SubjectAlternativeNames=["google.com", "www.google.com", "mail.google.com"],
|
||||
Tags=[{"Key": "Environment", "Value": "Prod"}, {"Key": "KeyOnly"},],
|
||||
Tags=[
|
||||
{"Key": "Environment", "Value": "Prod"},
|
||||
{"Key": "KeyOnly"},
|
||||
],
|
||||
)
|
||||
arn_2 = resp["CertificateArn"]
|
||||
|
||||
|
|
@ -398,7 +406,8 @@ def test_operations_with_invalid_tags():
|
|||
# request certificate with invalid tags
|
||||
with assert_raises(ClientError) as ex:
|
||||
client.request_certificate(
|
||||
DomainName="example.com", Tags=[{"Key": "X" * 200, "Value": "Valid"}],
|
||||
DomainName="example.com",
|
||||
Tags=[{"Key": "X" * 200, "Value": "Valid"}],
|
||||
)
|
||||
ex.exception.response["Error"]["Code"].should.equal("ValidationException")
|
||||
ex.exception.response["Error"]["Message"].should.contain(
|
||||
|
|
|
|||
|
|
@ -105,7 +105,9 @@ def test_create_rest_api_valid_apikeysources():
|
|||
|
||||
# 1. test creating rest api with HEADER apiKeySource
|
||||
response = client.create_rest_api(
|
||||
name="my_api", description="this is my api", apiKeySource="HEADER",
|
||||
name="my_api",
|
||||
description="this is my api",
|
||||
apiKeySource="HEADER",
|
||||
)
|
||||
api_id = response["id"]
|
||||
|
||||
|
|
@ -114,7 +116,9 @@ def test_create_rest_api_valid_apikeysources():
|
|||
|
||||
# 2. test creating rest api with AUTHORIZER apiKeySource
|
||||
response = client.create_rest_api(
|
||||
name="my_api2", description="this is my api", apiKeySource="AUTHORIZER",
|
||||
name="my_api2",
|
||||
description="this is my api",
|
||||
apiKeySource="AUTHORIZER",
|
||||
)
|
||||
api_id = response["id"]
|
||||
|
||||
|
|
@ -149,7 +153,9 @@ def test_create_rest_api_valid_endpointconfigurations():
|
|||
|
||||
response = client.get_rest_api(restApiId=api_id)
|
||||
response["endpointConfiguration"].should.equal(
|
||||
{"types": ["PRIVATE"],}
|
||||
{
|
||||
"types": ["PRIVATE"],
|
||||
}
|
||||
)
|
||||
|
||||
# 2. test creating rest api with REGIONAL endpointConfiguration
|
||||
|
|
@ -162,7 +168,9 @@ def test_create_rest_api_valid_endpointconfigurations():
|
|||
|
||||
response = client.get_rest_api(restApiId=api_id)
|
||||
response["endpointConfiguration"].should.equal(
|
||||
{"types": ["REGIONAL"],}
|
||||
{
|
||||
"types": ["REGIONAL"],
|
||||
}
|
||||
)
|
||||
|
||||
# 3. test creating rest api with EDGE endpointConfiguration
|
||||
|
|
@ -175,7 +183,9 @@ def test_create_rest_api_valid_endpointconfigurations():
|
|||
|
||||
response = client.get_rest_api(restApiId=api_id)
|
||||
response["endpointConfiguration"].should.equal(
|
||||
{"types": ["EDGE"],}
|
||||
{
|
||||
"types": ["EDGE"],
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -221,7 +231,11 @@ def test_create_resource():
|
|||
root_resource["ResponseMetadata"].pop("HTTPHeaders", None)
|
||||
root_resource["ResponseMetadata"].pop("RetryAttempts", None)
|
||||
root_resource.should.equal(
|
||||
{"path": "/", "id": root_id, "ResponseMetadata": {"HTTPStatusCode": 200},}
|
||||
{
|
||||
"path": "/",
|
||||
"id": root_id,
|
||||
"ResponseMetadata": {"HTTPStatusCode": 200},
|
||||
}
|
||||
)
|
||||
|
||||
client.create_resource(restApiId=api_id, parentId=root_id, pathPart="users")
|
||||
|
|
@ -1669,9 +1683,7 @@ def test_get_domain_name():
|
|||
with pytest.raises(ClientError) as ex:
|
||||
client.get_domain_name(domainName=domain_name)
|
||||
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"Invalid Domain Name specified"
|
||||
)
|
||||
ex.value.response["Error"]["Message"].should.equal("Invalid Domain Name specified")
|
||||
ex.value.response["Error"]["Code"].should.equal("NotFoundException")
|
||||
# adding a domain name
|
||||
client.create_domain_name(domainName=domain_name)
|
||||
|
|
@ -1708,9 +1720,7 @@ def test_create_model():
|
|||
description=description,
|
||||
contentType=content_type,
|
||||
)
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"Invalid Rest API Id specified"
|
||||
)
|
||||
ex.value.response["Error"]["Message"].should.equal("Invalid Rest API Id specified")
|
||||
ex.value.response["Error"]["Code"].should.equal("NotFoundException")
|
||||
|
||||
with pytest.raises(ClientError) as ex:
|
||||
|
|
@ -1772,9 +1782,7 @@ def test_get_model_by_name():
|
|||
|
||||
with pytest.raises(ClientError) as ex:
|
||||
client.get_model(restApiId=dummy_rest_api_id, modelName=model_name)
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"Invalid Rest API Id specified"
|
||||
)
|
||||
ex.value.response["Error"]["Message"].should.equal("Invalid Rest API Id specified")
|
||||
ex.value.response["Error"]["Code"].should.equal("NotFoundException")
|
||||
|
||||
|
||||
|
|
@ -1786,9 +1794,7 @@ 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.value.response["Error"]["Message"].should.equal(
|
||||
"Invalid Model Name specified"
|
||||
)
|
||||
ex.value.response["Error"]["Message"].should.equal("Invalid Model Name specified")
|
||||
ex.value.response["Error"]["Code"].should.equal("NotFoundException")
|
||||
|
||||
|
||||
|
|
@ -1828,8 +1834,10 @@ def test_http_proxying_integration():
|
|||
stage_name = "staging"
|
||||
client.create_deployment(restApiId=api_id, stageName=stage_name)
|
||||
|
||||
deploy_url = "https://{api_id}.execute-api.{region_name}.amazonaws.com/{stage_name}".format(
|
||||
api_id=api_id, region_name=region_name, stage_name=stage_name
|
||||
deploy_url = (
|
||||
"https://{api_id}.execute-api.{region_name}.amazonaws.com/{stage_name}".format(
|
||||
api_id=api_id, region_name=region_name, stage_name=stage_name
|
||||
)
|
||||
)
|
||||
|
||||
if not settings.TEST_SERVER_MODE:
|
||||
|
|
|
|||
|
|
@ -49,7 +49,8 @@ def test_describe_scalable_targets_with_invalid_scalable_dimension_should_return
|
|||
|
||||
with pytest.raises(ClientError) as err:
|
||||
response = client.describe_scalable_targets(
|
||||
ServiceNamespace=DEFAULT_SERVICE_NAMESPACE, ScalableDimension="foo",
|
||||
ServiceNamespace=DEFAULT_SERVICE_NAMESPACE,
|
||||
ScalableDimension="foo",
|
||||
)
|
||||
err.response["Error"]["Code"].should.equal("ValidationException")
|
||||
err.response["Error"]["Message"].split(":")[0].should.look_like(
|
||||
|
|
@ -64,7 +65,8 @@ def test_describe_scalable_targets_with_invalid_service_namespace_should_return_
|
|||
|
||||
with pytest.raises(ClientError) as err:
|
||||
response = client.describe_scalable_targets(
|
||||
ServiceNamespace="foo", ScalableDimension=DEFAULT_SCALABLE_DIMENSION,
|
||||
ServiceNamespace="foo",
|
||||
ScalableDimension=DEFAULT_SCALABLE_DIMENSION,
|
||||
)
|
||||
err.response["Error"]["Code"].should.equal("ValidationException")
|
||||
err.response["Error"]["Message"].split(":")[0].should.look_like(
|
||||
|
|
@ -79,7 +81,8 @@ def test_describe_scalable_targets_with_multiple_invalid_parameters_should_retur
|
|||
|
||||
with pytest.raises(ClientError) as err:
|
||||
response = client.describe_scalable_targets(
|
||||
ServiceNamespace="foo", ScalableDimension="bar",
|
||||
ServiceNamespace="foo",
|
||||
ScalableDimension="bar",
|
||||
)
|
||||
err.response["Error"]["Code"].should.equal("ValidationException")
|
||||
err.response["Error"]["Message"].split(":")[0].should.look_like(
|
||||
|
|
|
|||
|
|
@ -178,7 +178,9 @@ def test_create_named_query():
|
|||
|
||||
# craete named query
|
||||
res = client.create_named_query(
|
||||
Name="query-name", Database="target_db", QueryString="SELECT * FROM table1",
|
||||
Name="query-name",
|
||||
Database="target_db",
|
||||
QueryString="SELECT * FROM table1",
|
||||
)
|
||||
|
||||
assert "NamedQueryId" in res
|
||||
|
|
@ -215,6 +217,8 @@ def create_basic_workgroup(client, name):
|
|||
Name=name,
|
||||
Description="Test work group",
|
||||
Configuration={
|
||||
"ResultConfiguration": {"OutputLocation": "s3://bucket-name/prefix/",}
|
||||
"ResultConfiguration": {
|
||||
"OutputLocation": "s3://bucket-name/prefix/",
|
||||
}
|
||||
},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -97,8 +97,8 @@ def test_create_autoscaling_group():
|
|||
|
||||
@mock_autoscaling_deprecated
|
||||
def test_create_autoscaling_groups_defaults():
|
||||
""" Test with the minimum inputs and check that all of the proper defaults
|
||||
are assigned for the other attributes """
|
||||
"""Test with the minimum inputs and check that all of the proper defaults
|
||||
are assigned for the other attributes"""
|
||||
|
||||
mocked_networking = setup_networking_deprecated()
|
||||
conn = boto.connect_autoscale()
|
||||
|
|
@ -961,7 +961,8 @@ def test_describe_autoscaling_groups_boto3_launch_config():
|
|||
mocked_networking = setup_networking()
|
||||
client = boto3.client("autoscaling", region_name="us-east-1")
|
||||
client.create_launch_configuration(
|
||||
LaunchConfigurationName="test_launch_configuration", InstanceType="t2.micro",
|
||||
LaunchConfigurationName="test_launch_configuration",
|
||||
InstanceType="t2.micro",
|
||||
)
|
||||
client.create_auto_scaling_group(
|
||||
AutoScalingGroupName="test_asg",
|
||||
|
|
@ -1040,7 +1041,8 @@ def test_describe_autoscaling_instances_boto3_launch_config():
|
|||
mocked_networking = setup_networking()
|
||||
client = boto3.client("autoscaling", region_name="us-east-1")
|
||||
client.create_launch_configuration(
|
||||
LaunchConfigurationName="test_launch_configuration", InstanceType="t2.micro",
|
||||
LaunchConfigurationName="test_launch_configuration",
|
||||
InstanceType="t2.micro",
|
||||
)
|
||||
client.create_auto_scaling_group(
|
||||
AutoScalingGroupName="test_asg",
|
||||
|
|
@ -2154,7 +2156,8 @@ def test_standby_exit_standby():
|
|||
response["AutoScalingInstances"][0]["LifecycleState"].should.equal("Standby")
|
||||
|
||||
response = client.exit_standby(
|
||||
AutoScalingGroupName="test_asg", InstanceIds=[instance_to_standby_exit_standby],
|
||||
AutoScalingGroupName="test_asg",
|
||||
InstanceIds=[instance_to_standby_exit_standby],
|
||||
)
|
||||
response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ Outputs:
|
|||
""".strip()
|
||||
|
||||
cf_client.create_stack(
|
||||
StackName=stack_name, TemplateBody=cf_template,
|
||||
StackName=stack_name,
|
||||
TemplateBody=cf_template,
|
||||
)
|
||||
stack = cf_client.describe_stacks(StackName=stack_name)["Stacks"][0]
|
||||
stack["Outputs"][0]["OutputValue"].should.be.equal("test_launch_configuration")
|
||||
|
|
@ -56,7 +57,8 @@ Outputs:
|
|||
""".strip()
|
||||
|
||||
cf_client.update_stack(
|
||||
StackName=stack_name, TemplateBody=cf_template,
|
||||
StackName=stack_name,
|
||||
TemplateBody=cf_template,
|
||||
)
|
||||
stack = cf_client.describe_stacks(StackName=stack_name)["Stacks"][0]
|
||||
stack["Outputs"][0]["OutputValue"].should.be.equal("test_launch_configuration")
|
||||
|
|
@ -76,7 +78,8 @@ def test_autoscaling_group_from_launch_config():
|
|||
client = boto3.client("autoscaling", region_name="us-east-1")
|
||||
|
||||
client.create_launch_configuration(
|
||||
LaunchConfigurationName="test_launch_configuration", InstanceType="t2.micro",
|
||||
LaunchConfigurationName="test_launch_configuration",
|
||||
InstanceType="t2.micro",
|
||||
)
|
||||
stack_name = "test-auto-scaling-group"
|
||||
|
||||
|
|
|
|||
|
|
@ -152,8 +152,8 @@ def test_create_launch_configuration_using_ip_association_should_default_to_fals
|
|||
|
||||
@mock_autoscaling_deprecated
|
||||
def test_create_launch_configuration_defaults():
|
||||
""" Test with the minimum inputs and check that all of the proper defaults
|
||||
are assigned for the other attributes """
|
||||
"""Test with the minimum inputs and check that all of the proper defaults
|
||||
are assigned for the other attributes"""
|
||||
conn = boto.connect_autoscale()
|
||||
config = LaunchConfiguration(
|
||||
name="tester", image_id="ami-abcd1234", instance_type="m1.small"
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ def test_execute_policy_percent_change_in_capacity():
|
|||
|
||||
@mock_autoscaling_deprecated
|
||||
def test_execute_policy_small_percent_change_in_capacity():
|
||||
""" http://docs.aws.amazon.com/AutoScaling/latest/DeveloperGuide/as-scale-based-on-demand.html
|
||||
"""http://docs.aws.amazon.com/AutoScaling/latest/DeveloperGuide/as-scale-based-on-demand.html
|
||||
If PercentChangeInCapacity returns a value between 0 and 1,
|
||||
Auto Scaling will round it off to 1."""
|
||||
setup_autoscale_group()
|
||||
|
|
|
|||
|
|
@ -204,7 +204,9 @@ def test_invoke_dryrun_function():
|
|||
Runtime="python2.7",
|
||||
Role=get_role_name(),
|
||||
Handler="lambda_function.lambda_handler",
|
||||
Code={"ZipFile": get_test_zip_file1(),},
|
||||
Code={
|
||||
"ZipFile": get_test_zip_file1(),
|
||||
},
|
||||
Description="test lambda function",
|
||||
Timeout=3,
|
||||
MemorySize=128,
|
||||
|
|
@ -1275,7 +1277,8 @@ def wait_for_log_msg(expected_msg, log_group):
|
|||
|
||||
for log_stream in log_streams:
|
||||
result = logs_conn.get_log_events(
|
||||
logGroupName=log_group, logStreamName=log_stream["logStreamName"],
|
||||
logGroupName=log_group,
|
||||
logStreamName=log_stream["logStreamName"],
|
||||
)
|
||||
received_messages.extend(
|
||||
[event["message"] for event in result.get("events")]
|
||||
|
|
@ -1713,7 +1716,9 @@ def test_remove_function_permission():
|
|||
)
|
||||
|
||||
remove = conn.remove_permission(
|
||||
FunctionName="testFunction", StatementId="1", Qualifier="2",
|
||||
FunctionName="testFunction",
|
||||
StatementId="1",
|
||||
Qualifier="2",
|
||||
)
|
||||
remove["ResponseMetadata"]["HTTPStatusCode"].should.equal(204)
|
||||
policy = conn.get_policy(FunctionName="testFunction", Qualifier="2")["Policy"]
|
||||
|
|
|
|||
|
|
@ -23,7 +23,9 @@ depends_on_template_list = {
|
|||
},
|
||||
"LaunchConfig": {
|
||||
"Type": "AWS::AutoScaling::LaunchConfiguration",
|
||||
"Properties": {"LaunchConfigurationName": "test-launch-config",},
|
||||
"Properties": {
|
||||
"LaunchConfigurationName": "test-launch-config",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -45,7 +47,9 @@ depends_on_template_string = {
|
|||
},
|
||||
"LaunchConfig": {
|
||||
"Type": "AWS::AutoScaling::LaunchConfiguration",
|
||||
"Properties": {"LaunchConfigurationName": "test-launch-config",},
|
||||
"Properties": {
|
||||
"LaunchConfigurationName": "test-launch-config",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1369,10 +1369,12 @@ def test_non_json_redrive_policy():
|
|||
def test_boto3_create_duplicate_stack():
|
||||
cf_conn = boto3.client("cloudformation", region_name="us-east-1")
|
||||
cf_conn.create_stack(
|
||||
StackName="test_stack", TemplateBody=dummy_template_json,
|
||||
StackName="test_stack",
|
||||
TemplateBody=dummy_template_json,
|
||||
)
|
||||
|
||||
with pytest.raises(ClientError):
|
||||
cf_conn.create_stack(
|
||||
StackName="test_stack", TemplateBody=dummy_template_json,
|
||||
StackName="test_stack",
|
||||
TemplateBody=dummy_template_json,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2325,7 +2325,10 @@ def test_stack_dynamodb_resources_integration():
|
|||
dynamodb_client = boto3.client("dynamodb", region_name="us-east-1")
|
||||
table_desc = dynamodb_client.describe_table(TableName="myTableName")["Table"]
|
||||
table_desc["StreamSpecification"].should.equal(
|
||||
{"StreamEnabled": True, "StreamViewType": "KEYS_ONLY",}
|
||||
{
|
||||
"StreamEnabled": True,
|
||||
"StreamViewType": "KEYS_ONLY",
|
||||
}
|
||||
)
|
||||
|
||||
dynamodb_conn = boto3.resource("dynamodb", region_name="us-east-1")
|
||||
|
|
@ -2779,7 +2782,9 @@ def test_stack_events_get_attribute_integration():
|
|||
@mock_dynamodb2
|
||||
def test_dynamodb_table_creation():
|
||||
CFN_TEMPLATE = {
|
||||
"Outputs": {"MyTableName": {"Value": {"Ref": "MyTable"}},},
|
||||
"Outputs": {
|
||||
"MyTableName": {"Value": {"Ref": "MyTable"}},
|
||||
},
|
||||
"Resources": {
|
||||
"MyTable": {
|
||||
"Type": "AWS::DynamoDB::Table",
|
||||
|
|
|
|||
|
|
@ -326,7 +326,9 @@ def test_update_pipeline():
|
|||
"S3Bucket": "different-bucket",
|
||||
"S3ObjectKey": "test-object",
|
||||
},
|
||||
"outputArtifacts": [{"name": "artifact"},],
|
||||
"outputArtifacts": [
|
||||
{"name": "artifact"},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
@ -435,7 +437,9 @@ def test_update_pipeline_errors():
|
|||
"S3Bucket": "test-bucket",
|
||||
"S3ObjectKey": "test-object",
|
||||
},
|
||||
"outputArtifacts": [{"name": "artifact"},],
|
||||
"outputArtifacts": [
|
||||
{"name": "artifact"},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
@ -696,7 +700,9 @@ def create_basic_codepipeline(client, name):
|
|||
"S3Bucket": "test-bucket",
|
||||
"S3ObjectKey": "test-object",
|
||||
},
|
||||
"outputArtifacts": [{"name": "artifact"},],
|
||||
"outputArtifacts": [
|
||||
{"name": "artifact"},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1272,15 +1272,20 @@ def user_authentication_flow(conn):
|
|||
)["UserPoolClient"]["ClientId"]
|
||||
|
||||
conn.sign_up(
|
||||
ClientId=client_id, Username=username, Password=password,
|
||||
ClientId=client_id,
|
||||
Username=username,
|
||||
Password=password,
|
||||
)
|
||||
|
||||
client_secret = conn.describe_user_pool_client(
|
||||
UserPoolId=user_pool_id, ClientId=client_id,
|
||||
UserPoolId=user_pool_id,
|
||||
ClientId=client_id,
|
||||
)["UserPoolClient"]["ClientSecret"]
|
||||
|
||||
conn.confirm_sign_up(
|
||||
ClientId=client_id, Username=username, ConfirmationCode="123456",
|
||||
ClientId=client_id,
|
||||
Username=username,
|
||||
ConfirmationCode="123456",
|
||||
)
|
||||
|
||||
# generating secret hash
|
||||
|
|
@ -1318,18 +1323,25 @@ def user_authentication_flow(conn):
|
|||
)
|
||||
|
||||
conn.verify_software_token(
|
||||
AccessToken=result["AuthenticationResult"]["AccessToken"], UserCode="123456",
|
||||
AccessToken=result["AuthenticationResult"]["AccessToken"],
|
||||
UserCode="123456",
|
||||
)
|
||||
|
||||
conn.set_user_mfa_preference(
|
||||
AccessToken=result["AuthenticationResult"]["AccessToken"],
|
||||
SoftwareTokenMfaSettings={"Enabled": True, "PreferredMfa": True,},
|
||||
SoftwareTokenMfaSettings={
|
||||
"Enabled": True,
|
||||
"PreferredMfa": True,
|
||||
},
|
||||
)
|
||||
|
||||
result = conn.initiate_auth(
|
||||
ClientId=client_id,
|
||||
AuthFlow="REFRESH_TOKEN",
|
||||
AuthParameters={"SECRET_HASH": secret_hash, "REFRESH_TOKEN": refresh_token,},
|
||||
AuthParameters={
|
||||
"SECRET_HASH": secret_hash,
|
||||
"REFRESH_TOKEN": refresh_token,
|
||||
},
|
||||
)
|
||||
|
||||
result["AuthenticationResult"]["IdToken"].should_not.be.none
|
||||
|
|
@ -1583,7 +1595,8 @@ def test_sign_up():
|
|||
conn = boto3.client("cognito-idp", "us-west-2")
|
||||
user_pool_id = conn.create_user_pool(PoolName=str(uuid.uuid4()))["UserPool"]["Id"]
|
||||
client_id = conn.create_user_pool_client(
|
||||
UserPoolId=user_pool_id, ClientName=str(uuid.uuid4()),
|
||||
UserPoolId=user_pool_id,
|
||||
ClientName=str(uuid.uuid4()),
|
||||
)["UserPoolClient"]["ClientId"]
|
||||
username = str(uuid.uuid4())
|
||||
password = str(uuid.uuid4())
|
||||
|
|
@ -1599,12 +1612,16 @@ def test_confirm_sign_up():
|
|||
password = str(uuid.uuid4())
|
||||
user_pool_id = conn.create_user_pool(PoolName=str(uuid.uuid4()))["UserPool"]["Id"]
|
||||
client_id = conn.create_user_pool_client(
|
||||
UserPoolId=user_pool_id, ClientName=str(uuid.uuid4()), GenerateSecret=True,
|
||||
UserPoolId=user_pool_id,
|
||||
ClientName=str(uuid.uuid4()),
|
||||
GenerateSecret=True,
|
||||
)["UserPoolClient"]["ClientId"]
|
||||
conn.sign_up(ClientId=client_id, Username=username, Password=password)
|
||||
|
||||
conn.confirm_sign_up(
|
||||
ClientId=client_id, Username=username, ConfirmationCode="123456",
|
||||
ClientId=client_id,
|
||||
Username=username,
|
||||
ConfirmationCode="123456",
|
||||
)
|
||||
|
||||
result = conn.admin_get_user(UserPoolId=user_pool_id, Username=username)
|
||||
|
|
@ -1618,14 +1635,19 @@ def test_initiate_auth_USER_SRP_AUTH():
|
|||
password = str(uuid.uuid4())
|
||||
user_pool_id = conn.create_user_pool(PoolName=str(uuid.uuid4()))["UserPool"]["Id"]
|
||||
client_id = conn.create_user_pool_client(
|
||||
UserPoolId=user_pool_id, ClientName=str(uuid.uuid4()), GenerateSecret=True,
|
||||
UserPoolId=user_pool_id,
|
||||
ClientName=str(uuid.uuid4()),
|
||||
GenerateSecret=True,
|
||||
)["UserPoolClient"]["ClientId"]
|
||||
conn.sign_up(ClientId=client_id, Username=username, Password=password)
|
||||
client_secret = conn.describe_user_pool_client(
|
||||
UserPoolId=user_pool_id, ClientId=client_id,
|
||||
UserPoolId=user_pool_id,
|
||||
ClientId=client_id,
|
||||
)["UserPoolClient"]["ClientSecret"]
|
||||
conn.confirm_sign_up(
|
||||
ClientId=client_id, Username=username, ConfirmationCode="123456",
|
||||
ClientId=client_id,
|
||||
Username=username,
|
||||
ConfirmationCode="123456",
|
||||
)
|
||||
|
||||
key = bytes(str(client_secret).encode("latin-1"))
|
||||
|
|
@ -1669,11 +1691,14 @@ def test_initiate_auth_for_unconfirmed_user():
|
|||
password = str(uuid.uuid4())
|
||||
user_pool_id = conn.create_user_pool(PoolName=str(uuid.uuid4()))["UserPool"]["Id"]
|
||||
client_id = conn.create_user_pool_client(
|
||||
UserPoolId=user_pool_id, ClientName=str(uuid.uuid4()), GenerateSecret=True,
|
||||
UserPoolId=user_pool_id,
|
||||
ClientName=str(uuid.uuid4()),
|
||||
GenerateSecret=True,
|
||||
)["UserPoolClient"]["ClientId"]
|
||||
conn.sign_up(ClientId=client_id, Username=username, Password=password)
|
||||
client_secret = conn.describe_user_pool_client(
|
||||
UserPoolId=user_pool_id, ClientId=client_id,
|
||||
UserPoolId=user_pool_id,
|
||||
ClientId=client_id,
|
||||
)["UserPoolClient"]["ClientSecret"]
|
||||
|
||||
key = bytes(str(client_secret).encode("latin-1"))
|
||||
|
|
@ -1705,14 +1730,19 @@ def test_initiate_auth_with_invalid_secret_hash():
|
|||
password = str(uuid.uuid4())
|
||||
user_pool_id = conn.create_user_pool(PoolName=str(uuid.uuid4()))["UserPool"]["Id"]
|
||||
client_id = conn.create_user_pool_client(
|
||||
UserPoolId=user_pool_id, ClientName=str(uuid.uuid4()), GenerateSecret=True,
|
||||
UserPoolId=user_pool_id,
|
||||
ClientName=str(uuid.uuid4()),
|
||||
GenerateSecret=True,
|
||||
)["UserPoolClient"]["ClientId"]
|
||||
conn.sign_up(ClientId=client_id, Username=username, Password=password)
|
||||
client_secret = conn.describe_user_pool_client(
|
||||
UserPoolId=user_pool_id, ClientId=client_id,
|
||||
UserPoolId=user_pool_id,
|
||||
ClientId=client_id,
|
||||
)["UserPoolClient"]["ClientSecret"]
|
||||
conn.confirm_sign_up(
|
||||
ClientId=client_id, Username=username, ConfirmationCode="123456",
|
||||
ClientId=client_id,
|
||||
Username=username,
|
||||
ConfirmationCode="123456",
|
||||
)
|
||||
|
||||
invalid_secret_hash = str(uuid.uuid4())
|
||||
|
|
|
|||
|
|
@ -76,9 +76,7 @@ def test_put_configuration_recorder():
|
|||
"recordingGroup": bg,
|
||||
}
|
||||
)
|
||||
assert (
|
||||
ce.value.response["Error"]["Code"] == "InvalidRecordingGroupException"
|
||||
)
|
||||
assert ce.value.response["Error"]["Code"] == "InvalidRecordingGroupException"
|
||||
assert (
|
||||
ce.value.response["Error"]["Message"]
|
||||
== "The recording group provided is not valid"
|
||||
|
|
@ -255,8 +253,7 @@ def test_put_configuration_aggregator():
|
|||
],
|
||||
)
|
||||
assert (
|
||||
"You must choose one of these options"
|
||||
in ce.value.response["Error"]["Message"]
|
||||
"You must choose one of these options" in ce.value.response["Error"]["Message"]
|
||||
)
|
||||
assert ce.value.response["Error"]["Code"] == "InvalidParameterValueException"
|
||||
|
||||
|
|
@ -270,8 +267,7 @@ def test_put_configuration_aggregator():
|
|||
},
|
||||
)
|
||||
assert (
|
||||
"You must choose one of these options"
|
||||
in ce.value.response["Error"]["Message"]
|
||||
"You must choose one of these options" in ce.value.response["Error"]["Message"]
|
||||
)
|
||||
assert ce.value.response["Error"]["Code"] == "InvalidParameterValueException"
|
||||
|
||||
|
|
@ -475,8 +471,7 @@ def test_describe_configuration_aggregators():
|
|||
in ce.value.response["Error"]["Message"]
|
||||
)
|
||||
assert (
|
||||
ce.value.response["Error"]["Code"]
|
||||
== "NoSuchConfigurationAggregatorException"
|
||||
ce.value.response["Error"]["Code"] == "NoSuchConfigurationAggregatorException"
|
||||
)
|
||||
|
||||
# Error describe with more than 1 item in the list:
|
||||
|
|
@ -489,8 +484,7 @@ def test_describe_configuration_aggregators():
|
|||
in ce.value.response["Error"]["Message"]
|
||||
)
|
||||
assert (
|
||||
ce.value.response["Error"]["Code"]
|
||||
== "NoSuchConfigurationAggregatorException"
|
||||
ce.value.response["Error"]["Code"] == "NoSuchConfigurationAggregatorException"
|
||||
)
|
||||
|
||||
# Get the normal list:
|
||||
|
|
@ -553,9 +547,7 @@ def test_describe_configuration_aggregators():
|
|||
# Test with an invalid filter:
|
||||
with pytest.raises(ClientError) as ce:
|
||||
client.describe_configuration_aggregators(NextToken="WRONG")
|
||||
assert (
|
||||
"The nextToken provided is invalid" == ce.value.response["Error"]["Message"]
|
||||
)
|
||||
assert "The nextToken provided is invalid" == ce.value.response["Error"]["Message"]
|
||||
assert ce.value.response["Error"]["Code"] == "InvalidNextTokenException"
|
||||
|
||||
|
||||
|
|
@ -710,9 +702,7 @@ def test_describe_aggregation_authorizations():
|
|||
# Test with an invalid filter:
|
||||
with pytest.raises(ClientError) as ce:
|
||||
client.describe_aggregation_authorizations(NextToken="WRONG")
|
||||
assert (
|
||||
"The nextToken provided is invalid" == ce.value.response["Error"]["Message"]
|
||||
)
|
||||
assert "The nextToken provided is invalid" == ce.value.response["Error"]["Message"]
|
||||
assert ce.value.response["Error"]["Code"] == "InvalidNextTokenException"
|
||||
|
||||
|
||||
|
|
@ -758,8 +748,7 @@ def test_delete_configuration_aggregator():
|
|||
in ce.value.response["Error"]["Message"]
|
||||
)
|
||||
assert (
|
||||
ce.value.response["Error"]["Code"]
|
||||
== "NoSuchConfigurationAggregatorException"
|
||||
ce.value.response["Error"]["Code"] == "NoSuchConfigurationAggregatorException"
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -798,9 +787,7 @@ def test_describe_configurations():
|
|||
# Specify an incorrect name:
|
||||
with pytest.raises(ClientError) as ce:
|
||||
client.describe_configuration_recorders(ConfigurationRecorderNames=["wrong"])
|
||||
assert (
|
||||
ce.value.response["Error"]["Code"] == "NoSuchConfigurationRecorderException"
|
||||
)
|
||||
assert ce.value.response["Error"]["Code"] == "NoSuchConfigurationRecorderException"
|
||||
assert "wrong" in ce.value.response["Error"]["Message"]
|
||||
|
||||
# And with both a good and wrong name:
|
||||
|
|
@ -808,9 +795,7 @@ def test_describe_configurations():
|
|||
client.describe_configuration_recorders(
|
||||
ConfigurationRecorderNames=["testrecorder", "wrong"]
|
||||
)
|
||||
assert (
|
||||
ce.value.response["Error"]["Code"] == "NoSuchConfigurationRecorderException"
|
||||
)
|
||||
assert ce.value.response["Error"]["Code"] == "NoSuchConfigurationRecorderException"
|
||||
assert "wrong" in ce.value.response["Error"]["Message"]
|
||||
|
||||
|
||||
|
|
@ -847,9 +832,7 @@ def test_delivery_channels():
|
|||
# Try without a name supplied:
|
||||
with pytest.raises(ClientError) as ce:
|
||||
client.put_delivery_channel(DeliveryChannel={})
|
||||
assert (
|
||||
ce.value.response["Error"]["Code"] == "InvalidDeliveryChannelNameException"
|
||||
)
|
||||
assert ce.value.response["Error"]["Code"] == "InvalidDeliveryChannelNameException"
|
||||
assert "is not valid, blank string." in ce.value.response["Error"]["Message"]
|
||||
|
||||
# Try with a really long name:
|
||||
|
|
@ -1034,9 +1017,7 @@ def test_start_configuration_recorder():
|
|||
# Without a config recorder:
|
||||
with pytest.raises(ClientError) as ce:
|
||||
client.start_configuration_recorder(ConfigurationRecorderName="testrecorder")
|
||||
assert (
|
||||
ce.value.response["Error"]["Code"] == "NoSuchConfigurationRecorderException"
|
||||
)
|
||||
assert ce.value.response["Error"]["Code"] == "NoSuchConfigurationRecorderException"
|
||||
|
||||
# Make the config recorder;
|
||||
client.put_configuration_recorder(
|
||||
|
|
@ -1054,9 +1035,7 @@ def test_start_configuration_recorder():
|
|||
# Without a delivery channel:
|
||||
with pytest.raises(ClientError) as ce:
|
||||
client.start_configuration_recorder(ConfigurationRecorderName="testrecorder")
|
||||
assert (
|
||||
ce.value.response["Error"]["Code"] == "NoAvailableDeliveryChannelException"
|
||||
)
|
||||
assert ce.value.response["Error"]["Code"] == "NoAvailableDeliveryChannelException"
|
||||
|
||||
# Make the delivery channel:
|
||||
client.put_delivery_channel(
|
||||
|
|
@ -1092,9 +1071,7 @@ def test_stop_configuration_recorder():
|
|||
# Without a config recorder:
|
||||
with pytest.raises(ClientError) as ce:
|
||||
client.stop_configuration_recorder(ConfigurationRecorderName="testrecorder")
|
||||
assert (
|
||||
ce.value.response["Error"]["Code"] == "NoSuchConfigurationRecorderException"
|
||||
)
|
||||
assert ce.value.response["Error"]["Code"] == "NoSuchConfigurationRecorderException"
|
||||
|
||||
# Make the config recorder;
|
||||
client.put_configuration_recorder(
|
||||
|
|
@ -1184,9 +1161,7 @@ def test_describe_configuration_recorder_status():
|
|||
client.describe_configuration_recorder_status(
|
||||
ConfigurationRecorderNames=["testrecorder", "wrong"]
|
||||
)
|
||||
assert (
|
||||
ce.value.response["Error"]["Code"] == "NoSuchConfigurationRecorderException"
|
||||
)
|
||||
assert ce.value.response["Error"]["Code"] == "NoSuchConfigurationRecorderException"
|
||||
assert "wrong" in ce.value.response["Error"]["Message"]
|
||||
|
||||
|
||||
|
|
@ -1213,9 +1188,7 @@ def test_delete_configuration_recorder():
|
|||
# Try again -- it should be deleted:
|
||||
with pytest.raises(ClientError) as ce:
|
||||
client.delete_configuration_recorder(ConfigurationRecorderName="testrecorder")
|
||||
assert (
|
||||
ce.value.response["Error"]["Code"] == "NoSuchConfigurationRecorderException"
|
||||
)
|
||||
assert ce.value.response["Error"]["Code"] == "NoSuchConfigurationRecorderException"
|
||||
|
||||
|
||||
@mock_config
|
||||
|
|
@ -1243,8 +1216,7 @@ def test_delete_delivery_channel():
|
|||
with pytest.raises(ClientError) as ce:
|
||||
client.delete_delivery_channel(DeliveryChannelName="testchannel")
|
||||
assert (
|
||||
ce.value.response["Error"]["Code"]
|
||||
== "LastDeliveryChannelDeleteFailedException"
|
||||
ce.value.response["Error"]["Code"] == "LastDeliveryChannelDeleteFailedException"
|
||||
)
|
||||
assert (
|
||||
"because there is a running configuration recorder."
|
||||
|
|
@ -1267,7 +1239,7 @@ def test_delete_delivery_channel():
|
|||
@mock_s3
|
||||
def test_list_discovered_resource():
|
||||
"""NOTE: We are only really testing the Config part. For each individual service, please add tests
|
||||
for that individual service's "list_config_service_resources" function.
|
||||
for that individual service's "list_config_service_resources" function.
|
||||
"""
|
||||
client = boto3.client("config", region_name="us-west-2")
|
||||
|
||||
|
|
@ -1373,7 +1345,7 @@ def test_list_discovered_resource():
|
|||
@mock_s3
|
||||
def test_list_aggregate_discovered_resource():
|
||||
"""NOTE: We are only really testing the Config part. For each individual service, please add tests
|
||||
for that individual service's "list_config_service_resources" function.
|
||||
for that individual service's "list_config_service_resources" function.
|
||||
"""
|
||||
client = boto3.client("config", region_name="us-west-2")
|
||||
|
||||
|
|
@ -1517,7 +1489,7 @@ def test_list_aggregate_discovered_resource():
|
|||
@mock_s3
|
||||
def test_get_resource_config_history():
|
||||
"""NOTE: We are only really testing the Config part. For each individual service, please add tests
|
||||
for that individual service's "get_config_resource" function.
|
||||
for that individual service's "get_config_resource" function.
|
||||
"""
|
||||
client = boto3.client("config", region_name="us-west-2")
|
||||
|
||||
|
|
@ -1576,7 +1548,7 @@ def test_get_resource_config_history():
|
|||
@mock_s3
|
||||
def test_batch_get_resource_config():
|
||||
"""NOTE: We are only really testing the Config part. For each individual service, please add tests
|
||||
for that individual service's "get_config_resource" function.
|
||||
for that individual service's "get_config_resource" function.
|
||||
"""
|
||||
client = boto3.client("config", region_name="us-west-2")
|
||||
|
||||
|
|
@ -1640,7 +1612,7 @@ def test_batch_get_resource_config():
|
|||
@mock_s3
|
||||
def test_batch_get_aggregate_resource_config():
|
||||
"""NOTE: We are only really testing the Config part. For each individual service, please add tests
|
||||
for that individual service's "get_config_resource" function.
|
||||
for that individual service's "get_config_resource" function.
|
||||
"""
|
||||
from moto.config.models import DEFAULT_ACCOUNT_ID
|
||||
|
||||
|
|
@ -1873,7 +1845,12 @@ def test_put_evaluations():
|
|||
response["ResponseMetadata"].pop("HTTPHeaders", None)
|
||||
response["ResponseMetadata"].pop("RetryAttempts", None)
|
||||
response.should.equal(
|
||||
{"FailedEvaluations": [], "ResponseMetadata": {"HTTPStatusCode": 200,},}
|
||||
{
|
||||
"FailedEvaluations": [],
|
||||
"ResponseMetadata": {
|
||||
"HTTPStatusCode": 200,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -325,7 +325,9 @@ def test_access_denied_for_run_instances():
|
|||
ex.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(403)
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"User: arn:aws:iam::{account_id}:user/{user_name} is not authorized to perform: {operation}".format(
|
||||
account_id=ACCOUNT_ID, user_name=user_name, operation="ec2:RunInstances",
|
||||
account_id=ACCOUNT_ID,
|
||||
user_name=user_name,
|
||||
operation="ec2:RunInstances",
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -1347,9 +1347,13 @@ def test_get_item_returns_consumed_capacity():
|
|||
def test_put_empty_item():
|
||||
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
|
||||
dynamodb.create_table(
|
||||
AttributeDefinitions=[{"AttributeName": "structure_id", "AttributeType": "S"},],
|
||||
AttributeDefinitions=[
|
||||
{"AttributeName": "structure_id", "AttributeType": "S"},
|
||||
],
|
||||
TableName="test",
|
||||
KeySchema=[{"AttributeName": "structure_id", "KeyType": "HASH"},],
|
||||
KeySchema=[
|
||||
{"AttributeName": "structure_id", "KeyType": "HASH"},
|
||||
],
|
||||
ProvisionedThroughput={"ReadCapacityUnits": 123, "WriteCapacityUnits": 123},
|
||||
)
|
||||
table = dynamodb.Table("test")
|
||||
|
|
@ -1366,9 +1370,13 @@ def test_put_empty_item():
|
|||
def test_put_item_nonexisting_hash_key():
|
||||
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
|
||||
dynamodb.create_table(
|
||||
AttributeDefinitions=[{"AttributeName": "structure_id", "AttributeType": "S"},],
|
||||
AttributeDefinitions=[
|
||||
{"AttributeName": "structure_id", "AttributeType": "S"},
|
||||
],
|
||||
TableName="test",
|
||||
KeySchema=[{"AttributeName": "structure_id", "KeyType": "HASH"},],
|
||||
KeySchema=[
|
||||
{"AttributeName": "structure_id", "KeyType": "HASH"},
|
||||
],
|
||||
ProvisionedThroughput={"ReadCapacityUnits": 123, "WriteCapacityUnits": 123},
|
||||
)
|
||||
table = dynamodb.Table("test")
|
||||
|
|
@ -2287,7 +2295,10 @@ def test_update_item_on_map():
|
|||
table.update_item(
|
||||
Key={"forum_name": "the-key", "subject": "123"},
|
||||
UpdateExpression="SET body.#nested.#data = :tb",
|
||||
ExpressionAttributeNames={"#nested": "nested", "#data": "data",},
|
||||
ExpressionAttributeNames={
|
||||
"#nested": "nested",
|
||||
"#data": "data",
|
||||
},
|
||||
ExpressionAttributeValues={":tb": "new_value"},
|
||||
)
|
||||
# Running this against AWS DDB gives an exception so make sure it also fails.:
|
||||
|
|
@ -3951,19 +3962,30 @@ def test_update_supports_nested_update_if_nested_value_not_exists():
|
|||
|
||||
table = dynamodb.Table(name)
|
||||
table.put_item(
|
||||
Item={"user_id": "1234", "friends": {"5678": {"name": "friend_5678"}},},
|
||||
Item={
|
||||
"user_id": "1234",
|
||||
"friends": {"5678": {"name": "friend_5678"}},
|
||||
},
|
||||
)
|
||||
table.update_item(
|
||||
Key={"user_id": "1234"},
|
||||
ExpressionAttributeNames={"#friends": "friends", "#friendid": "0000",},
|
||||
ExpressionAttributeValues={":friend": {"name": "friend_0000"},},
|
||||
ExpressionAttributeNames={
|
||||
"#friends": "friends",
|
||||
"#friendid": "0000",
|
||||
},
|
||||
ExpressionAttributeValues={
|
||||
":friend": {"name": "friend_0000"},
|
||||
},
|
||||
UpdateExpression="SET #friends.#friendid = :friend",
|
||||
ReturnValues="UPDATED_NEW",
|
||||
)
|
||||
item = table.get_item(Key={"user_id": "1234"})["Item"]
|
||||
assert item == {
|
||||
"user_id": "1234",
|
||||
"friends": {"5678": {"name": "friend_5678"}, "0000": {"name": "friend_0000"},},
|
||||
"friends": {
|
||||
"5678": {"name": "friend_5678"},
|
||||
"0000": {"name": "friend_0000"},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -4057,9 +4079,7 @@ def test_update_catches_invalid_list_append_operation():
|
|||
|
||||
# Verify correct error is returned
|
||||
str(ex.value).should.match("Parameter validation failed:")
|
||||
str(ex.value).should.match(
|
||||
"Invalid type for parameter ExpressionAttributeValues."
|
||||
)
|
||||
str(ex.value).should.match("Invalid type for parameter ExpressionAttributeValues.")
|
||||
|
||||
|
||||
def _create_user_table():
|
||||
|
|
@ -4188,11 +4208,17 @@ def test_invalid_transact_get_items():
|
|||
)
|
||||
table = dynamodb.Table("test1")
|
||||
table.put_item(
|
||||
Item={"id": "1", "val": "1",}
|
||||
Item={
|
||||
"id": "1",
|
||||
"val": "1",
|
||||
}
|
||||
)
|
||||
|
||||
table.put_item(
|
||||
Item={"id": "1", "val": "2",}
|
||||
Item={
|
||||
"id": "1",
|
||||
"val": "2",
|
||||
}
|
||||
)
|
||||
|
||||
client = boto3.client("dynamodb", region_name="us-east-1")
|
||||
|
|
@ -4214,16 +4240,28 @@ def test_invalid_transact_get_items():
|
|||
with pytest.raises(ClientError) as ex:
|
||||
client.transact_get_items(
|
||||
TransactItems=[
|
||||
{"Get": {"Key": {"id": {"S": "1"},}, "TableName": "test1"}},
|
||||
{"Get": {"Key": {"id": {"S": "1"},}, "TableName": "non_exists_table"}},
|
||||
{
|
||||
"Get": {
|
||||
"Key": {
|
||||
"id": {"S": "1"},
|
||||
},
|
||||
"TableName": "test1",
|
||||
}
|
||||
},
|
||||
{
|
||||
"Get": {
|
||||
"Key": {
|
||||
"id": {"S": "1"},
|
||||
},
|
||||
"TableName": "non_exists_table",
|
||||
}
|
||||
},
|
||||
]
|
||||
)
|
||||
|
||||
ex.value.response["Error"]["Code"].should.equal("ResourceNotFoundException")
|
||||
ex.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"Requested resource not found"
|
||||
)
|
||||
ex.value.response["Error"]["Message"].should.equal("Requested resource not found")
|
||||
|
||||
|
||||
@mock_dynamodb2
|
||||
|
|
@ -4243,11 +4281,17 @@ def test_valid_transact_get_items():
|
|||
)
|
||||
table1 = dynamodb.Table("test1")
|
||||
table1.put_item(
|
||||
Item={"id": "1", "sort_key": "1",}
|
||||
Item={
|
||||
"id": "1",
|
||||
"sort_key": "1",
|
||||
}
|
||||
)
|
||||
|
||||
table1.put_item(
|
||||
Item={"id": "1", "sort_key": "2",}
|
||||
Item={
|
||||
"id": "1",
|
||||
"sort_key": "2",
|
||||
}
|
||||
)
|
||||
|
||||
dynamodb.create_table(
|
||||
|
|
@ -4264,7 +4308,10 @@ def test_valid_transact_get_items():
|
|||
)
|
||||
table2 = dynamodb.Table("test2")
|
||||
table2.put_item(
|
||||
Item={"id": "1", "sort_key": "1",}
|
||||
Item={
|
||||
"id": "1",
|
||||
"sort_key": "1",
|
||||
}
|
||||
)
|
||||
|
||||
client = boto3.client("dynamodb", region_name="us-east-1")
|
||||
|
|
@ -4378,7 +4425,10 @@ def test_valid_transact_get_items():
|
|||
"TableName": "test1",
|
||||
"CapacityUnits": 4.0,
|
||||
"ReadCapacityUnits": 4.0,
|
||||
"Table": {"CapacityUnits": 4.0, "ReadCapacityUnits": 4.0,},
|
||||
"Table": {
|
||||
"CapacityUnits": 4.0,
|
||||
"ReadCapacityUnits": 4.0,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
|
|
@ -4387,7 +4437,10 @@ def test_valid_transact_get_items():
|
|||
"TableName": "test2",
|
||||
"CapacityUnits": 2.0,
|
||||
"ReadCapacityUnits": 2.0,
|
||||
"Table": {"CapacityUnits": 2.0, "ReadCapacityUnits": 2.0,},
|
||||
"Table": {
|
||||
"CapacityUnits": 2.0,
|
||||
"ReadCapacityUnits": 2.0,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
|
|
@ -4403,7 +4456,9 @@ def test_gsi_verify_negative_number_order():
|
|||
{"AttributeName": "gsiK1PartitionKey", "KeyType": "HASH"},
|
||||
{"AttributeName": "gsiK1SortKey", "KeyType": "RANGE"},
|
||||
],
|
||||
"Projection": {"ProjectionType": "KEYS_ONLY",},
|
||||
"Projection": {
|
||||
"ProjectionType": "KEYS_ONLY",
|
||||
},
|
||||
}
|
||||
],
|
||||
"AttributeDefinitions": [
|
||||
|
|
@ -4454,7 +4509,9 @@ def test_gsi_verify_negative_number_order():
|
|||
def test_transact_write_items_put():
|
||||
table_schema = {
|
||||
"KeySchema": [{"AttributeName": "id", "KeyType": "HASH"}],
|
||||
"AttributeDefinitions": [{"AttributeName": "id", "AttributeType": "S"},],
|
||||
"AttributeDefinitions": [
|
||||
{"AttributeName": "id", "AttributeType": "S"},
|
||||
],
|
||||
}
|
||||
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
|
||||
dynamodb.create_table(
|
||||
|
|
@ -4465,7 +4522,10 @@ def test_transact_write_items_put():
|
|||
TransactItems=[
|
||||
{
|
||||
"Put": {
|
||||
"Item": {"id": {"S": "foo{}".format(str(i))}, "foo": {"S": "bar"},},
|
||||
"Item": {
|
||||
"id": {"S": "foo{}".format(str(i))},
|
||||
"foo": {"S": "bar"},
|
||||
},
|
||||
"TableName": "test-table",
|
||||
}
|
||||
}
|
||||
|
|
@ -4481,14 +4541,19 @@ def test_transact_write_items_put():
|
|||
def test_transact_write_items_put_conditional_expressions():
|
||||
table_schema = {
|
||||
"KeySchema": [{"AttributeName": "id", "KeyType": "HASH"}],
|
||||
"AttributeDefinitions": [{"AttributeName": "id", "AttributeType": "S"},],
|
||||
"AttributeDefinitions": [
|
||||
{"AttributeName": "id", "AttributeType": "S"},
|
||||
],
|
||||
}
|
||||
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
|
||||
dynamodb.create_table(
|
||||
TableName="test-table", BillingMode="PAY_PER_REQUEST", **table_schema
|
||||
)
|
||||
dynamodb.put_item(
|
||||
TableName="test-table", Item={"id": {"S": "foo2"},},
|
||||
TableName="test-table",
|
||||
Item={
|
||||
"id": {"S": "foo2"},
|
||||
},
|
||||
)
|
||||
# Put multiple items
|
||||
with pytest.raises(ClientError) as ex:
|
||||
|
|
@ -4526,7 +4591,9 @@ def test_transact_write_items_put_conditional_expressions():
|
|||
def test_transact_write_items_conditioncheck_passes():
|
||||
table_schema = {
|
||||
"KeySchema": [{"AttributeName": "id", "KeyType": "HASH"}],
|
||||
"AttributeDefinitions": [{"AttributeName": "id", "AttributeType": "S"},],
|
||||
"AttributeDefinitions": [
|
||||
{"AttributeName": "id", "AttributeType": "S"},
|
||||
],
|
||||
}
|
||||
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
|
||||
dynamodb.create_table(
|
||||
|
|
@ -4534,7 +4601,10 @@ def test_transact_write_items_conditioncheck_passes():
|
|||
)
|
||||
# Insert an item without email address
|
||||
dynamodb.put_item(
|
||||
TableName="test-table", Item={"id": {"S": "foo"},},
|
||||
TableName="test-table",
|
||||
Item={
|
||||
"id": {"S": "foo"},
|
||||
},
|
||||
)
|
||||
# Put an email address, after verifying it doesn't exist yet
|
||||
dynamodb.transact_write_items(
|
||||
|
|
@ -4568,7 +4638,9 @@ def test_transact_write_items_conditioncheck_passes():
|
|||
def test_transact_write_items_conditioncheck_fails():
|
||||
table_schema = {
|
||||
"KeySchema": [{"AttributeName": "id", "KeyType": "HASH"}],
|
||||
"AttributeDefinitions": [{"AttributeName": "id", "AttributeType": "S"},],
|
||||
"AttributeDefinitions": [
|
||||
{"AttributeName": "id", "AttributeType": "S"},
|
||||
],
|
||||
}
|
||||
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
|
||||
dynamodb.create_table(
|
||||
|
|
@ -4617,7 +4689,9 @@ def test_transact_write_items_conditioncheck_fails():
|
|||
def test_transact_write_items_delete():
|
||||
table_schema = {
|
||||
"KeySchema": [{"AttributeName": "id", "KeyType": "HASH"}],
|
||||
"AttributeDefinitions": [{"AttributeName": "id", "AttributeType": "S"},],
|
||||
"AttributeDefinitions": [
|
||||
{"AttributeName": "id", "AttributeType": "S"},
|
||||
],
|
||||
}
|
||||
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
|
||||
dynamodb.create_table(
|
||||
|
|
@ -4625,12 +4699,20 @@ def test_transact_write_items_delete():
|
|||
)
|
||||
# Insert an item
|
||||
dynamodb.put_item(
|
||||
TableName="test-table", Item={"id": {"S": "foo"},},
|
||||
TableName="test-table",
|
||||
Item={
|
||||
"id": {"S": "foo"},
|
||||
},
|
||||
)
|
||||
# Delete the item
|
||||
dynamodb.transact_write_items(
|
||||
TransactItems=[
|
||||
{"Delete": {"Key": {"id": {"S": "foo"}}, "TableName": "test-table",}}
|
||||
{
|
||||
"Delete": {
|
||||
"Key": {"id": {"S": "foo"}},
|
||||
"TableName": "test-table",
|
||||
}
|
||||
}
|
||||
]
|
||||
)
|
||||
# Assert the item is deleted
|
||||
|
|
@ -4642,7 +4724,9 @@ def test_transact_write_items_delete():
|
|||
def test_transact_write_items_delete_with_successful_condition_expression():
|
||||
table_schema = {
|
||||
"KeySchema": [{"AttributeName": "id", "KeyType": "HASH"}],
|
||||
"AttributeDefinitions": [{"AttributeName": "id", "AttributeType": "S"},],
|
||||
"AttributeDefinitions": [
|
||||
{"AttributeName": "id", "AttributeType": "S"},
|
||||
],
|
||||
}
|
||||
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
|
||||
dynamodb.create_table(
|
||||
|
|
@ -4650,14 +4734,19 @@ def test_transact_write_items_delete_with_successful_condition_expression():
|
|||
)
|
||||
# Insert an item without email address
|
||||
dynamodb.put_item(
|
||||
TableName="test-table", Item={"id": {"S": "foo"},},
|
||||
TableName="test-table",
|
||||
Item={
|
||||
"id": {"S": "foo"},
|
||||
},
|
||||
)
|
||||
# ConditionExpression will pass - no email address has been specified yet
|
||||
dynamodb.transact_write_items(
|
||||
TransactItems=[
|
||||
{
|
||||
"Delete": {
|
||||
"Key": {"id": {"S": "foo"},},
|
||||
"Key": {
|
||||
"id": {"S": "foo"},
|
||||
},
|
||||
"TableName": "test-table",
|
||||
"ConditionExpression": "attribute_not_exists(#e)",
|
||||
"ExpressionAttributeNames": {"#e": "email_address"},
|
||||
|
|
@ -4674,7 +4763,9 @@ def test_transact_write_items_delete_with_successful_condition_expression():
|
|||
def test_transact_write_items_delete_with_failed_condition_expression():
|
||||
table_schema = {
|
||||
"KeySchema": [{"AttributeName": "id", "KeyType": "HASH"}],
|
||||
"AttributeDefinitions": [{"AttributeName": "id", "AttributeType": "S"},],
|
||||
"AttributeDefinitions": [
|
||||
{"AttributeName": "id", "AttributeType": "S"},
|
||||
],
|
||||
}
|
||||
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
|
||||
dynamodb.create_table(
|
||||
|
|
@ -4692,7 +4783,9 @@ def test_transact_write_items_delete_with_failed_condition_expression():
|
|||
TransactItems=[
|
||||
{
|
||||
"Delete": {
|
||||
"Key": {"id": {"S": "foo"},},
|
||||
"Key": {
|
||||
"id": {"S": "foo"},
|
||||
},
|
||||
"TableName": "test-table",
|
||||
"ConditionExpression": "attribute_not_exists(#e)",
|
||||
"ExpressionAttributeNames": {"#e": "email_address"},
|
||||
|
|
@ -4713,7 +4806,9 @@ def test_transact_write_items_delete_with_failed_condition_expression():
|
|||
def test_transact_write_items_update():
|
||||
table_schema = {
|
||||
"KeySchema": [{"AttributeName": "id", "KeyType": "HASH"}],
|
||||
"AttributeDefinitions": [{"AttributeName": "id", "AttributeType": "S"},],
|
||||
"AttributeDefinitions": [
|
||||
{"AttributeName": "id", "AttributeType": "S"},
|
||||
],
|
||||
}
|
||||
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
|
||||
dynamodb.create_table(
|
||||
|
|
@ -4745,7 +4840,9 @@ def test_transact_write_items_update():
|
|||
def test_transact_write_items_update_with_failed_condition_expression():
|
||||
table_schema = {
|
||||
"KeySchema": [{"AttributeName": "id", "KeyType": "HASH"}],
|
||||
"AttributeDefinitions": [{"AttributeName": "id", "AttributeType": "S"},],
|
||||
"AttributeDefinitions": [
|
||||
{"AttributeName": "id", "AttributeType": "S"},
|
||||
],
|
||||
}
|
||||
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
|
||||
dynamodb.create_table(
|
||||
|
|
@ -4935,12 +5032,18 @@ def create_simple_table_and_return_client():
|
|||
dynamodb.create_table(
|
||||
TableName="moto-test",
|
||||
KeySchema=[{"AttributeName": "id", "KeyType": "HASH"}],
|
||||
AttributeDefinitions=[{"AttributeName": "id", "AttributeType": "S"},],
|
||||
AttributeDefinitions=[
|
||||
{"AttributeName": "id", "AttributeType": "S"},
|
||||
],
|
||||
ProvisionedThroughput={"ReadCapacityUnits": 1, "WriteCapacityUnits": 1},
|
||||
)
|
||||
dynamodb.put_item(
|
||||
TableName="moto-test",
|
||||
Item={"id": {"S": "1"}, "myNum": {"N": "1"}, "MyStr": {"S": "1"},},
|
||||
Item={
|
||||
"id": {"S": "1"},
|
||||
"myNum": {"N": "1"},
|
||||
"MyStr": {"S": "1"},
|
||||
},
|
||||
)
|
||||
return dynamodb
|
||||
|
||||
|
|
@ -5004,7 +5107,11 @@ def test_update_expression_with_plus_in_attribute_name():
|
|||
|
||||
dynamodb.put_item(
|
||||
TableName="moto-test",
|
||||
Item={"id": {"S": "1"}, "my+Num": {"S": "1"}, "MyStr": {"S": "aaa"},},
|
||||
Item={
|
||||
"id": {"S": "1"},
|
||||
"my+Num": {"S": "1"},
|
||||
"MyStr": {"S": "aaa"},
|
||||
},
|
||||
)
|
||||
try:
|
||||
dynamodb.update_item(
|
||||
|
|
@ -5031,7 +5138,11 @@ def test_update_expression_with_minus_in_attribute_name():
|
|||
|
||||
dynamodb.put_item(
|
||||
TableName="moto-test",
|
||||
Item={"id": {"S": "1"}, "my-Num": {"S": "1"}, "MyStr": {"S": "aaa"},},
|
||||
Item={
|
||||
"id": {"S": "1"},
|
||||
"my-Num": {"S": "1"},
|
||||
"MyStr": {"S": "aaa"},
|
||||
},
|
||||
)
|
||||
try:
|
||||
dynamodb.update_item(
|
||||
|
|
@ -5058,7 +5169,11 @@ def test_update_expression_with_space_in_attribute_name():
|
|||
|
||||
dynamodb.put_item(
|
||||
TableName="moto-test",
|
||||
Item={"id": {"S": "1"}, "my Num": {"S": "1"}, "MyStr": {"S": "aaa"},},
|
||||
Item={
|
||||
"id": {"S": "1"},
|
||||
"my Num": {"S": "1"},
|
||||
"MyStr": {"S": "aaa"},
|
||||
},
|
||||
)
|
||||
|
||||
try:
|
||||
|
|
@ -5241,7 +5356,8 @@ def test_update_item_atomic_counter_from_zero():
|
|||
key = {"t_id": {"S": "item1"}}
|
||||
|
||||
ddb_mock.put_item(
|
||||
TableName=table, Item=key,
|
||||
TableName=table,
|
||||
Item=key,
|
||||
)
|
||||
|
||||
ddb_mock.update_item(
|
||||
|
|
@ -5267,7 +5383,8 @@ def test_update_item_add_to_non_existent_set():
|
|||
)
|
||||
key = {"t_id": {"S": "item1"}}
|
||||
ddb_mock.put_item(
|
||||
TableName=table, Item=key,
|
||||
TableName=table,
|
||||
Item=key,
|
||||
)
|
||||
|
||||
ddb_mock.update_item(
|
||||
|
|
@ -5292,7 +5409,8 @@ def test_update_item_add_to_non_existent_number_set():
|
|||
)
|
||||
key = {"t_id": {"S": "item1"}}
|
||||
ddb_mock.put_item(
|
||||
TableName=table, Item=key,
|
||||
TableName=table,
|
||||
Item=key,
|
||||
)
|
||||
|
||||
ddb_mock.update_item(
|
||||
|
|
@ -5309,7 +5427,9 @@ def test_update_item_add_to_non_existent_number_set():
|
|||
def test_transact_write_items_fails_with_transaction_canceled_exception():
|
||||
table_schema = {
|
||||
"KeySchema": [{"AttributeName": "id", "KeyType": "HASH"}],
|
||||
"AttributeDefinitions": [{"AttributeName": "id", "AttributeType": "S"},],
|
||||
"AttributeDefinitions": [
|
||||
{"AttributeName": "id", "AttributeType": "S"},
|
||||
],
|
||||
}
|
||||
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
|
||||
dynamodb.create_table(
|
||||
|
|
@ -5361,7 +5481,9 @@ def test_gsi_projection_type_keys_only():
|
|||
{"AttributeName": "gsiK1PartitionKey", "KeyType": "HASH"},
|
||||
{"AttributeName": "gsiK1SortKey", "KeyType": "RANGE"},
|
||||
],
|
||||
"Projection": {"ProjectionType": "KEYS_ONLY",},
|
||||
"Projection": {
|
||||
"ProjectionType": "KEYS_ONLY",
|
||||
},
|
||||
}
|
||||
],
|
||||
"AttributeDefinitions": [
|
||||
|
|
@ -5414,7 +5536,9 @@ def test_lsi_projection_type_keys_only():
|
|||
{"AttributeName": "partitionKey", "KeyType": "HASH"},
|
||||
{"AttributeName": "lsiK1SortKey", "KeyType": "RANGE"},
|
||||
],
|
||||
"Projection": {"ProjectionType": "KEYS_ONLY",},
|
||||
"Projection": {
|
||||
"ProjectionType": "KEYS_ONLY",
|
||||
},
|
||||
}
|
||||
],
|
||||
"AttributeDefinitions": [
|
||||
|
|
@ -5439,7 +5563,8 @@ def test_lsi_projection_type_keys_only():
|
|||
table.put_item(Item=item)
|
||||
|
||||
items = table.query(
|
||||
KeyConditionExpression=Key("partitionKey").eq("pk-1"), IndexName="LSI",
|
||||
KeyConditionExpression=Key("partitionKey").eq("pk-1"),
|
||||
IndexName="LSI",
|
||||
)["Items"]
|
||||
items.should.have.length_of(1)
|
||||
# Item should only include GSI Keys and Table Keys, as per the ProjectionType
|
||||
|
|
|
|||
|
|
@ -211,7 +211,11 @@ def test_execution_of_remove_in_map():
|
|||
"itemlist": {
|
||||
"L": [
|
||||
{"M": {"foo00": {"S": "bar1"}, "foo01": {"S": "bar2"}}},
|
||||
{"M": {"foo10": {"S": "bar1"},}},
|
||||
{
|
||||
"M": {
|
||||
"foo10": {"S": "bar1"},
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
@ -260,7 +264,9 @@ def test_execution_of_remove_in_list():
|
|||
"itemmap": {
|
||||
"M": {
|
||||
"itemlist": {
|
||||
"L": [{"M": {"foo00": {"S": "bar1"}, "foo01": {"S": "bar2"}}},]
|
||||
"L": [
|
||||
{"M": {"foo00": {"S": "bar1"}, "foo01": {"S": "bar2"}}},
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -277,7 +283,10 @@ def test_execution_of_delete_element_from_set():
|
|||
hash_key_type="TYPE",
|
||||
range_key=None,
|
||||
range_key_type=None,
|
||||
attrs={"id": {"S": "foo2"}, "s": {"SS": ["value1", "value2", "value3"]},},
|
||||
attrs={
|
||||
"id": {"S": "foo2"},
|
||||
"s": {"SS": ["value1", "value2", "value3"]},
|
||||
},
|
||||
)
|
||||
validated_ast = UpdateExpressionValidator(
|
||||
update_expression_ast,
|
||||
|
|
@ -291,7 +300,10 @@ def test_execution_of_delete_element_from_set():
|
|||
hash_key_type="TYPE",
|
||||
range_key=None,
|
||||
range_key_type=None,
|
||||
attrs={"id": {"S": "foo2"}, "s": {"SS": ["value1", "value3"]},},
|
||||
attrs={
|
||||
"id": {"S": "foo2"},
|
||||
"s": {"SS": ["value1", "value3"]},
|
||||
},
|
||||
)
|
||||
assert expected_item == item
|
||||
|
||||
|
|
@ -304,7 +316,10 @@ def test_execution_of_add_number():
|
|||
hash_key_type="TYPE",
|
||||
range_key=None,
|
||||
range_key_type=None,
|
||||
attrs={"id": {"S": "foo2"}, "s": {"N": "5"},},
|
||||
attrs={
|
||||
"id": {"S": "foo2"},
|
||||
"s": {"N": "5"},
|
||||
},
|
||||
)
|
||||
validated_ast = UpdateExpressionValidator(
|
||||
update_expression_ast,
|
||||
|
|
@ -331,7 +346,10 @@ def test_execution_of_add_set_to_a_number():
|
|||
hash_key_type="TYPE",
|
||||
range_key=None,
|
||||
range_key_type=None,
|
||||
attrs={"id": {"S": "foo2"}, "s": {"N": "5"},},
|
||||
attrs={
|
||||
"id": {"S": "foo2"},
|
||||
"s": {"N": "5"},
|
||||
},
|
||||
)
|
||||
try:
|
||||
validated_ast = UpdateExpressionValidator(
|
||||
|
|
@ -362,7 +380,10 @@ def test_execution_of_add_to_a_set():
|
|||
hash_key_type="TYPE",
|
||||
range_key=None,
|
||||
range_key_type=None,
|
||||
attrs={"id": {"S": "foo2"}, "s": {"SS": ["value1", "value2", "value3"]},},
|
||||
attrs={
|
||||
"id": {"S": "foo2"},
|
||||
"s": {"SS": ["value1", "value2", "value3"]},
|
||||
},
|
||||
)
|
||||
validated_ast = UpdateExpressionValidator(
|
||||
update_expression_ast,
|
||||
|
|
@ -386,13 +407,34 @@ def test_execution_of_add_to_a_set():
|
|||
|
||||
@parameterized(
|
||||
[
|
||||
({":value": {"S": "10"}}, "STRING",),
|
||||
({":value": {"N": "10"}}, "NUMBER",),
|
||||
({":value": {"B": "10"}}, "BINARY",),
|
||||
({":value": {"BOOL": True}}, "BOOLEAN",),
|
||||
({":value": {"NULL": True}}, "NULL",),
|
||||
({":value": {"M": {"el0": {"S": "10"}}}}, "MAP",),
|
||||
({":value": {"L": []}}, "LIST",),
|
||||
(
|
||||
{":value": {"S": "10"}},
|
||||
"STRING",
|
||||
),
|
||||
(
|
||||
{":value": {"N": "10"}},
|
||||
"NUMBER",
|
||||
),
|
||||
(
|
||||
{":value": {"B": "10"}},
|
||||
"BINARY",
|
||||
),
|
||||
(
|
||||
{":value": {"BOOL": True}},
|
||||
"BOOLEAN",
|
||||
),
|
||||
(
|
||||
{":value": {"NULL": True}},
|
||||
"NULL",
|
||||
),
|
||||
(
|
||||
{":value": {"M": {"el0": {"S": "10"}}}},
|
||||
"MAP",
|
||||
),
|
||||
(
|
||||
{":value": {"L": []}},
|
||||
"LIST",
|
||||
),
|
||||
]
|
||||
)
|
||||
def test_execution_of__delete_element_from_set_invalid_value(
|
||||
|
|
@ -406,7 +448,10 @@ def test_execution_of__delete_element_from_set_invalid_value(
|
|||
hash_key_type="TYPE",
|
||||
range_key=None,
|
||||
range_key_type=None,
|
||||
attrs={"id": {"S": "foo2"}, "s": {"SS": ["value1", "value2", "value3"]},},
|
||||
attrs={
|
||||
"id": {"S": "foo2"},
|
||||
"s": {"SS": ["value1", "value2", "value3"]},
|
||||
},
|
||||
)
|
||||
try:
|
||||
validated_ast = UpdateExpressionValidator(
|
||||
|
|
@ -431,7 +476,10 @@ def test_execution_of_delete_element_from_a_string_attribute():
|
|||
hash_key_type="TYPE",
|
||||
range_key=None,
|
||||
range_key_type=None,
|
||||
attrs={"id": {"S": "foo2"}, "s": {"S": "5"},},
|
||||
attrs={
|
||||
"id": {"S": "foo2"},
|
||||
"s": {"S": "5"},
|
||||
},
|
||||
)
|
||||
try:
|
||||
validated_ast = UpdateExpressionValidator(
|
||||
|
|
|
|||
|
|
@ -42,7 +42,10 @@ def test_validation_of_update_expression_with_keyword():
|
|||
|
||||
|
||||
@parameterized(
|
||||
["SET a = #b + :val2", "SET a = :val2 + #b",]
|
||||
[
|
||||
"SET a = #b + :val2",
|
||||
"SET a = :val2 + #b",
|
||||
]
|
||||
)
|
||||
def test_validation_of_a_set_statement_with_incorrect_passed_value(update_expression):
|
||||
"""
|
||||
|
|
@ -99,7 +102,10 @@ def test_validation_of_update_expression_with_attribute_that_does_not_exist_in_i
|
|||
|
||||
|
||||
@parameterized(
|
||||
["SET a = #c", "SET a = #c + #d",]
|
||||
[
|
||||
"SET a = #c",
|
||||
"SET a = #c + #d",
|
||||
]
|
||||
)
|
||||
def test_validation_of_update_expression_with_attribute_name_that_is_not_defined(
|
||||
update_expression,
|
||||
|
|
|
|||
|
|
@ -616,9 +616,9 @@ def test_ami_describe_executable_users_and_filter():
|
|||
@mock_ec2_deprecated
|
||||
def test_ami_attribute_user_and_group_permissions():
|
||||
"""
|
||||
Boto supports adding/removing both users and groups at the same time.
|
||||
Just spot-check this -- input variations, idempotency, etc are validated
|
||||
via user-specific and group-specific tests above.
|
||||
Boto supports adding/removing both users and groups at the same time.
|
||||
Just spot-check this -- input variations, idempotency, etc are validated
|
||||
via user-specific and group-specific tests above.
|
||||
"""
|
||||
conn = boto.connect_ec2("the_key", "the_secret")
|
||||
reservation = conn.run_instances("ami-1234abcd")
|
||||
|
|
|
|||
|
|
@ -144,7 +144,9 @@ def test_create_flow_log_create():
|
|||
|
||||
bucket = s3.create_bucket(
|
||||
Bucket="test-flow-logs",
|
||||
CreateBucketConfiguration={"LocationConstraint": "us-west-1",},
|
||||
CreateBucketConfiguration={
|
||||
"LocationConstraint": "us-west-1",
|
||||
},
|
||||
)
|
||||
|
||||
response = client.create_flow_logs(
|
||||
|
|
|
|||
|
|
@ -211,16 +211,16 @@ def test_instance_detach_volume_wrong_path():
|
|||
ImageId="ami-d3adb33f",
|
||||
MinCount=1,
|
||||
MaxCount=1,
|
||||
BlockDeviceMappings=[{"DeviceName": "/dev/sda1", "Ebs": {"VolumeSize": 50}},],
|
||||
BlockDeviceMappings=[
|
||||
{"DeviceName": "/dev/sda1", "Ebs": {"VolumeSize": 50}},
|
||||
],
|
||||
)
|
||||
instance = result[0]
|
||||
for volume in instance.volumes.all():
|
||||
with pytest.raises(ClientError) as ex:
|
||||
instance.detach_volume(VolumeId=volume.volume_id, Device="/dev/sdf")
|
||||
|
||||
ex.value.response["Error"]["Code"].should.equal(
|
||||
"InvalidAttachment.NotFound"
|
||||
)
|
||||
ex.value.response["Error"]["Code"].should.equal("InvalidAttachment.NotFound")
|
||||
ex.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"The volume {0} is not attached to instance {1} as device {2}".format(
|
||||
|
|
@ -1585,7 +1585,9 @@ def test_create_instance_ebs_optimized():
|
|||
instance.ebs_optimized.should.be(False)
|
||||
|
||||
instance = ec2_resource.create_instances(
|
||||
ImageId="ami-12345678", MaxCount=1, MinCount=1,
|
||||
ImageId="ami-12345678",
|
||||
MaxCount=1,
|
||||
MinCount=1,
|
||||
)[0]
|
||||
instance.load()
|
||||
instance.ebs_optimized.should.be(False)
|
||||
|
|
|
|||
|
|
@ -235,8 +235,8 @@ def test_route_table_associations():
|
|||
@mock_ec2_deprecated
|
||||
def test_route_table_replace_route_table_association():
|
||||
"""
|
||||
Note: Boto has deprecated replace_route_table_association (which returns status)
|
||||
and now uses replace_route_table_association_with_assoc (which returns association ID).
|
||||
Note: Boto has deprecated replace_route_table_association (which returns status)
|
||||
and now uses replace_route_table_association_with_assoc (which returns association ID).
|
||||
"""
|
||||
conn = boto.connect_vpc("the_key", "the_secret")
|
||||
vpc = conn.create_vpc("10.0.0.0/16")
|
||||
|
|
|
|||
|
|
@ -661,7 +661,11 @@ def test_run_instances_should_attach_to_default_subnet():
|
|||
client = boto3.client("ec2", region_name="us-west-1")
|
||||
ec2.create_security_group(GroupName="sg01", Description="Test security group sg01")
|
||||
# run_instances
|
||||
instances = client.run_instances(MinCount=1, MaxCount=1, SecurityGroups=["sg01"],)
|
||||
instances = client.run_instances(
|
||||
MinCount=1,
|
||||
MaxCount=1,
|
||||
SecurityGroups=["sg01"],
|
||||
)
|
||||
# Assert subnet is created appropriately
|
||||
subnets = client.describe_subnets()["Subnets"]
|
||||
default_subnet_id = subnets[0]["SubnetId"]
|
||||
|
|
|
|||
|
|
@ -60,7 +60,9 @@ def test_create_vpn_connection_with_vpn_gateway():
|
|||
|
||||
vpn_gateway = client.create_vpn_gateway(Type="ipsec.1").get("VpnGateway", {})
|
||||
customer_gateway = client.create_customer_gateway(
|
||||
Type="ipsec.1", PublicIp="205.251.242.54", BgpAsn=65534,
|
||||
Type="ipsec.1",
|
||||
PublicIp="205.251.242.54",
|
||||
BgpAsn=65534,
|
||||
).get("CustomerGateway", {})
|
||||
vpn_connection = client.create_vpn_connection(
|
||||
Type="ipsec.1",
|
||||
|
|
|
|||
|
|
@ -2531,7 +2531,9 @@ def test_describe_task_sets():
|
|||
assert "tags" not in task_sets[0]
|
||||
|
||||
task_sets = client.describe_task_sets(
|
||||
cluster=cluster_name, service=service_name, include=["TAGS"],
|
||||
cluster=cluster_name,
|
||||
service=service_name,
|
||||
include=["TAGS"],
|
||||
)["taskSets"]
|
||||
|
||||
cluster_arn = client.describe_clusters(clusters=[cluster_name])["clusters"][0][
|
||||
|
|
@ -2591,29 +2593,39 @@ def test_delete_task_set():
|
|||
)
|
||||
|
||||
task_set = client.create_task_set(
|
||||
cluster=cluster_name, service=service_name, taskDefinition=task_def_name,
|
||||
cluster=cluster_name,
|
||||
service=service_name,
|
||||
taskDefinition=task_def_name,
|
||||
)["taskSet"]
|
||||
|
||||
task_sets = client.describe_task_sets(
|
||||
cluster=cluster_name, service=service_name, taskSets=[task_set["taskSetArn"]],
|
||||
cluster=cluster_name,
|
||||
service=service_name,
|
||||
taskSets=[task_set["taskSetArn"]],
|
||||
)["taskSets"]
|
||||
|
||||
assert len(task_sets) == 1
|
||||
|
||||
response = client.delete_task_set(
|
||||
cluster=cluster_name, service=service_name, taskSet=task_set["taskSetArn"],
|
||||
cluster=cluster_name,
|
||||
service=service_name,
|
||||
taskSet=task_set["taskSetArn"],
|
||||
)
|
||||
assert response["taskSet"]["taskSetArn"] == task_set["taskSetArn"]
|
||||
|
||||
task_sets = client.describe_task_sets(
|
||||
cluster=cluster_name, service=service_name, taskSets=[task_set["taskSetArn"]],
|
||||
cluster=cluster_name,
|
||||
service=service_name,
|
||||
taskSets=[task_set["taskSetArn"]],
|
||||
)["taskSets"]
|
||||
|
||||
assert len(task_sets) == 0
|
||||
|
||||
with pytest.raises(ClientError):
|
||||
_ = client.delete_task_set(
|
||||
cluster=cluster_name, service=service_name, taskSet=task_set["taskSetArn"],
|
||||
cluster=cluster_name,
|
||||
service=service_name,
|
||||
taskSet=task_set["taskSetArn"],
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -2649,7 +2661,9 @@ def test_update_service_primary_task_set():
|
|||
)
|
||||
|
||||
task_set = client.create_task_set(
|
||||
cluster=cluster_name, service=service_name, taskDefinition=task_def_name,
|
||||
cluster=cluster_name,
|
||||
service=service_name,
|
||||
taskDefinition=task_def_name,
|
||||
)["taskSet"]
|
||||
|
||||
service = client.describe_services(cluster=cluster_name, services=[service_name],)[
|
||||
|
|
@ -2669,7 +2683,9 @@ def test_update_service_primary_task_set():
|
|||
assert service["taskDefinition"] == service["taskSets"][0]["taskDefinition"]
|
||||
|
||||
another_task_set = client.create_task_set(
|
||||
cluster=cluster_name, service=service_name, taskDefinition=task_def_name,
|
||||
cluster=cluster_name,
|
||||
service=service_name,
|
||||
taskDefinition=task_def_name,
|
||||
)["taskSet"]
|
||||
service = client.describe_services(cluster=cluster_name, services=[service_name],)[
|
||||
"services"
|
||||
|
|
@ -2721,11 +2737,15 @@ def test_update_task_set():
|
|||
)
|
||||
|
||||
task_set = client.create_task_set(
|
||||
cluster=cluster_name, service=service_name, taskDefinition=task_def_name,
|
||||
cluster=cluster_name,
|
||||
service=service_name,
|
||||
taskDefinition=task_def_name,
|
||||
)["taskSet"]
|
||||
|
||||
another_task_set = client.create_task_set(
|
||||
cluster=cluster_name, service=service_name, taskDefinition=task_def_name,
|
||||
cluster=cluster_name,
|
||||
service=service_name,
|
||||
taskDefinition=task_def_name,
|
||||
)["taskSet"]
|
||||
assert another_task_set["scale"]["unit"] == "PERCENT"
|
||||
assert another_task_set["scale"]["value"] == 100.0
|
||||
|
|
@ -2738,7 +2758,9 @@ def test_update_task_set():
|
|||
)
|
||||
|
||||
updated_task_set = client.describe_task_sets(
|
||||
cluster=cluster_name, service=service_name, taskSets=[task_set["taskSetArn"]],
|
||||
cluster=cluster_name,
|
||||
service=service_name,
|
||||
taskSets=[task_set["taskSetArn"]],
|
||||
)["taskSets"][0]
|
||||
assert updated_task_set["scale"]["value"] == 25.0
|
||||
assert updated_task_set["scale"]["unit"] == "PERCENT"
|
||||
|
|
@ -2784,11 +2806,13 @@ def test_list_tasks_with_filters():
|
|||
}
|
||||
|
||||
_ = ecs.register_task_definition(
|
||||
family="test_task_def_1", containerDefinitions=[test_container_def],
|
||||
family="test_task_def_1",
|
||||
containerDefinitions=[test_container_def],
|
||||
)
|
||||
|
||||
_ = ecs.register_task_definition(
|
||||
family="test_task_def_2", containerDefinitions=[test_container_def],
|
||||
family="test_task_def_2",
|
||||
containerDefinitions=[test_container_def],
|
||||
)
|
||||
|
||||
_ = ecs.start_task(
|
||||
|
|
|
|||
|
|
@ -9,24 +9,30 @@ from moto import mock_elasticbeanstalk
|
|||
def test_create_application():
|
||||
# Create Elastic Beanstalk Application
|
||||
conn = boto3.client("elasticbeanstalk", region_name="us-east-1")
|
||||
app = conn.create_application(ApplicationName="myapp",)
|
||||
app = conn.create_application(
|
||||
ApplicationName="myapp",
|
||||
)
|
||||
app["Application"]["ApplicationName"].should.equal("myapp")
|
||||
|
||||
|
||||
@mock_elasticbeanstalk
|
||||
def test_create_application_dup():
|
||||
conn = boto3.client("elasticbeanstalk", region_name="us-east-1")
|
||||
conn.create_application(ApplicationName="myapp",)
|
||||
conn.create_application.when.called_with(ApplicationName="myapp",).should.throw(
|
||||
ClientError
|
||||
conn.create_application(
|
||||
ApplicationName="myapp",
|
||||
)
|
||||
conn.create_application.when.called_with(
|
||||
ApplicationName="myapp",
|
||||
).should.throw(ClientError)
|
||||
|
||||
|
||||
@mock_elasticbeanstalk
|
||||
def test_describe_applications():
|
||||
# Create Elastic Beanstalk Application
|
||||
conn = boto3.client("elasticbeanstalk", region_name="us-east-1")
|
||||
conn.create_application(ApplicationName="myapp",)
|
||||
conn.create_application(
|
||||
ApplicationName="myapp",
|
||||
)
|
||||
|
||||
apps = conn.describe_applications()
|
||||
len(apps["Applications"]).should.equal(1)
|
||||
|
|
@ -37,8 +43,13 @@ def test_describe_applications():
|
|||
def test_create_environment():
|
||||
# Create Elastic Beanstalk Environment
|
||||
conn = boto3.client("elasticbeanstalk", region_name="us-east-1")
|
||||
app = conn.create_application(ApplicationName="myapp",)
|
||||
env = conn.create_environment(ApplicationName="myapp", EnvironmentName="myenv",)
|
||||
app = conn.create_application(
|
||||
ApplicationName="myapp",
|
||||
)
|
||||
env = conn.create_environment(
|
||||
ApplicationName="myapp",
|
||||
EnvironmentName="myenv",
|
||||
)
|
||||
env["EnvironmentName"].should.equal("myenv")
|
||||
|
||||
|
||||
|
|
@ -46,9 +57,12 @@ def test_create_environment():
|
|||
def test_describe_environments():
|
||||
# List Elastic Beanstalk Envs
|
||||
conn = boto3.client("elasticbeanstalk", region_name="us-east-1")
|
||||
conn.create_application(ApplicationName="myapp",)
|
||||
conn.create_application(
|
||||
ApplicationName="myapp",
|
||||
)
|
||||
conn.create_environment(
|
||||
ApplicationName="myapp", EnvironmentName="myenv",
|
||||
ApplicationName="myapp",
|
||||
EnvironmentName="myenv",
|
||||
)
|
||||
|
||||
envs = conn.describe_environments()
|
||||
|
|
@ -75,7 +89,9 @@ def tags_list_to_dict(tag_list):
|
|||
@mock_elasticbeanstalk
|
||||
def test_create_environment_tags():
|
||||
conn = boto3.client("elasticbeanstalk", region_name="us-east-1")
|
||||
conn.create_application(ApplicationName="myapp",)
|
||||
conn.create_application(
|
||||
ApplicationName="myapp",
|
||||
)
|
||||
env_tags = {"initial key": "initial value"}
|
||||
env = conn.create_environment(
|
||||
ApplicationName="myapp",
|
||||
|
|
@ -83,7 +99,9 @@ def test_create_environment_tags():
|
|||
Tags=tags_dict_to_list(env_tags),
|
||||
)
|
||||
|
||||
tags = conn.list_tags_for_resource(ResourceArn=env["EnvironmentArn"],)
|
||||
tags = conn.list_tags_for_resource(
|
||||
ResourceArn=env["EnvironmentArn"],
|
||||
)
|
||||
tags["ResourceArn"].should.equal(env["EnvironmentArn"])
|
||||
tags_list_to_dict(tags["ResourceTags"]).should.equal(env_tags)
|
||||
|
||||
|
|
@ -91,7 +109,9 @@ def test_create_environment_tags():
|
|||
@mock_elasticbeanstalk
|
||||
def test_update_tags():
|
||||
conn = boto3.client("elasticbeanstalk", region_name="us-east-1")
|
||||
conn.create_application(ApplicationName="myapp",)
|
||||
conn.create_application(
|
||||
ApplicationName="myapp",
|
||||
)
|
||||
env_tags = {
|
||||
"initial key": "initial value",
|
||||
"to remove": "delete me",
|
||||
|
|
@ -117,7 +137,9 @@ def test_update_tags():
|
|||
total_env_tags.update(extra_env_tags)
|
||||
del total_env_tags["to remove"]
|
||||
|
||||
tags = conn.list_tags_for_resource(ResourceArn=env["EnvironmentArn"],)
|
||||
tags = conn.list_tags_for_resource(
|
||||
ResourceArn=env["EnvironmentArn"],
|
||||
)
|
||||
tags["ResourceArn"].should.equal(env["EnvironmentArn"])
|
||||
tags_list_to_dict(tags["ResourceTags"]).should.equal(total_env_tags)
|
||||
|
||||
|
|
|
|||
|
|
@ -184,8 +184,9 @@ def test_apply_security_groups_to_load_balancer():
|
|||
response = client.apply_security_groups_to_load_balancer(
|
||||
LoadBalancerName="my-lb", SecurityGroups=["not-really-a-security-group"]
|
||||
)
|
||||
assert "One or more of the specified security groups do not exist." \
|
||||
in str(error.value)
|
||||
assert "One or more of the specified security groups do not exist." in str(
|
||||
error.value
|
||||
)
|
||||
|
||||
|
||||
@mock_elb_deprecated
|
||||
|
|
|
|||
|
|
@ -524,8 +524,10 @@ def test_run_job_flow_with_instance_groups_with_autoscaling():
|
|||
if "AutoScalingPolicy" in y:
|
||||
x["AutoScalingPolicy"]["Status"]["State"].should.equal("ATTACHED")
|
||||
returned_policy = deepcopy(x["AutoScalingPolicy"])
|
||||
auto_scaling_policy_with_cluster_id = _patch_cluster_id_placeholder_in_autoscaling_policy(
|
||||
y["AutoScalingPolicy"], cluster_id
|
||||
auto_scaling_policy_with_cluster_id = (
|
||||
_patch_cluster_id_placeholder_in_autoscaling_policy(
|
||||
y["AutoScalingPolicy"], cluster_id
|
||||
)
|
||||
)
|
||||
del returned_policy["Status"]
|
||||
returned_policy.should.equal(auto_scaling_policy_with_cluster_id)
|
||||
|
|
@ -551,8 +553,10 @@ def test_put_remove_auto_scaling_policy():
|
|||
AutoScalingPolicy=auto_scaling_policy,
|
||||
)
|
||||
|
||||
auto_scaling_policy_with_cluster_id = _patch_cluster_id_placeholder_in_autoscaling_policy(
|
||||
auto_scaling_policy, cluster_id
|
||||
auto_scaling_policy_with_cluster_id = (
|
||||
_patch_cluster_id_placeholder_in_autoscaling_policy(
|
||||
auto_scaling_policy, cluster_id
|
||||
)
|
||||
)
|
||||
del resp["AutoScalingPolicy"]["Status"]
|
||||
resp["AutoScalingPolicy"].should.equal(auto_scaling_policy_with_cluster_id)
|
||||
|
|
|
|||
|
|
@ -223,9 +223,7 @@ def test_get_table_not_exits():
|
|||
helpers.get_table(client, database_name, "myfirsttable")
|
||||
|
||||
exc.value.response["Error"]["Code"].should.equal("EntityNotFoundException")
|
||||
exc.value.response["Error"]["Message"].should.match(
|
||||
"Table myfirsttable not found"
|
||||
)
|
||||
exc.value.response["Error"]["Message"].should.match("Table myfirsttable not found")
|
||||
|
||||
|
||||
@mock_glue
|
||||
|
|
|
|||
|
|
@ -207,7 +207,9 @@ def test_remove_role_from_instance_profile():
|
|||
def test_delete_instance_profile():
|
||||
conn = boto3.client("iam", region_name="us-east-1")
|
||||
conn.create_role(
|
||||
RoleName="my-role", AssumeRolePolicyDocument="some policy", Path="/my-path/"
|
||||
RoleName="my-role",
|
||||
AssumeRolePolicyDocument="some policy",
|
||||
Path="/my-path/",
|
||||
)
|
||||
conn.create_instance_profile(InstanceProfileName="my-profile")
|
||||
conn.add_role_to_instance_profile(
|
||||
|
|
@ -257,7 +259,9 @@ def test_delete_role():
|
|||
|
||||
# Test deletion failure with a managed policy
|
||||
conn.create_role(
|
||||
RoleName="my-role", AssumeRolePolicyDocument="some policy", Path="/my-path/"
|
||||
RoleName="my-role",
|
||||
AssumeRolePolicyDocument="some policy",
|
||||
Path="/my-path/",
|
||||
)
|
||||
response = conn.create_policy(
|
||||
PolicyName="my-managed-policy", PolicyDocument=MOCK_POLICY
|
||||
|
|
@ -273,10 +277,14 @@ def test_delete_role():
|
|||
|
||||
# Test deletion failure with an inline policy
|
||||
conn.create_role(
|
||||
RoleName="my-role", AssumeRolePolicyDocument="some policy", Path="/my-path/"
|
||||
RoleName="my-role",
|
||||
AssumeRolePolicyDocument="some policy",
|
||||
Path="/my-path/",
|
||||
)
|
||||
conn.put_role_policy(
|
||||
RoleName="my-role", PolicyName="my-role-policy", PolicyDocument=MOCK_POLICY
|
||||
RoleName="my-role",
|
||||
PolicyName="my-role-policy",
|
||||
PolicyDocument=MOCK_POLICY,
|
||||
)
|
||||
with pytest.raises(conn.exceptions.DeleteConflictException):
|
||||
conn.delete_role(RoleName="my-role")
|
||||
|
|
@ -287,7 +295,9 @@ def test_delete_role():
|
|||
|
||||
# Test deletion failure with attachment to an instance profile
|
||||
conn.create_role(
|
||||
RoleName="my-role", AssumeRolePolicyDocument="some policy", Path="/my-path/"
|
||||
RoleName="my-role",
|
||||
AssumeRolePolicyDocument="some policy",
|
||||
Path="/my-path/",
|
||||
)
|
||||
conn.create_instance_profile(InstanceProfileName="my-profile")
|
||||
conn.add_role_to_instance_profile(
|
||||
|
|
@ -304,7 +314,9 @@ def test_delete_role():
|
|||
|
||||
# Test deletion with no conflicts
|
||||
conn.create_role(
|
||||
RoleName="my-role", AssumeRolePolicyDocument="some policy", Path="/my-path/"
|
||||
RoleName="my-role",
|
||||
AssumeRolePolicyDocument="some policy",
|
||||
Path="/my-path/",
|
||||
)
|
||||
conn.delete_role(RoleName="my-role")
|
||||
with pytest.raises(conn.exceptions.NoSuchEntityException):
|
||||
|
|
@ -331,7 +343,9 @@ def test_list_instance_profiles_for_role():
|
|||
conn = boto.connect_iam()
|
||||
|
||||
conn.create_role(
|
||||
role_name="my-role", assume_role_policy_document="some policy", path="my-path"
|
||||
role_name="my-role",
|
||||
assume_role_policy_document="some policy",
|
||||
path="my-path",
|
||||
)
|
||||
conn.create_role(
|
||||
role_name="my-role2",
|
||||
|
|
@ -343,7 +357,8 @@ def test_list_instance_profiles_for_role():
|
|||
profile_path_list = ["my-path", "my-path2"]
|
||||
for profile_count in range(0, 2):
|
||||
conn.create_instance_profile(
|
||||
profile_name_list[profile_count], path=profile_path_list[profile_count]
|
||||
profile_name_list[profile_count],
|
||||
path=profile_path_list[profile_count],
|
||||
)
|
||||
|
||||
for profile_count in range(0, 2):
|
||||
|
|
@ -409,7 +424,9 @@ def test_put_role_policy():
|
|||
def test_get_role_policy():
|
||||
conn = boto3.client("iam", region_name="us-east-1")
|
||||
conn.create_role(
|
||||
RoleName="my-role", AssumeRolePolicyDocument="some policy", Path="my-path"
|
||||
RoleName="my-role",
|
||||
AssumeRolePolicyDocument="some policy",
|
||||
Path="my-path",
|
||||
)
|
||||
with pytest.raises(conn.exceptions.NoSuchEntityException):
|
||||
conn.get_role_policy(RoleName="my-role", PolicyName="does-not-exist")
|
||||
|
|
@ -898,19 +915,19 @@ def test_get_all_access_keys():
|
|||
conn = boto.connect_iam()
|
||||
conn.create_user("my-user")
|
||||
response = conn.get_all_access_keys("my-user")
|
||||
assert \
|
||||
assert (
|
||||
response["list_access_keys_response"]["list_access_keys_result"][
|
||||
"access_key_metadata"
|
||||
] == []
|
||||
]
|
||||
== []
|
||||
)
|
||||
conn.create_access_key("my-user")
|
||||
response = conn.get_all_access_keys("my-user")
|
||||
assert \
|
||||
sorted(
|
||||
response["list_access_keys_response"]["list_access_keys_result"][
|
||||
"access_key_metadata"
|
||||
][0].keys()
|
||||
) == \
|
||||
sorted(["status", "create_date", "user_name", "access_key_id"])
|
||||
assert sorted(
|
||||
response["list_access_keys_response"]["list_access_keys_result"][
|
||||
"access_key_metadata"
|
||||
][0].keys()
|
||||
) == sorted(["status", "create_date", "user_name", "access_key_id"])
|
||||
|
||||
|
||||
@mock_iam
|
||||
|
|
@ -921,9 +938,9 @@ def test_list_access_keys():
|
|||
assert response["AccessKeyMetadata"] == []
|
||||
access_key = conn.create_access_key(UserName="my-user")["AccessKey"]
|
||||
response = conn.list_access_keys(UserName="my-user")
|
||||
assert \
|
||||
sorted(response["AccessKeyMetadata"][0].keys()) == \
|
||||
sorted(["Status", "CreateDate", "UserName", "AccessKeyId"]
|
||||
assert sorted(response["AccessKeyMetadata"][0].keys()) == sorted(
|
||||
["Status", "CreateDate", "UserName", "AccessKeyId"]
|
||||
)
|
||||
conn = boto3.client(
|
||||
"iam",
|
||||
region_name="us-east-1",
|
||||
|
|
@ -931,9 +948,9 @@ def test_list_access_keys():
|
|||
aws_secret_access_key=access_key["SecretAccessKey"],
|
||||
)
|
||||
response = conn.list_access_keys()
|
||||
assert \
|
||||
sorted(response["AccessKeyMetadata"][0].keys()) == \
|
||||
sorted(["Status", "CreateDate", "UserName", "AccessKeyId"])
|
||||
assert sorted(response["AccessKeyMetadata"][0].keys()) == sorted(
|
||||
["Status", "CreateDate", "UserName", "AccessKeyId"]
|
||||
)
|
||||
|
||||
|
||||
@mock_iam_deprecated()
|
||||
|
|
@ -1022,7 +1039,8 @@ def test_create_virtual_mfa_device_errors():
|
|||
client.create_virtual_mfa_device.when.called_with(
|
||||
VirtualMFADeviceName="test-device"
|
||||
).should.throw(
|
||||
ClientError, "MFADevice entity at the same path and name already exists."
|
||||
ClientError,
|
||||
"MFADevice entity at the same path and name already exists.",
|
||||
)
|
||||
|
||||
client.create_virtual_mfa_device.when.called_with(
|
||||
|
|
@ -1211,7 +1229,9 @@ def test_delete_user():
|
|||
# Test deletion failure with an inline policy
|
||||
conn.create_user(UserName="my-user")
|
||||
conn.put_user_policy(
|
||||
UserName="my-user", PolicyName="my-user-policy", PolicyDocument=MOCK_POLICY
|
||||
UserName="my-user",
|
||||
PolicyName="my-user-policy",
|
||||
PolicyDocument=MOCK_POLICY,
|
||||
)
|
||||
with pytest.raises(conn.exceptions.DeleteConflictException):
|
||||
conn.delete_user(UserName="my-user")
|
||||
|
|
@ -1396,7 +1416,9 @@ def test_managed_policy():
|
|||
|
||||
role_name = "my-role"
|
||||
conn.create_role(
|
||||
role_name, assume_role_policy_document={"policy": "test"}, path="my-path"
|
||||
role_name,
|
||||
assume_role_policy_document={"policy": "test"},
|
||||
path="my-path",
|
||||
)
|
||||
for policy_name in [
|
||||
"AmazonElasticMapReduceRole",
|
||||
|
|
@ -1423,7 +1445,8 @@ def test_managed_policy():
|
|||
].should.have.length_of(2)
|
||||
|
||||
conn.detach_role_policy(
|
||||
"arn:aws:iam::aws:policy/service-role/AmazonElasticMapReduceRole", role_name
|
||||
"arn:aws:iam::aws:policy/service-role/AmazonElasticMapReduceRole",
|
||||
role_name,
|
||||
)
|
||||
rows = conn.list_policies(only_attached=True)["list_policies_response"][
|
||||
"list_policies_result"
|
||||
|
|
@ -1444,7 +1467,8 @@ def test_managed_policy():
|
|||
|
||||
with pytest.raises(BotoServerError):
|
||||
conn.detach_role_policy(
|
||||
"arn:aws:iam::aws:policy/service-role/AmazonElasticMapReduceRole", role_name
|
||||
"arn:aws:iam::aws:policy/service-role/AmazonElasticMapReduceRole",
|
||||
role_name,
|
||||
)
|
||||
|
||||
with pytest.raises(BotoServerError):
|
||||
|
|
@ -1562,7 +1586,9 @@ def test_get_ssh_public_key():
|
|||
|
||||
with pytest.raises(ClientError):
|
||||
client.get_ssh_public_key(
|
||||
UserName=username, SSHPublicKeyId="xxnon-existent-keyxx", Encoding="SSH"
|
||||
UserName=username,
|
||||
SSHPublicKeyId="xxnon-existent-keyxx",
|
||||
Encoding="SSH",
|
||||
)
|
||||
|
||||
resp = client.upload_ssh_public_key(UserName=username, SSHPublicKeyBody=public_key)
|
||||
|
|
@ -1603,7 +1629,9 @@ def test_update_ssh_public_key():
|
|||
|
||||
with pytest.raises(ClientError):
|
||||
client.update_ssh_public_key(
|
||||
UserName=username, SSHPublicKeyId="xxnon-existent-keyxx", Status="Inactive"
|
||||
UserName=username,
|
||||
SSHPublicKeyId="xxnon-existent-keyxx",
|
||||
Status="Inactive",
|
||||
)
|
||||
|
||||
resp = client.upload_ssh_public_key(UserName=username, SSHPublicKeyBody=public_key)
|
||||
|
|
@ -1681,7 +1709,9 @@ def test_get_account_authorization_details():
|
|||
UserName="testUser", PolicyName="testPolicy", PolicyDocument=test_policy
|
||||
)
|
||||
conn.put_group_policy(
|
||||
GroupName="testGroup", PolicyName="testPolicy", PolicyDocument=test_policy
|
||||
GroupName="testGroup",
|
||||
PolicyName="testPolicy",
|
||||
PolicyDocument=test_policy,
|
||||
)
|
||||
|
||||
conn.attach_user_policy(
|
||||
|
|
@ -1981,7 +2011,9 @@ def test_create_role_with_tags():
|
|||
map(lambda x: {"Key": str(x), "Value": str(x)}, range(0, 51))
|
||||
)
|
||||
conn.create_role(
|
||||
RoleName="my-role3", AssumeRolePolicyDocument="{}", Tags=too_many_tags
|
||||
RoleName="my-role3",
|
||||
AssumeRolePolicyDocument="{}",
|
||||
Tags=too_many_tags,
|
||||
)
|
||||
assert (
|
||||
"failed to satisfy constraint: Member must have length less than or equal to 50."
|
||||
|
|
@ -2247,7 +2279,9 @@ def test_update_role_description():
|
|||
conn.delete_role(RoleName="my-role")
|
||||
|
||||
conn.create_role(
|
||||
RoleName="my-role", AssumeRolePolicyDocument="some policy", Path="/my-path/"
|
||||
RoleName="my-role",
|
||||
AssumeRolePolicyDocument="some policy",
|
||||
Path="/my-path/",
|
||||
)
|
||||
response = conn.update_role_description(RoleName="my-role", Description="test")
|
||||
|
||||
|
|
@ -2262,7 +2296,9 @@ def test_update_role():
|
|||
conn.delete_role(RoleName="my-role")
|
||||
|
||||
conn.create_role(
|
||||
RoleName="my-role", AssumeRolePolicyDocument="some policy", Path="/my-path/"
|
||||
RoleName="my-role",
|
||||
AssumeRolePolicyDocument="some policy",
|
||||
Path="/my-path/",
|
||||
)
|
||||
response = conn.update_role_description(RoleName="my-role", Description="test")
|
||||
assert response["Role"]["RoleName"] == "my-role"
|
||||
|
|
@ -2276,7 +2312,9 @@ def test_update_role():
|
|||
conn.delete_role(RoleName="my-role")
|
||||
|
||||
conn.create_role(
|
||||
RoleName="my-role", AssumeRolePolicyDocument="some policy", Path="/my-path/"
|
||||
RoleName="my-role",
|
||||
AssumeRolePolicyDocument="some policy",
|
||||
Path="/my-path/",
|
||||
)
|
||||
response = conn.update_role(RoleName="my-role", Description="test")
|
||||
assert len(response.keys()) == 1
|
||||
|
|
@ -2317,7 +2355,9 @@ def test_list_entities_for_policy():
|
|||
|
||||
conn = boto3.client("iam", region_name="us-east-1")
|
||||
conn.create_role(
|
||||
RoleName="my-role", AssumeRolePolicyDocument="some policy", Path="/my-path/"
|
||||
RoleName="my-role",
|
||||
AssumeRolePolicyDocument="some policy",
|
||||
Path="/my-path/",
|
||||
)
|
||||
conn.create_user(Path="/", UserName="testUser")
|
||||
conn.create_group(Path="/", GroupName="testGroup")
|
||||
|
|
@ -2333,7 +2373,9 @@ def test_list_entities_for_policy():
|
|||
UserName="testUser", PolicyName="testPolicy", PolicyDocument=test_policy
|
||||
)
|
||||
conn.put_group_policy(
|
||||
GroupName="testGroup", PolicyName="testPolicy", PolicyDocument=test_policy
|
||||
GroupName="testGroup",
|
||||
PolicyName="testPolicy",
|
||||
PolicyDocument=test_policy,
|
||||
)
|
||||
|
||||
conn.attach_user_policy(
|
||||
|
|
@ -2396,7 +2438,9 @@ def test_list_entities_for_policy():
|
|||
def test_create_role_no_path():
|
||||
conn = boto3.client("iam", region_name="us-east-1")
|
||||
resp = conn.create_role(
|
||||
RoleName="my-role", AssumeRolePolicyDocument="some policy", Description="test"
|
||||
RoleName="my-role",
|
||||
AssumeRolePolicyDocument="some policy",
|
||||
Description="test",
|
||||
)
|
||||
resp.get("Role").get("Arn").should.equal(
|
||||
"arn:aws:iam::{}:role/my-role".format(ACCOUNT_ID)
|
||||
|
|
@ -2452,7 +2496,9 @@ def test_create_role_with_same_name_should_fail():
|
|||
iam = boto3.client("iam", region_name="us-east-1")
|
||||
test_role_name = str(uuid4())
|
||||
iam.create_role(
|
||||
RoleName=test_role_name, AssumeRolePolicyDocument="policy", Description="test"
|
||||
RoleName=test_role_name,
|
||||
AssumeRolePolicyDocument="policy",
|
||||
Description="test",
|
||||
)
|
||||
# Create the role again, and verify that it fails
|
||||
with pytest.raises(ClientError) as err:
|
||||
|
|
@ -2539,14 +2585,24 @@ def test_create_open_id_connect_provider_errors():
|
|||
|
||||
client.create_open_id_connect_provider.when.called_with(
|
||||
Url="http://example.org",
|
||||
ThumbprintList=["a" * 40, "b" * 40, "c" * 40, "d" * 40, "e" * 40, "f" * 40],
|
||||
ThumbprintList=[
|
||||
"a" * 40,
|
||||
"b" * 40,
|
||||
"c" * 40,
|
||||
"d" * 40,
|
||||
"e" * 40,
|
||||
"f" * 40,
|
||||
],
|
||||
).should.throw(ClientError, "Thumbprint list must contain fewer than 5 entries.")
|
||||
|
||||
too_many_client_ids = ["{}".format(i) for i in range(101)]
|
||||
client.create_open_id_connect_provider.when.called_with(
|
||||
Url="http://example.org", ThumbprintList=[], ClientIDList=too_many_client_ids
|
||||
Url="http://example.org",
|
||||
ThumbprintList=[],
|
||||
ClientIDList=too_many_client_ids,
|
||||
).should.throw(
|
||||
ClientError, "Cannot exceed quota for ClientIdsPerOpenIdConnectProvider: 100"
|
||||
ClientError,
|
||||
"Cannot exceed quota for ClientIdsPerOpenIdConnectProvider: 100",
|
||||
)
|
||||
|
||||
too_long_url = "b" * 256
|
||||
|
|
@ -2587,7 +2643,8 @@ def test_delete_open_id_connect_provider():
|
|||
client.get_open_id_connect_provider.when.called_with(
|
||||
OpenIDConnectProviderArn=open_id_arn
|
||||
).should.throw(
|
||||
ClientError, "OpenIDConnect Provider not found for arn {}".format(open_id_arn)
|
||||
ClientError,
|
||||
"OpenIDConnect Provider not found for arn {}".format(open_id_arn),
|
||||
)
|
||||
|
||||
# deleting a non existing provider should be successful
|
||||
|
|
@ -2679,7 +2736,9 @@ def test_update_account_password_policy_errors():
|
|||
client = boto3.client("iam", region_name="us-east-1")
|
||||
|
||||
client.update_account_password_policy.when.called_with(
|
||||
MaxPasswordAge=1096, MinimumPasswordLength=129, PasswordReusePrevention=25
|
||||
MaxPasswordAge=1096,
|
||||
MinimumPasswordLength=129,
|
||||
PasswordReusePrevention=25,
|
||||
).should.throw(
|
||||
ClientError,
|
||||
"3 validation errors detected: "
|
||||
|
|
@ -2757,7 +2816,8 @@ def test_delete_account_password_policy_errors():
|
|||
client = boto3.client("iam", region_name="us-east-1")
|
||||
|
||||
client.delete_account_password_policy.when.called_with().should.throw(
|
||||
ClientError, "The account policy with name PasswordPolicy cannot be found."
|
||||
ClientError,
|
||||
"The account policy with name PasswordPolicy cannot be found.",
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -2885,7 +2945,8 @@ def test_list_user_tags():
|
|||
conn = boto3.client("iam", region_name="us-east-1")
|
||||
conn.create_user(UserName="kenny-bania")
|
||||
conn.create_user(
|
||||
UserName="jackie-chiles", Tags=[{"Key": "Sue-Allen", "Value": "Oh-Henry"}]
|
||||
UserName="jackie-chiles",
|
||||
Tags=[{"Key": "Sue-Allen", "Value": "Oh-Henry"}],
|
||||
)
|
||||
conn.create_user(
|
||||
UserName="cosmo",
|
||||
|
|
@ -2904,7 +2965,10 @@ def test_list_user_tags():
|
|||
|
||||
response = conn.list_user_tags(UserName="cosmo")
|
||||
response["Tags"].should.equal(
|
||||
[{"Key": "Stan", "Value": "The Caddy"}, {"Key": "like-a", "Value": "glove"}]
|
||||
[
|
||||
{"Key": "Stan", "Value": "The Caddy"},
|
||||
{"Key": "like-a", "Value": "glove"},
|
||||
]
|
||||
)
|
||||
response["IsTruncated"].should_not.be.ok
|
||||
|
||||
|
|
@ -2947,7 +3011,8 @@ def test_delete_account_password_policy_errors():
|
|||
client = boto3.client("iam", region_name="us-east-1")
|
||||
|
||||
client.delete_account_password_policy.when.called_with().should.throw(
|
||||
ClientError, "The account policy with name PasswordPolicy cannot be found."
|
||||
ClientError,
|
||||
"The account policy with name PasswordPolicy cannot be found.",
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -2976,7 +3041,10 @@ def test_role_list_config_discovered_resources():
|
|||
max_session_duration=3600,
|
||||
)
|
||||
roles.append(
|
||||
{"id": this_role.id, "name": this_role.name,}
|
||||
{
|
||||
"id": this_role.id,
|
||||
"name": this_role.name,
|
||||
}
|
||||
)
|
||||
|
||||
assert len(roles) == num_roles
|
||||
|
|
@ -3034,7 +3102,11 @@ def test_role_config_dict():
|
|||
basic_assume_role = {
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{"Effect": "Allow", "Principal": {"AWS": "*"}, "Action": "sts:AssumeRole"}
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Principal": {"AWS": "*"},
|
||||
"Action": "sts:AssumeRole",
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
|
|
@ -3351,7 +3423,9 @@ def test_role_config_client():
|
|||
# Test non-aggregated pagination
|
||||
assert (
|
||||
config_client.list_discovered_resources(
|
||||
resourceType="AWS::IAM::Role", limit=1, nextToken=result["nextToken"]
|
||||
resourceType="AWS::IAM::Role",
|
||||
limit=1,
|
||||
nextToken=result["nextToken"],
|
||||
)["resourceIdentifiers"][0]["resourceId"]
|
||||
) != first_result
|
||||
|
||||
|
|
@ -3387,14 +3461,18 @@ def test_role_config_client():
|
|||
# Test non-aggregated resource name/id filter
|
||||
assert (
|
||||
config_client.list_discovered_resources(
|
||||
resourceType="AWS::IAM::Role", resourceName=roles[1]["name"], limit=1,
|
||||
resourceType="AWS::IAM::Role",
|
||||
resourceName=roles[1]["name"],
|
||||
limit=1,
|
||||
)["resourceIdentifiers"][0]["resourceName"]
|
||||
== roles[1]["name"]
|
||||
)
|
||||
|
||||
assert (
|
||||
config_client.list_discovered_resources(
|
||||
resourceType="AWS::IAM::Role", resourceIds=[roles[0]["id"]], limit=1,
|
||||
resourceType="AWS::IAM::Role",
|
||||
resourceIds=[roles[0]["id"]],
|
||||
limit=1,
|
||||
)["resourceIdentifiers"][0]["resourceName"]
|
||||
== roles[0]["name"]
|
||||
)
|
||||
|
|
@ -3440,13 +3518,17 @@ def test_role_config_client():
|
|||
# Test non-aggregated resource name/id filter
|
||||
assert (
|
||||
config_client.list_discovered_resources(
|
||||
resourceType="AWS::IAM::Role", resourceName=roles[1]["name"], limit=1,
|
||||
resourceType="AWS::IAM::Role",
|
||||
resourceName=roles[1]["name"],
|
||||
limit=1,
|
||||
)["resourceIdentifiers"][0]["resourceName"]
|
||||
== roles[1]["name"]
|
||||
)
|
||||
assert (
|
||||
config_client.list_discovered_resources(
|
||||
resourceType="AWS::IAM::Role", resourceIds=[roles[0]["id"]], limit=1,
|
||||
resourceType="AWS::IAM::Role",
|
||||
resourceIds=[roles[0]["id"]],
|
||||
limit=1,
|
||||
)["resourceIdentifiers"][0]["resourceName"]
|
||||
== roles[0]["name"]
|
||||
)
|
||||
|
|
@ -3556,7 +3638,10 @@ def test_policy_list_config_discovered_resources():
|
|||
policy_name="policy{}".format(ix),
|
||||
)
|
||||
policies.append(
|
||||
{"id": this_policy.id, "name": this_policy.name,}
|
||||
{
|
||||
"id": this_policy.id,
|
||||
"name": this_policy.name,
|
||||
}
|
||||
)
|
||||
|
||||
assert len(policies) == num_policies
|
||||
|
|
@ -3781,7 +3866,9 @@ def test_policy_config_client():
|
|||
# Test non-aggregated pagination
|
||||
assert (
|
||||
config_client.list_discovered_resources(
|
||||
resourceType="AWS::IAM::Policy", limit=1, nextToken=result["nextToken"]
|
||||
resourceType="AWS::IAM::Policy",
|
||||
limit=1,
|
||||
nextToken=result["nextToken"],
|
||||
)["resourceIdentifiers"][0]["resourceId"]
|
||||
) != first_result
|
||||
|
||||
|
|
@ -3818,14 +3905,18 @@ def test_policy_config_client():
|
|||
# Test non-aggregated resource name/id filter
|
||||
assert (
|
||||
config_client.list_discovered_resources(
|
||||
resourceType="AWS::IAM::Policy", resourceName=policies[1]["name"], limit=1,
|
||||
resourceType="AWS::IAM::Policy",
|
||||
resourceName=policies[1]["name"],
|
||||
limit=1,
|
||||
)["resourceIdentifiers"][0]["resourceName"]
|
||||
== policies[1]["name"]
|
||||
)
|
||||
|
||||
assert (
|
||||
config_client.list_discovered_resources(
|
||||
resourceType="AWS::IAM::Policy", resourceIds=[policies[0]["id"]], limit=1,
|
||||
resourceType="AWS::IAM::Policy",
|
||||
resourceIds=[policies[0]["id"]],
|
||||
limit=1,
|
||||
)["resourceIdentifiers"][0]["resourceName"]
|
||||
== policies[0]["name"]
|
||||
)
|
||||
|
|
@ -3906,7 +3997,10 @@ def test_policy_config_client():
|
|||
assert (
|
||||
config_client.batch_get_resource_config(
|
||||
resourceKeys=[
|
||||
{"resourceType": "AWS::IAM::Policy", "resourceId": policies[7]["id"]}
|
||||
{
|
||||
"resourceType": "AWS::IAM::Policy",
|
||||
"resourceId": policies[7]["id"],
|
||||
}
|
||||
]
|
||||
)["baseConfigurationItems"][0]["resourceName"]
|
||||
== policies[7]["name"]
|
||||
|
|
|
|||
|
|
@ -939,9 +939,7 @@ class TestListThingGroup:
|
|||
resp["thingGroups"].should.have.length_of(0)
|
||||
with pytest.raises(ClientError) as e:
|
||||
client.list_thing_groups(parentGroup="inexistant-group-name")
|
||||
e.value.response["Error"]["Code"].should.equal(
|
||||
"ResourceNotFoundException"
|
||||
)
|
||||
e.value.response["Error"]["Code"].should.equal("ResourceNotFoundException")
|
||||
|
||||
@mock_iot
|
||||
def test_should_list_all_groups_filtered_by_parent_non_recursively(self):
|
||||
|
|
@ -1019,7 +1017,9 @@ def test_delete_thing_group():
|
|||
group_name_1a = "my-group-name-1a"
|
||||
group_name_2a = "my-group-name-2a"
|
||||
tree_dict = {
|
||||
group_name_1a: {group_name_2a: {},},
|
||||
group_name_1a: {
|
||||
group_name_2a: {},
|
||||
},
|
||||
}
|
||||
group_catalog = generate_thing_group_tree(client, tree_dict)
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,9 @@ def test_get_hls_streaming_session_url():
|
|||
region_name=region_name,
|
||||
endpoint_url=data_endpoint,
|
||||
)
|
||||
res = client.get_hls_streaming_session_url(StreamName=stream_name,)
|
||||
res = client.get_hls_streaming_session_url(
|
||||
StreamName=stream_name,
|
||||
)
|
||||
reg_exp = "^{}/hls/v1/getHLSMasterPlaylist.m3u8\?SessionToken\=.+$".format(
|
||||
data_endpoint
|
||||
)
|
||||
|
|
@ -48,7 +50,9 @@ def test_get_dash_streaming_session_url():
|
|||
region_name=region_name,
|
||||
endpoint_url=data_endpoint,
|
||||
)
|
||||
res = client.get_dash_streaming_session_url(StreamName=stream_name,)
|
||||
res = client.get_dash_streaming_session_url(
|
||||
StreamName=stream_name,
|
||||
)
|
||||
reg_exp = "^{}/dash/v1/getDASHManifest.mpd\?SessionToken\=.+$".format(data_endpoint)
|
||||
res.should.have.key("DASHStreamingSessionURL").which.should.match(reg_exp)
|
||||
|
||||
|
|
|
|||
|
|
@ -575,8 +575,10 @@ def test__delete_alias__raises_if_alias_is_not_found():
|
|||
with pytest.raises(NotFoundException) as err:
|
||||
kms.delete_alias(alias_name)
|
||||
|
||||
expected_message_match = r"Alias arn:aws:kms:{region}:[0-9]{{12}}:{alias_name} is not found.".format(
|
||||
region=region, alias_name=alias_name
|
||||
expected_message_match = (
|
||||
r"Alias arn:aws:kms:{region}:[0-9]{{12}}:{alias_name} is not found.".format(
|
||||
region=region, alias_name=alias_name
|
||||
)
|
||||
)
|
||||
ex = err.value
|
||||
ex.body["__type"].should.equal("NotFoundException")
|
||||
|
|
|
|||
|
|
@ -55,14 +55,20 @@ def test_create_key():
|
|||
key["KeyMetadata"]["Origin"].should.equal("AWS_KMS")
|
||||
key["KeyMetadata"].should_not.have.key("SigningAlgorithms")
|
||||
|
||||
key = conn.create_key(KeyUsage="ENCRYPT_DECRYPT", CustomerMasterKeySpec="RSA_2048",)
|
||||
key = conn.create_key(
|
||||
KeyUsage="ENCRYPT_DECRYPT",
|
||||
CustomerMasterKeySpec="RSA_2048",
|
||||
)
|
||||
|
||||
sorted(key["KeyMetadata"]["EncryptionAlgorithms"]).should.equal(
|
||||
["RSAES_OAEP_SHA_1", "RSAES_OAEP_SHA_256"]
|
||||
)
|
||||
key["KeyMetadata"].should_not.have.key("SigningAlgorithms")
|
||||
|
||||
key = conn.create_key(KeyUsage="SIGN_VERIFY", CustomerMasterKeySpec="RSA_2048",)
|
||||
key = conn.create_key(
|
||||
KeyUsage="SIGN_VERIFY",
|
||||
CustomerMasterKeySpec="RSA_2048",
|
||||
)
|
||||
|
||||
key["KeyMetadata"].should_not.have.key("EncryptionAlgorithms")
|
||||
sorted(key["KeyMetadata"]["SigningAlgorithms"]).should.equal(
|
||||
|
|
@ -77,21 +83,24 @@ def test_create_key():
|
|||
)
|
||||
|
||||
key = conn.create_key(
|
||||
KeyUsage="SIGN_VERIFY", CustomerMasterKeySpec="ECC_SECG_P256K1",
|
||||
KeyUsage="SIGN_VERIFY",
|
||||
CustomerMasterKeySpec="ECC_SECG_P256K1",
|
||||
)
|
||||
|
||||
key["KeyMetadata"].should_not.have.key("EncryptionAlgorithms")
|
||||
key["KeyMetadata"]["SigningAlgorithms"].should.equal(["ECDSA_SHA_256"])
|
||||
|
||||
key = conn.create_key(
|
||||
KeyUsage="SIGN_VERIFY", CustomerMasterKeySpec="ECC_NIST_P384",
|
||||
KeyUsage="SIGN_VERIFY",
|
||||
CustomerMasterKeySpec="ECC_NIST_P384",
|
||||
)
|
||||
|
||||
key["KeyMetadata"].should_not.have.key("EncryptionAlgorithms")
|
||||
key["KeyMetadata"]["SigningAlgorithms"].should.equal(["ECDSA_SHA_384"])
|
||||
|
||||
key = conn.create_key(
|
||||
KeyUsage="SIGN_VERIFY", CustomerMasterKeySpec="ECC_NIST_P521",
|
||||
KeyUsage="SIGN_VERIFY",
|
||||
CustomerMasterKeySpec="ECC_NIST_P521",
|
||||
)
|
||||
|
||||
key["KeyMetadata"].should_not.have.key("EncryptionAlgorithms")
|
||||
|
|
@ -101,7 +110,10 @@ def test_create_key():
|
|||
@mock_kms
|
||||
def test_describe_key():
|
||||
client = boto3.client("kms", region_name="us-east-1")
|
||||
response = client.create_key(Description="my key", KeyUsage="ENCRYPT_DECRYPT",)
|
||||
response = client.create_key(
|
||||
Description="my key",
|
||||
KeyUsage="ENCRYPT_DECRYPT",
|
||||
)
|
||||
key_id = response["KeyMetadata"]["KeyId"]
|
||||
|
||||
response = client.describe_key(KeyId=key_id)
|
||||
|
|
|
|||
|
|
@ -205,7 +205,8 @@ def test_delete_subscription_filter_errors():
|
|||
|
||||
# when
|
||||
client_logs.delete_subscription_filter(
|
||||
logGroupName="/test", filterName="test",
|
||||
logGroupName="/test",
|
||||
filterName="test",
|
||||
)
|
||||
|
||||
# then
|
||||
|
|
@ -243,7 +244,8 @@ def test_delete_subscription_filter_errors():
|
|||
# when
|
||||
with pytest.raises(ClientError) as e:
|
||||
client_logs.delete_subscription_filter(
|
||||
logGroupName="not-existing-log-group", filterName="test",
|
||||
logGroupName="not-existing-log-group",
|
||||
filterName="test",
|
||||
)
|
||||
|
||||
# then
|
||||
|
|
@ -258,7 +260,8 @@ def test_delete_subscription_filter_errors():
|
|||
# when
|
||||
with pytest.raises(ClientError) as e:
|
||||
client_logs.delete_subscription_filter(
|
||||
logGroupName="/test", filterName="wrong-filter-name",
|
||||
logGroupName="/test",
|
||||
filterName="wrong-filter-name",
|
||||
)
|
||||
|
||||
# then
|
||||
|
|
@ -342,7 +345,9 @@ def _get_role_name(region_name):
|
|||
return iam.get_role(RoleName="test-role")["Role"]["Arn"]
|
||||
except ClientError:
|
||||
return iam.create_role(
|
||||
RoleName="test-role", AssumeRolePolicyDocument="test policy", Path="/",
|
||||
RoleName="test-role",
|
||||
AssumeRolePolicyDocument="test policy",
|
||||
Path="/",
|
||||
)["Role"]["Arn"]
|
||||
|
||||
|
||||
|
|
@ -372,7 +377,8 @@ def _wait_for_log_msg(client, log_group_name, expected_msg_part):
|
|||
|
||||
for log_stream in log_streams:
|
||||
result = client.get_log_events(
|
||||
logGroupName=log_group_name, logStreamName=log_stream["logStreamName"],
|
||||
logGroupName=log_group_name,
|
||||
logStreamName=log_stream["logStreamName"],
|
||||
)
|
||||
received_messages.extend(
|
||||
[event["message"] for event in result.get("events")]
|
||||
|
|
|
|||
|
|
@ -448,7 +448,9 @@ def test_describe_subscription_filters_errors():
|
|||
|
||||
# when
|
||||
with pytest.raises(ClientError) as e:
|
||||
client.describe_subscription_filters(logGroupName="not-existing-log-group",)
|
||||
client.describe_subscription_filters(
|
||||
logGroupName="not-existing-log-group",
|
||||
)
|
||||
|
||||
# then
|
||||
ex = e.value
|
||||
|
|
|
|||
|
|
@ -183,7 +183,8 @@ def test_create_another_member_withopts():
|
|||
|
||||
# But cannot get
|
||||
response = conn.get_member.when.called_with(
|
||||
NetworkId=network_id, MemberId=member_id2,
|
||||
NetworkId=network_id,
|
||||
MemberId=member_id2,
|
||||
).should.throw(Exception, "Member {0} not found".format(member_id2))
|
||||
|
||||
# Delete member 1
|
||||
|
|
@ -255,7 +256,9 @@ def test_invite_and_remove_member():
|
|||
|
||||
# Create proposal (invite and remove member)
|
||||
response = conn.create_proposal(
|
||||
NetworkId=network_id, MemberId=member_id, Actions=both_policy_actions,
|
||||
NetworkId=network_id,
|
||||
MemberId=member_id,
|
||||
Actions=both_policy_actions,
|
||||
)
|
||||
proposal_id2 = response["ProposalId"]
|
||||
|
||||
|
|
@ -368,7 +371,10 @@ def test_create_too_many_members():
|
|||
MemberConfiguration=helpers.create_member_configuration(
|
||||
"testmember6", "admin", "Admin12345", False, "Test Member 6"
|
||||
),
|
||||
).should.throw(Exception, "is the maximum number of members allowed in a",)
|
||||
).should.throw(
|
||||
Exception,
|
||||
"is the maximum number of members allowed in a",
|
||||
)
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
|
|
@ -594,7 +600,8 @@ def test_get_member_badmember():
|
|||
network_id = response["NetworkId"]
|
||||
|
||||
response = conn.get_member.when.called_with(
|
||||
NetworkId=network_id, MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
NetworkId=network_id,
|
||||
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
).should.throw(Exception, "Member m-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
||||
|
||||
|
|
@ -624,7 +631,8 @@ def test_delete_member_badmember():
|
|||
network_id = response["NetworkId"]
|
||||
|
||||
response = conn.delete_member.when.called_with(
|
||||
NetworkId=network_id, MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
NetworkId=network_id,
|
||||
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
).should.throw(Exception, "Member m-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,9 @@ def test_create_node():
|
|||
|
||||
# Delete node
|
||||
conn.delete_node(
|
||||
NetworkId=network_id, MemberId=member_id, NodeId=node_id,
|
||||
NetworkId=network_id,
|
||||
MemberId=member_id,
|
||||
NodeId=node_id,
|
||||
)
|
||||
|
||||
# Find node in full list
|
||||
|
|
@ -77,7 +79,9 @@ def test_create_node():
|
|||
|
||||
# But cannot get
|
||||
response = conn.get_node.when.called_with(
|
||||
NetworkId=network_id, MemberId=member_id, NodeId=node_id,
|
||||
NetworkId=network_id,
|
||||
MemberId=member_id,
|
||||
NodeId=node_id,
|
||||
).should.throw(Exception, "Node {0} not found".format(node_id))
|
||||
|
||||
|
||||
|
|
@ -103,7 +107,9 @@ def test_create_node_standard_edition():
|
|||
logconfigbad = dict(helpers.default_nodeconfiguration)
|
||||
logconfigbad["InstanceType"] = "bc.t3.large"
|
||||
response = conn.create_node(
|
||||
NetworkId=network_id, MemberId=member_id, NodeConfiguration=logconfigbad,
|
||||
NetworkId=network_id,
|
||||
MemberId=member_id,
|
||||
NodeConfiguration=logconfigbad,
|
||||
)
|
||||
node_id = response["NodeId"]
|
||||
|
||||
|
|
@ -146,7 +152,8 @@ def test_create_node_standard_edition():
|
|||
|
||||
# Should now be an exception
|
||||
response = conn.list_nodes.when.called_with(
|
||||
NetworkId=network_id, MemberId=member_id,
|
||||
NetworkId=network_id,
|
||||
MemberId=member_id,
|
||||
).should.throw(Exception, "Member {0} not found".format(member_id))
|
||||
|
||||
|
||||
|
|
@ -192,7 +199,8 @@ def test_create_too_many_nodes():
|
|||
MemberId=member_id,
|
||||
NodeConfiguration=helpers.default_nodeconfiguration,
|
||||
).should.throw(
|
||||
Exception, "Maximum number of nodes exceeded in member {0}".format(member_id),
|
||||
Exception,
|
||||
"Maximum number of nodes exceeded in member {0}".format(member_id),
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -249,14 +257,18 @@ def test_create_node_badnodeconfig():
|
|||
logconfigbad = dict(helpers.default_nodeconfiguration)
|
||||
logconfigbad["InstanceType"] = "foo"
|
||||
response = conn.create_node.when.called_with(
|
||||
NetworkId=network_id, MemberId=member_id, NodeConfiguration=logconfigbad,
|
||||
NetworkId=network_id,
|
||||
MemberId=member_id,
|
||||
NodeConfiguration=logconfigbad,
|
||||
).should.throw(Exception, "Requested instance foo isn't supported.")
|
||||
|
||||
# Incorrect instance type for edition
|
||||
logconfigbad = dict(helpers.default_nodeconfiguration)
|
||||
logconfigbad["InstanceType"] = "bc.t3.large"
|
||||
response = conn.create_node.when.called_with(
|
||||
NetworkId=network_id, MemberId=member_id, NodeConfiguration=logconfigbad,
|
||||
NetworkId=network_id,
|
||||
MemberId=member_id,
|
||||
NodeConfiguration=logconfigbad,
|
||||
).should.throw(
|
||||
Exception,
|
||||
"Instance type bc.t3.large is not supported with STARTER Edition networks",
|
||||
|
|
@ -266,7 +278,9 @@ def test_create_node_badnodeconfig():
|
|||
logconfigbad = dict(helpers.default_nodeconfiguration)
|
||||
logconfigbad["AvailabilityZone"] = "us-east-11"
|
||||
response = conn.create_node.when.called_with(
|
||||
NetworkId=network_id, MemberId=member_id, NodeConfiguration=logconfigbad,
|
||||
NetworkId=network_id,
|
||||
MemberId=member_id,
|
||||
NodeConfiguration=logconfigbad,
|
||||
).should.throw(Exception, "Availability Zone is not valid")
|
||||
|
||||
|
||||
|
|
@ -296,7 +310,8 @@ def test_list_nodes_badmember():
|
|||
network_id = response["NetworkId"]
|
||||
|
||||
response = conn.list_nodes.when.called_with(
|
||||
NetworkId=network_id, MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
NetworkId=network_id,
|
||||
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
).should.throw(Exception, "Member m-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -131,7 +131,9 @@ def test_create_proposal_badinvitationacctid():
|
|||
member_id = response["MemberId"]
|
||||
|
||||
response = conn.create_proposal.when.called_with(
|
||||
NetworkId=network_id, MemberId=member_id, Actions=actions,
|
||||
NetworkId=network_id,
|
||||
MemberId=member_id,
|
||||
Actions=actions,
|
||||
).should.throw(Exception, "Account ID format specified in proposal is not valid")
|
||||
|
||||
|
||||
|
|
@ -155,7 +157,9 @@ def test_create_proposal_badremovalmemid():
|
|||
member_id = response["MemberId"]
|
||||
|
||||
response = conn.create_proposal.when.called_with(
|
||||
NetworkId=network_id, MemberId=member_id, Actions=actions,
|
||||
NetworkId=network_id,
|
||||
MemberId=member_id,
|
||||
Actions=actions,
|
||||
).should.throw(Exception, "Member ID format specified in proposal is not valid")
|
||||
|
||||
|
||||
|
|
@ -194,5 +198,6 @@ def test_get_proposal_badproposal():
|
|||
network_id = response["NetworkId"]
|
||||
|
||||
response = conn.get_proposal.when.called_with(
|
||||
NetworkId=network_id, ProposalId="p-ABCDEFGHIJKLMNOP0123456789",
|
||||
NetworkId=network_id,
|
||||
ProposalId="p-ABCDEFGHIJKLMNOP0123456789",
|
||||
).should.throw(Exception, "Proposal p-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
|
|
|||
|
|
@ -666,5 +666,6 @@ def test_list_proposal_votes_badproposal():
|
|||
member_id = response["MemberId"]
|
||||
|
||||
response = conn.list_proposal_votes.when.called_with(
|
||||
NetworkId=network_id, ProposalId="p-ABCDEFGHIJKLMNOP0123456789",
|
||||
NetworkId=network_id,
|
||||
ProposalId="p-ABCDEFGHIJKLMNOP0123456789",
|
||||
).should.throw(Exception, "Proposal p-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
|
|
|||
|
|
@ -931,7 +931,10 @@ def test_tag_resource_errors():
|
|||
|
||||
with pytest.raises(ClientError) as e:
|
||||
client.tag_resource(
|
||||
ResourceId="000000000000", Tags=[{"Key": "key", "Value": "value"},],
|
||||
ResourceId="000000000000",
|
||||
Tags=[
|
||||
{"Key": "key", "Value": "value"},
|
||||
],
|
||||
)
|
||||
ex = e.value
|
||||
ex.operation_name.should.equal("TagResource")
|
||||
|
|
|
|||
|
|
@ -48,8 +48,8 @@ else:
|
|||
|
||||
|
||||
def reduced_min_part_size(f):
|
||||
""" speed up tests by temporarily making the multipart minimum part size
|
||||
small
|
||||
"""speed up tests by temporarily making the multipart minimum part size
|
||||
small
|
||||
"""
|
||||
orig_size = s3model.UPLOAD_PART_MIN_SIZE
|
||||
|
||||
|
|
@ -1207,8 +1207,7 @@ if not settings.TEST_SERVER_MODE:
|
|||
with pytest.raises(ClientError) as ce:
|
||||
client.get_public_access_block(AccountId=ACCOUNT_ID)
|
||||
assert (
|
||||
ce.value.response["Error"]["Code"]
|
||||
== "NoSuchPublicAccessBlockConfiguration"
|
||||
ce.value.response["Error"]["Code"] == "NoSuchPublicAccessBlockConfiguration"
|
||||
)
|
||||
|
||||
# Put a with an invalid account ID:
|
||||
|
|
@ -1265,8 +1264,7 @@ if not settings.TEST_SERVER_MODE:
|
|||
with pytest.raises(ClientError) as ce:
|
||||
client.get_public_access_block(AccountId=ACCOUNT_ID)
|
||||
assert (
|
||||
ce.value.response["Error"]["Code"]
|
||||
== "NoSuchPublicAccessBlockConfiguration"
|
||||
ce.value.response["Error"]["Code"] == "NoSuchPublicAccessBlockConfiguration"
|
||||
)
|
||||
|
||||
@mock_s3
|
||||
|
|
@ -1465,9 +1463,7 @@ if not settings.TEST_SERVER_MODE:
|
|||
config_client.get_resource_config_history(
|
||||
resourceType="AWS::S3::AccountPublicAccessBlock", resourceId=ACCOUNT_ID
|
||||
)
|
||||
assert (
|
||||
ce.value.response["Error"]["Code"] == "ResourceNotDiscoveredException"
|
||||
)
|
||||
assert ce.value.response["Error"]["Code"] == "ResourceNotDiscoveredException"
|
||||
# aggregate
|
||||
result = config_client.batch_get_resource_config(
|
||||
resourceKeys=[
|
||||
|
|
@ -2402,7 +2398,9 @@ def test_boto3_get_object_if_match():
|
|||
|
||||
with pytest.raises(botocore.exceptions.ClientError) as err:
|
||||
s3.get_object(
|
||||
Bucket=bucket_name, Key=key, IfMatch='"hello"',
|
||||
Bucket=bucket_name,
|
||||
Key=key,
|
||||
IfMatch='"hello"',
|
||||
)
|
||||
e = err.value
|
||||
e.response["Error"]["Code"].should.equal("PreconditionFailed")
|
||||
|
|
@ -2421,7 +2419,9 @@ def test_boto3_get_object_if_none_match():
|
|||
|
||||
with pytest.raises(botocore.exceptions.ClientError) as err:
|
||||
s3.get_object(
|
||||
Bucket=bucket_name, Key=key, IfNoneMatch=etag,
|
||||
Bucket=bucket_name,
|
||||
Key=key,
|
||||
IfNoneMatch=etag,
|
||||
)
|
||||
e = err.value
|
||||
e.response["Error"].should.equal({"Code": "304", "Message": "Not Modified"})
|
||||
|
|
@ -2479,7 +2479,9 @@ def test_boto3_head_object_if_match():
|
|||
|
||||
with pytest.raises(botocore.exceptions.ClientError) as err:
|
||||
s3.head_object(
|
||||
Bucket=bucket_name, Key=key, IfMatch='"hello"',
|
||||
Bucket=bucket_name,
|
||||
Key=key,
|
||||
IfMatch='"hello"',
|
||||
)
|
||||
e = err.value
|
||||
e.response["Error"].should.equal({"Code": "412", "Message": "Precondition Failed"})
|
||||
|
|
@ -2497,7 +2499,9 @@ def test_boto3_head_object_if_none_match():
|
|||
|
||||
with pytest.raises(botocore.exceptions.ClientError) as err:
|
||||
s3.head_object(
|
||||
Bucket=bucket_name, Key=key, IfNoneMatch=etag,
|
||||
Bucket=bucket_name,
|
||||
Key=key,
|
||||
IfNoneMatch=etag,
|
||||
)
|
||||
e = err.value
|
||||
e.response["Error"].should.equal({"Code": "304", "Message": "Not Modified"})
|
||||
|
|
@ -3200,9 +3204,7 @@ def test_put_bucket_notification_errors():
|
|||
)
|
||||
|
||||
assert err.value.response["Error"]["Code"] == "InvalidArgument"
|
||||
assert (
|
||||
err.value.response["Error"]["Message"] == "The ARN is not well formed"
|
||||
)
|
||||
assert err.value.response["Error"]["Message"] == "The ARN is not well formed"
|
||||
|
||||
# Region not the same as the bucket:
|
||||
with pytest.raises(ClientError) as err:
|
||||
|
|
@ -4075,9 +4077,7 @@ def test_public_access_block():
|
|||
with pytest.raises(ClientError) as ce:
|
||||
client.get_public_access_block(Bucket="mybucket")
|
||||
|
||||
assert (
|
||||
ce.value.response["Error"]["Code"] == "NoSuchPublicAccessBlockConfiguration"
|
||||
)
|
||||
assert ce.value.response["Error"]["Code"] == "NoSuchPublicAccessBlockConfiguration"
|
||||
assert (
|
||||
ce.value.response["Error"]["Message"]
|
||||
== "The public access block configuration was not found"
|
||||
|
|
@ -4157,9 +4157,7 @@ def test_public_access_block():
|
|||
|
||||
with pytest.raises(ClientError) as ce:
|
||||
client.get_public_access_block(Bucket="mybucket")
|
||||
assert (
|
||||
ce.value.response["Error"]["Code"] == "NoSuchPublicAccessBlockConfiguration"
|
||||
)
|
||||
assert ce.value.response["Error"]["Code"] == "NoSuchPublicAccessBlockConfiguration"
|
||||
|
||||
|
||||
@mock_s3
|
||||
|
|
|
|||
|
|
@ -14,7 +14,12 @@ def test_s3_bucket_cloudformation_basic():
|
|||
|
||||
template = {
|
||||
"AWSTemplateFormatVersion": "2010-09-09",
|
||||
"Resources": {"testInstance": {"Type": "AWS::S3::Bucket", "Properties": {},}},
|
||||
"Resources": {
|
||||
"testInstance": {
|
||||
"Type": "AWS::S3::Bucket",
|
||||
"Properties": {},
|
||||
}
|
||||
},
|
||||
"Outputs": {"Bucket": {"Value": {"Ref": "testInstance"}}},
|
||||
}
|
||||
template_json = json.dumps(template)
|
||||
|
|
|
|||
|
|
@ -88,11 +88,15 @@ def test_delete_endpoint_config():
|
|||
resp = sagemaker.delete_endpoint_config(EndpointConfigName=endpoint_config_name)
|
||||
with pytest.raises(ClientError) as e:
|
||||
sagemaker.describe_endpoint_config(EndpointConfigName=endpoint_config_name)
|
||||
assert e.value.response["Error"]["Message"].startswith("Could not find endpoint configuration")
|
||||
assert e.value.response["Error"]["Message"].startswith(
|
||||
"Could not find endpoint configuration"
|
||||
)
|
||||
|
||||
with pytest.raises(ClientError) as e:
|
||||
sagemaker.delete_endpoint_config(EndpointConfigName=endpoint_config_name)
|
||||
assert e.value.response["Error"]["Message"].startswith( "Could not find endpoint configuration")
|
||||
assert e.value.response["Error"]["Message"].startswith(
|
||||
"Could not find endpoint configuration"
|
||||
)
|
||||
|
||||
|
||||
@mock_sagemaker
|
||||
|
|
@ -134,7 +138,9 @@ def test_create_endpoint():
|
|||
sagemaker.create_endpoint(
|
||||
EndpointName=endpoint_name, EndpointConfigName="NonexistentEndpointConfig"
|
||||
)
|
||||
assert e.value.response["Error"]["Message"].startswith("Could not find endpoint configuration")
|
||||
assert e.value.response["Error"]["Message"].startswith(
|
||||
"Could not find endpoint configuration"
|
||||
)
|
||||
|
||||
model_name = "MyModel"
|
||||
_create_model(sagemaker, model_name)
|
||||
|
|
|
|||
|
|
@ -49,8 +49,9 @@ def test_create_notebook_instance_minimal_params():
|
|||
assert resp["NotebookInstanceArn"].endswith(args["NotebookInstanceName"])
|
||||
assert resp["NotebookInstanceName"] == NAME_PARAM
|
||||
assert resp["NotebookInstanceStatus"] == "InService"
|
||||
assert resp["Url"] == \
|
||||
"{}.notebook.{}.sagemaker.aws".format(NAME_PARAM, TEST_REGION_NAME)
|
||||
assert resp["Url"] == "{}.notebook.{}.sagemaker.aws".format(
|
||||
NAME_PARAM, TEST_REGION_NAME
|
||||
)
|
||||
assert resp["InstanceType"] == INSTANCE_TYPE_PARAM
|
||||
assert resp["RoleArn"] == FAKE_ROLE_ARN
|
||||
assert isinstance(resp["LastModifiedTime"], datetime.datetime)
|
||||
|
|
@ -99,8 +100,9 @@ def test_create_notebook_instance_params():
|
|||
assert resp["NotebookInstanceArn"].endswith(args["NotebookInstanceName"])
|
||||
assert resp["NotebookInstanceName"] == NAME_PARAM
|
||||
assert resp["NotebookInstanceStatus"] == "InService"
|
||||
assert resp["Url"] == \
|
||||
"{}.notebook.{}.sagemaker.aws".format(NAME_PARAM, TEST_REGION_NAME)
|
||||
assert resp["Url"] == "{}.notebook.{}.sagemaker.aws".format(
|
||||
NAME_PARAM, TEST_REGION_NAME
|
||||
)
|
||||
assert resp["InstanceType"] == INSTANCE_TYPE_PARAM
|
||||
assert resp["RoleArn"] == FAKE_ROLE_ARN
|
||||
assert isinstance(resp["LastModifiedTime"], datetime.datetime)
|
||||
|
|
@ -111,8 +113,7 @@ def test_create_notebook_instance_params():
|
|||
assert resp["SubnetId"] == FAKE_SUBNET_ID
|
||||
assert resp["SecurityGroups"] == FAKE_SECURITY_GROUP_IDS
|
||||
assert resp["KmsKeyId"] == FAKE_KMS_KEY_ID
|
||||
assert resp["NotebookInstanceLifecycleConfigName"] == \
|
||||
FAKE_LIFECYCLE_CONFIG_NAME
|
||||
assert resp["NotebookInstanceLifecycleConfigName"] == FAKE_LIFECYCLE_CONFIG_NAME
|
||||
assert resp["AcceleratorTypes"] == ACCELERATOR_TYPES_PARAM
|
||||
assert resp["DefaultCodeRepository"] == FAKE_DEFAULT_CODE_REPO
|
||||
assert resp["AdditionalCodeRepositories"] == FAKE_ADDL_CODE_REPOS
|
||||
|
|
@ -135,9 +136,11 @@ def test_create_notebook_instance_bad_volume_size():
|
|||
}
|
||||
with pytest.raises(ParamValidationError) as ex:
|
||||
sagemaker.create_notebook_instance(**args)
|
||||
assert \
|
||||
ex.value.args[0] == \
|
||||
"Parameter validation failed:\nInvalid range for parameter VolumeSizeInGB, value: {}, valid range: 5-inf".format(vol_size)
|
||||
assert ex.value.args[
|
||||
0
|
||||
] == "Parameter validation failed:\nInvalid range for parameter VolumeSizeInGB, value: {}, valid range: 5-inf".format(
|
||||
vol_size
|
||||
)
|
||||
|
||||
|
||||
@mock_sagemaker
|
||||
|
|
@ -238,17 +241,15 @@ def test_notebook_instance_lifecycle_config():
|
|||
OnCreate=on_create,
|
||||
OnStart=on_start,
|
||||
)
|
||||
assert \
|
||||
e.value.response["Error"]["Message"].endswith(
|
||||
"Notebook Instance Lifecycle Config already exists.)"
|
||||
)
|
||||
assert e.value.response["Error"]["Message"].endswith(
|
||||
"Notebook Instance Lifecycle Config already exists.)"
|
||||
)
|
||||
|
||||
resp = sagemaker.describe_notebook_instance_lifecycle_config(
|
||||
NotebookInstanceLifecycleConfigName=name,
|
||||
)
|
||||
assert resp["NotebookInstanceLifecycleConfigName"] == name
|
||||
assert \
|
||||
resp["NotebookInstanceLifecycleConfigArn"].startswith("arn:aws:sagemaker")
|
||||
assert resp["NotebookInstanceLifecycleConfigArn"].startswith("arn:aws:sagemaker")
|
||||
assert resp["NotebookInstanceLifecycleConfigArn"].endswith(name)
|
||||
assert resp["OnStart"] == on_start
|
||||
assert resp["OnCreate"] == on_create
|
||||
|
|
@ -263,16 +264,14 @@ def test_notebook_instance_lifecycle_config():
|
|||
sagemaker.describe_notebook_instance_lifecycle_config(
|
||||
NotebookInstanceLifecycleConfigName=name,
|
||||
)
|
||||
assert \
|
||||
e.value.response["Error"]["Message"].endswith(
|
||||
"Notebook Instance Lifecycle Config does not exist.)"
|
||||
)
|
||||
assert e.value.response["Error"]["Message"].endswith(
|
||||
"Notebook Instance Lifecycle Config does not exist.)"
|
||||
)
|
||||
|
||||
with pytest.raises(ClientError) as e:
|
||||
sagemaker.delete_notebook_instance_lifecycle_config(
|
||||
NotebookInstanceLifecycleConfigName=name,
|
||||
)
|
||||
assert \
|
||||
e.value.response["Error"]["Message"].endswith(
|
||||
"Notebook Instance Lifecycle Config does not exist.)"
|
||||
)
|
||||
assert e.value.response["Error"]["Message"].endswith(
|
||||
"Notebook Instance Lifecycle Config does not exist.)"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -82,20 +82,21 @@ def test_create_training_job():
|
|||
r"^arn:aws:sagemaker:.*:.*:training-job/{}$".format(training_job_name)
|
||||
)
|
||||
assert resp["ModelArtifacts"]["S3ModelArtifacts"].startswith(
|
||||
params["OutputDataConfig"]["S3OutputPath"]
|
||||
)
|
||||
params["OutputDataConfig"]["S3OutputPath"]
|
||||
)
|
||||
assert training_job_name in (resp["ModelArtifacts"]["S3ModelArtifacts"])
|
||||
assert \
|
||||
resp["ModelArtifacts"]["S3ModelArtifacts"].endswith("output/model.tar.gz")
|
||||
assert resp["ModelArtifacts"]["S3ModelArtifacts"].endswith("output/model.tar.gz")
|
||||
assert resp["TrainingJobStatus"] == "Completed"
|
||||
assert resp["SecondaryStatus"] == "Completed"
|
||||
assert resp["HyperParameters"] == params["HyperParameters"]
|
||||
assert \
|
||||
resp["AlgorithmSpecification"]["TrainingImage"] == \
|
||||
params["AlgorithmSpecification"]["TrainingImage"]
|
||||
assert \
|
||||
resp["AlgorithmSpecification"]["TrainingInputMode"] == \
|
||||
params["AlgorithmSpecification"]["TrainingInputMode"]
|
||||
assert (
|
||||
resp["AlgorithmSpecification"]["TrainingImage"]
|
||||
== params["AlgorithmSpecification"]["TrainingImage"]
|
||||
)
|
||||
assert (
|
||||
resp["AlgorithmSpecification"]["TrainingInputMode"]
|
||||
== params["AlgorithmSpecification"]["TrainingInputMode"]
|
||||
)
|
||||
assert "MetricDefinitions" in resp["AlgorithmSpecification"]
|
||||
assert "Name" in resp["AlgorithmSpecification"]["MetricDefinitions"][0]
|
||||
assert "Regex" in resp["AlgorithmSpecification"]["MetricDefinitions"][0]
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ def test_with_all_filter():
|
|||
secrets = conn.list_secrets(Filters=[{"Key": "all", "Values": ["foo"]}])
|
||||
|
||||
secret_names = list(map(lambda s: s["Name"], secrets["SecretList"]))
|
||||
assert sorted(secret_names) == ['bar', 'baz', 'foo', 'multi', 'qux']
|
||||
assert sorted(secret_names) == ["bar", "baz", "foo", "multi", "qux"]
|
||||
|
||||
|
||||
@mock_secretsmanager
|
||||
|
|
|
|||
|
|
@ -56,9 +56,10 @@ def test_get_secret_that_does_not_exist():
|
|||
with pytest.raises(ClientError) as cm:
|
||||
result = conn.get_secret_value(SecretId="i-dont-exist")
|
||||
|
||||
assert \
|
||||
"Secrets Manager can't find the specified secret." == \
|
||||
cm.value.response["Error"]["Message"]
|
||||
assert (
|
||||
"Secrets Manager can't find the specified secret."
|
||||
== cm.value.response["Error"]["Message"]
|
||||
)
|
||||
|
||||
|
||||
@mock_secretsmanager
|
||||
|
|
@ -71,9 +72,10 @@ def test_get_secret_that_does_not_match():
|
|||
with pytest.raises(ClientError) as cm:
|
||||
result = conn.get_secret_value(SecretId="i-dont-match")
|
||||
|
||||
assert \
|
||||
"Secrets Manager can't find the specified secret." == \
|
||||
cm.value.response["Error"]["Message"]
|
||||
assert (
|
||||
"Secrets Manager can't find the specified secret."
|
||||
== cm.value.response["Error"]["Message"]
|
||||
)
|
||||
|
||||
|
||||
@mock_secretsmanager
|
||||
|
|
@ -97,9 +99,10 @@ def test_get_secret_that_has_no_value():
|
|||
with pytest.raises(ClientError) as cm:
|
||||
result = conn.get_secret_value(SecretId="java-util-test-password")
|
||||
|
||||
assert \
|
||||
"Secrets Manager can't find the specified secret value for staging label: AWSCURRENT" == \
|
||||
cm.value.response["Error"]["Message"]
|
||||
assert (
|
||||
"Secrets Manager can't find the specified secret value for staging label: AWSCURRENT"
|
||||
== cm.value.response["Error"]["Message"]
|
||||
)
|
||||
|
||||
|
||||
@mock_secretsmanager
|
||||
|
|
@ -113,11 +116,10 @@ def test_get_secret_version_that_does_not_exist():
|
|||
with pytest.raises(ClientError) as cm:
|
||||
conn.get_secret_value(SecretId=secret_arn, VersionId=missing_version_id)
|
||||
|
||||
assert \
|
||||
(
|
||||
"An error occurred (ResourceNotFoundException) when calling the GetSecretValue operation: Secrets "
|
||||
"Manager can't find the specified secret value for VersionId: 00000000-0000-0000-0000-000000000000"
|
||||
) == cm.value.response["Error"]["Message"]
|
||||
assert (
|
||||
"An error occurred (ResourceNotFoundException) when calling the GetSecretValue operation: Secrets "
|
||||
"Manager can't find the specified secret value for VersionId: 00000000-0000-0000-0000-000000000000"
|
||||
) == cm.value.response["Error"]["Message"]
|
||||
|
||||
|
||||
@mock_secretsmanager
|
||||
|
|
@ -879,9 +881,10 @@ def test_update_secret_which_does_not_exit():
|
|||
SecretId="test-secret", SecretString="barsecret"
|
||||
)
|
||||
|
||||
assert \
|
||||
"Secrets Manager can't find the specified secret." == \
|
||||
cm.value.response["Error"]["Message"]
|
||||
assert (
|
||||
"Secrets Manager can't find the specified secret."
|
||||
== cm.value.response["Error"]["Message"]
|
||||
)
|
||||
|
||||
|
||||
@mock_secretsmanager
|
||||
|
|
@ -897,8 +900,7 @@ def test_update_secret_marked_as_deleted():
|
|||
)
|
||||
|
||||
assert (
|
||||
"because it was marked for deletion."
|
||||
in cm.value.response["Error"]["Message"]
|
||||
"because it was marked for deletion." in cm.value.response["Error"]["Message"]
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -924,11 +926,17 @@ def test_tag_resource():
|
|||
conn = boto3.client("secretsmanager", region_name="us-west-2")
|
||||
conn.create_secret(Name="test-secret", SecretString="foosecret")
|
||||
conn.tag_resource(
|
||||
SecretId="test-secret", Tags=[{"Key": "FirstTag", "Value": "SomeValue"},],
|
||||
SecretId="test-secret",
|
||||
Tags=[
|
||||
{"Key": "FirstTag", "Value": "SomeValue"},
|
||||
],
|
||||
)
|
||||
|
||||
conn.tag_resource(
|
||||
SecretId="test-secret", Tags=[{"Key": "SecondTag", "Value": "AnotherValue"},],
|
||||
SecretId="test-secret",
|
||||
Tags=[
|
||||
{"Key": "SecondTag", "Value": "AnotherValue"},
|
||||
],
|
||||
)
|
||||
|
||||
secrets = conn.list_secrets()
|
||||
|
|
@ -940,7 +948,9 @@ def test_tag_resource():
|
|||
with assert_raises(ClientError) as cm:
|
||||
conn.tag_resource(
|
||||
SecretId="dummy-test-secret",
|
||||
Tags=[{"Key": "FirstTag", "Value": "SomeValue"},],
|
||||
Tags=[
|
||||
{"Key": "FirstTag", "Value": "SomeValue"},
|
||||
],
|
||||
)
|
||||
|
||||
assert_equal(
|
||||
|
|
|
|||
|
|
@ -89,9 +89,10 @@ def test_get_secret_that_has_no_value():
|
|||
)
|
||||
|
||||
json_data = json.loads(get_secret.data.decode("utf-8"))
|
||||
assert \
|
||||
json_data["message"] == \
|
||||
"Secrets Manager can't find the specified secret value for staging label: AWSCURRENT"
|
||||
assert (
|
||||
json_data["message"]
|
||||
== "Secrets Manager can't find the specified secret value for staging label: AWSCURRENT"
|
||||
)
|
||||
assert json_data["__type"] == "ResourceNotFoundException"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -89,7 +89,9 @@ def test_send_email_when_verify_source():
|
|||
conn = boto3.client("ses", region_name="us-east-1")
|
||||
|
||||
kwargs = dict(
|
||||
Destination={"ToAddresses": ["test_to@example.com"],},
|
||||
Destination={
|
||||
"ToAddresses": ["test_to@example.com"],
|
||||
},
|
||||
Message={
|
||||
"Subject": {"Data": "test subject"},
|
||||
"Body": {"Text": {"Data": "test body"}},
|
||||
|
|
@ -276,7 +278,16 @@ def test_send_email_notification_with_encoded_sender():
|
|||
response = conn.send_email(
|
||||
Source=sender,
|
||||
Destination={"ToAddresses": ["your.friend@hotmail.com"]},
|
||||
Message={"Subject": {"Data": "hi",}, "Body": {"Text": {"Data": "there",}}},
|
||||
Message={
|
||||
"Subject": {
|
||||
"Data": "hi",
|
||||
},
|
||||
"Body": {
|
||||
"Text": {
|
||||
"Data": "there",
|
||||
}
|
||||
},
|
||||
},
|
||||
)
|
||||
response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
||||
|
||||
|
|
@ -291,7 +302,9 @@ def test_create_configuration_set():
|
|||
EventDestination={
|
||||
"Name": "snsEvent",
|
||||
"Enabled": True,
|
||||
"MatchingEventTypes": ["send",],
|
||||
"MatchingEventTypes": [
|
||||
"send",
|
||||
],
|
||||
"SNSDestination": {
|
||||
"TopicARN": "arn:aws:sns:us-east-1:123456789012:myTopic"
|
||||
},
|
||||
|
|
@ -304,7 +317,9 @@ def test_create_configuration_set():
|
|||
EventDestination={
|
||||
"Name": "snsEvent",
|
||||
"Enabled": True,
|
||||
"MatchingEventTypes": ["send",],
|
||||
"MatchingEventTypes": [
|
||||
"send",
|
||||
],
|
||||
"SNSDestination": {
|
||||
"TopicARN": "arn:aws:sns:us-east-1:123456789012:myTopic"
|
||||
},
|
||||
|
|
@ -319,7 +334,9 @@ def test_create_configuration_set():
|
|||
EventDestination={
|
||||
"Name": "snsEvent",
|
||||
"Enabled": True,
|
||||
"MatchingEventTypes": ["send",],
|
||||
"MatchingEventTypes": [
|
||||
"send",
|
||||
],
|
||||
"SNSDestination": {
|
||||
"TopicARN": "arn:aws:sns:us-east-1:123456789012:myTopic"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -152,7 +152,9 @@ def test_publish_to_sqs_msg_attr_byte_value():
|
|||
sqs = boto3.resource("sqs", region_name="us-east-1")
|
||||
queue = sqs.create_queue(QueueName="test-queue")
|
||||
conn.subscribe(
|
||||
TopicArn=topic_arn, Protocol="sqs", Endpoint=queue.attributes["QueueArn"],
|
||||
TopicArn=topic_arn,
|
||||
Protocol="sqs",
|
||||
Endpoint=queue.attributes["QueueArn"],
|
||||
)
|
||||
queue_raw = sqs.create_queue(QueueName="test-queue-raw")
|
||||
conn.subscribe(
|
||||
|
|
|
|||
|
|
@ -525,7 +525,9 @@ def test_untag_resource_error():
|
|||
@mock_sns
|
||||
def test_topic_kms_master_key_id_attribute():
|
||||
client = boto3.client("sns", region_name="us-west-2")
|
||||
resp = client.create_topic(Name="test-sns-no-key-attr",)
|
||||
resp = client.create_topic(
|
||||
Name="test-sns-no-key-attr",
|
||||
)
|
||||
topic_arn = resp["TopicArn"]
|
||||
resp = client.get_topic_attributes(TopicArn=topic_arn)
|
||||
resp["Attributes"].should_not.have.key("KmsMasterKeyId")
|
||||
|
|
@ -538,7 +540,10 @@ def test_topic_kms_master_key_id_attribute():
|
|||
resp["Attributes"]["KmsMasterKeyId"].should.equal("test-key")
|
||||
|
||||
resp = client.create_topic(
|
||||
Name="test-sns-with-key-attr", Attributes={"KmsMasterKeyId": "key-id",}
|
||||
Name="test-sns-with-key-attr",
|
||||
Attributes={
|
||||
"KmsMasterKeyId": "key-id",
|
||||
},
|
||||
)
|
||||
topic_arn = resp["TopicArn"]
|
||||
resp = client.get_topic_attributes(TopicArn=topic_arn)
|
||||
|
|
|
|||
|
|
@ -719,7 +719,10 @@ def test_send_receive_message_with_attributes_with_labels():
|
|||
response = queue.send_message(
|
||||
MessageBody="test message",
|
||||
MessageAttributes={
|
||||
"somevalue": {"StringValue": "somevalue", "DataType": "String.custom",}
|
||||
"somevalue": {
|
||||
"StringValue": "somevalue",
|
||||
"DataType": "String.custom",
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
|
|
@ -2242,7 +2245,9 @@ def test_invoke_function_from_sqs_exception():
|
|||
@mock_sqs
|
||||
def test_maximum_message_size_attribute_default():
|
||||
sqs = boto3.resource("sqs", region_name="eu-west-3")
|
||||
queue = sqs.create_queue(QueueName="test-queue",)
|
||||
queue = sqs.create_queue(
|
||||
QueueName="test-queue",
|
||||
)
|
||||
int(queue.attributes["MaximumMessageSize"]).should.equal(MAXIMUM_MESSAGE_LENGTH)
|
||||
with assert_raises(Exception) as e:
|
||||
queue.send_message(MessageBody="a" * (MAXIMUM_MESSAGE_LENGTH + 1))
|
||||
|
|
|
|||
|
|
@ -309,25 +309,29 @@ def test_put_parameter_invalid_names():
|
|||
client.put_parameter.when.called_with(
|
||||
Name="ssm_test", Value="value", Type="String"
|
||||
).should.throw(
|
||||
ClientError, invalid_prefix_err,
|
||||
ClientError,
|
||||
invalid_prefix_err,
|
||||
)
|
||||
|
||||
client.put_parameter.when.called_with(
|
||||
Name="SSM_TEST", Value="value", Type="String"
|
||||
).should.throw(
|
||||
ClientError, invalid_prefix_err,
|
||||
ClientError,
|
||||
invalid_prefix_err,
|
||||
)
|
||||
|
||||
client.put_parameter.when.called_with(
|
||||
Name="aws_test", Value="value", Type="String"
|
||||
).should.throw(
|
||||
ClientError, invalid_prefix_err,
|
||||
ClientError,
|
||||
invalid_prefix_err,
|
||||
)
|
||||
|
||||
client.put_parameter.when.called_with(
|
||||
Name="AWS_TEST", Value="value", Type="String"
|
||||
).should.throw(
|
||||
ClientError, invalid_prefix_err,
|
||||
ClientError,
|
||||
invalid_prefix_err,
|
||||
)
|
||||
|
||||
ssm_path = "/ssm_test/path/to/var"
|
||||
|
|
@ -354,14 +358,16 @@ def test_put_parameter_invalid_names():
|
|||
client.put_parameter.when.called_with(
|
||||
Name=aws_path, Value="value", Type="String"
|
||||
).should.throw(
|
||||
ClientError, "No access to reserved parameter name: {}.".format(aws_path),
|
||||
ClientError,
|
||||
"No access to reserved parameter name: {}.".format(aws_path),
|
||||
)
|
||||
|
||||
aws_path = "/AWS/PATH/TO/VAR"
|
||||
client.put_parameter.when.called_with(
|
||||
Name=aws_path, Value="value", Type="String"
|
||||
).should.throw(
|
||||
ClientError, "No access to reserved parameter name: {}.".format(aws_path),
|
||||
ClientError,
|
||||
"No access to reserved parameter name: {}.".format(aws_path),
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -448,9 +454,7 @@ def test_get_parameter_with_version_and_labels():
|
|||
with pytest.raises(ClientError) as ex:
|
||||
client.get_parameter(Name="test-2:2", WithDecryption=False)
|
||||
ex.value.response["Error"]["Code"].should.equal("ParameterNotFound")
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"Parameter test-2:2 not found."
|
||||
)
|
||||
ex.value.response["Error"]["Message"].should.equal("Parameter test-2:2 not found.")
|
||||
|
||||
|
||||
@mock_ssm
|
||||
|
|
|
|||
|
|
@ -356,8 +356,10 @@ def test_state_machine_can_deleted_nonexisting_machine():
|
|||
@mock_stepfunctions
|
||||
def test_state_machine_tagging_non_existent_resource_fails():
|
||||
client = boto3.client("stepfunctions", region_name=region)
|
||||
non_existent_arn = "arn:aws:states:{region}:{account}:stateMachine:non-existent".format(
|
||||
region=region, account=ACCOUNT_ID
|
||||
non_existent_arn = (
|
||||
"arn:aws:states:{region}:{account}:stateMachine:non-existent".format(
|
||||
region=region, account=ACCOUNT_ID
|
||||
)
|
||||
)
|
||||
with assert_raises(ClientError) as ex:
|
||||
client.tag_resource(resourceArn=non_existent_arn, tags=[])
|
||||
|
|
@ -368,8 +370,10 @@ def test_state_machine_tagging_non_existent_resource_fails():
|
|||
@mock_stepfunctions
|
||||
def test_state_machine_untagging_non_existent_resource_fails():
|
||||
client = boto3.client("stepfunctions", region_name=region)
|
||||
non_existent_arn = "arn:aws:states:{region}:{account}:stateMachine:non-existent".format(
|
||||
region=region, account=ACCOUNT_ID
|
||||
non_existent_arn = (
|
||||
"arn:aws:states:{region}:{account}:stateMachine:non-existent".format(
|
||||
region=region, account=ACCOUNT_ID
|
||||
)
|
||||
)
|
||||
with assert_raises(ClientError) as ex:
|
||||
client.untag_resource(resourceArn=non_existent_arn, tagKeys=[])
|
||||
|
|
@ -386,7 +390,9 @@ def test_state_machine_tagging():
|
|||
{"key": "tag_key2", "value": "tag_value2"},
|
||||
]
|
||||
machine = client.create_state_machine(
|
||||
name="test", definition=str(simple_definition), roleArn=_get_default_role(),
|
||||
name="test",
|
||||
definition=str(simple_definition),
|
||||
roleArn=_get_default_role(),
|
||||
)
|
||||
client.tag_resource(resourceArn=machine["stateMachineArn"], tags=tags)
|
||||
resp = client.list_tags_for_resource(resourceArn=machine["stateMachineArn"])
|
||||
|
|
|
|||
|
|
@ -17,7 +17,9 @@ def test_run_medical_transcription_job_minimal_params():
|
|||
args = {
|
||||
"MedicalTranscriptionJobName": job_name,
|
||||
"LanguageCode": "en-US",
|
||||
"Media": {"MediaFileUri": "s3://my-bucket/my-media-file.wav",},
|
||||
"Media": {
|
||||
"MediaFileUri": "s3://my-bucket/my-media-file.wav",
|
||||
},
|
||||
"OutputBucketName": "my-output-bucket",
|
||||
"Specialty": "PRIMARYCARE",
|
||||
"Type": "CONVERSATION",
|
||||
|
|
@ -98,7 +100,9 @@ def test_run_medical_transcription_job_all_params():
|
|||
"LanguageCode": "en-US",
|
||||
"MediaSampleRateHertz": 48000,
|
||||
"MediaFormat": "flac",
|
||||
"Media": {"MediaFileUri": "s3://my-bucket/my-media-file.dat",},
|
||||
"Media": {
|
||||
"MediaFileUri": "s3://my-bucket/my-media-file.dat",
|
||||
},
|
||||
"OutputBucketName": "my-output-bucket",
|
||||
"OutputEncryptionKMSKeyId": "arn:aws:kms:us-east-1:012345678901:key/37111b5e-8eff-4706-ae3a-d4f9d1d559fc",
|
||||
"Settings": {
|
||||
|
|
@ -199,7 +203,9 @@ def test_run_medical_transcription_job_with_existing_job_name():
|
|||
args = {
|
||||
"MedicalTranscriptionJobName": job_name,
|
||||
"LanguageCode": "en-US",
|
||||
"Media": {"MediaFileUri": "s3://my-bucket/my-media-file.wav",},
|
||||
"Media": {
|
||||
"MediaFileUri": "s3://my-bucket/my-media-file.wav",
|
||||
},
|
||||
"OutputBucketName": "my-output-bucket",
|
||||
"Specialty": "PRIMARYCARE",
|
||||
"Type": "CONVERSATION",
|
||||
|
|
@ -222,7 +228,9 @@ def test_run_medical_transcription_job_nonexistent_vocabulary():
|
|||
args = {
|
||||
"MedicalTranscriptionJobName": job_name,
|
||||
"LanguageCode": "en-US",
|
||||
"Media": {"MediaFileUri": "s3://my-bucket/my-media-file.dat",},
|
||||
"Media": {
|
||||
"MediaFileUri": "s3://my-bucket/my-media-file.dat",
|
||||
},
|
||||
"OutputBucketName": "my-output-bucket",
|
||||
"Settings": {"VocabularyName": "NonexistentVocabulary"},
|
||||
"Specialty": "PRIMARYCARE",
|
||||
|
|
@ -244,7 +252,9 @@ def test_list_medical_transcription_jobs():
|
|||
args = {
|
||||
"MedicalTranscriptionJobName": job_name,
|
||||
"LanguageCode": "en-US",
|
||||
"Media": {"MediaFileUri": "s3://my-bucket/my-media-file.wav",},
|
||||
"Media": {
|
||||
"MediaFileUri": "s3://my-bucket/my-media-file.wav",
|
||||
},
|
||||
"OutputBucketName": "my-output-bucket",
|
||||
"Specialty": "PRIMARYCARE",
|
||||
"Type": "CONVERSATION",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue