Merge branch 'master' of github.com:spulec/moto
This commit is contained in:
commit
f7acdb9b3a
13 changed files with 371 additions and 11 deletions
|
|
@ -3634,6 +3634,31 @@ def test_update_supports_list_append_with_nested_if_not_exists_operation():
|
|||
)
|
||||
|
||||
|
||||
@mock_dynamodb2
|
||||
def test_update_supports_list_append_with_nested_if_not_exists_operation_and_property_already_exists():
|
||||
dynamo = boto3.resource("dynamodb", region_name="us-west-1")
|
||||
table_name = "test"
|
||||
|
||||
dynamo.create_table(
|
||||
TableName=table_name,
|
||||
AttributeDefinitions=[{"AttributeName": "Id", "AttributeType": "S"}],
|
||||
KeySchema=[{"AttributeName": "Id", "KeyType": "HASH"}],
|
||||
ProvisionedThroughput={"ReadCapacityUnits": 20, "WriteCapacityUnits": 20},
|
||||
)
|
||||
|
||||
table = dynamo.Table(table_name)
|
||||
|
||||
table.put_item(Item={"Id": "item-id", "event_history": ["other_value"]})
|
||||
table.update_item(
|
||||
Key={"Id": "item-id"},
|
||||
UpdateExpression="SET event_history = list_append(if_not_exists(event_history, :empty_list), :new_value)",
|
||||
ExpressionAttributeValues={":empty_list": [], ":new_value": ["some_value"]},
|
||||
)
|
||||
table.get_item(Key={"Id": "item-id"})["Item"].should.equal(
|
||||
{"Id": "item-id", "event_history": ["other_value", "some_value"]}
|
||||
)
|
||||
|
||||
|
||||
@mock_dynamodb2
|
||||
def test_update_catches_invalid_list_append_operation():
|
||||
client = boto3.client("dynamodb", region_name="us-east-1")
|
||||
|
|
|
|||
|
|
@ -753,6 +753,79 @@ def test_change_weighted_resource_record_sets():
|
|||
record["Weight"].should.equal(10)
|
||||
|
||||
|
||||
@mock_route53
|
||||
def test_failover_record_sets():
|
||||
conn = boto3.client("route53", region_name="us-east-2")
|
||||
conn.create_hosted_zone(Name="test.zone.", CallerReference=str(hash("test")))
|
||||
zones = conn.list_hosted_zones_by_name(DNSName="test.zone.")
|
||||
hosted_zone_id = zones["HostedZones"][0]["Id"]
|
||||
|
||||
# Create geolocation record
|
||||
conn.change_resource_record_sets(
|
||||
HostedZoneId=hosted_zone_id,
|
||||
ChangeBatch={
|
||||
"Changes": [
|
||||
{
|
||||
"Action": "CREATE",
|
||||
"ResourceRecordSet": {
|
||||
"Name": "failover.test.zone.",
|
||||
"Type": "A",
|
||||
"TTL": 10,
|
||||
"ResourceRecords": [{"Value": "127.0.0.1"}],
|
||||
"Failover": "PRIMARY",
|
||||
},
|
||||
}
|
||||
]
|
||||
},
|
||||
)
|
||||
|
||||
response = conn.list_resource_record_sets(HostedZoneId=hosted_zone_id)
|
||||
record = response["ResourceRecordSets"][0]
|
||||
record["Failover"].should.equal("PRIMARY")
|
||||
|
||||
|
||||
@mock_route53
|
||||
def test_geolocation_record_sets():
|
||||
conn = boto3.client("route53", region_name="us-east-2")
|
||||
conn.create_hosted_zone(Name="test.zone.", CallerReference=str(hash("test")))
|
||||
zones = conn.list_hosted_zones_by_name(DNSName="test.zone.")
|
||||
hosted_zone_id = zones["HostedZones"][0]["Id"]
|
||||
|
||||
# Create geolocation record
|
||||
conn.change_resource_record_sets(
|
||||
HostedZoneId=hosted_zone_id,
|
||||
ChangeBatch={
|
||||
"Changes": [
|
||||
{
|
||||
"Action": "CREATE",
|
||||
"ResourceRecordSet": {
|
||||
"Name": "georecord1.test.zone.",
|
||||
"Type": "A",
|
||||
"TTL": 10,
|
||||
"ResourceRecords": [{"Value": "127.0.0.1"}],
|
||||
"GeoLocation": {"ContinentCode": "EU"},
|
||||
},
|
||||
},
|
||||
{
|
||||
"Action": "CREATE",
|
||||
"ResourceRecordSet": {
|
||||
"Name": "georecord2.test.zone.",
|
||||
"Type": "A",
|
||||
"TTL": 10,
|
||||
"ResourceRecords": [{"Value": "127.0.0.2"}],
|
||||
"GeoLocation": {"CountryCode": "US", "SubdivisionCode": "NY"},
|
||||
},
|
||||
},
|
||||
]
|
||||
},
|
||||
)
|
||||
|
||||
response = conn.list_resource_record_sets(HostedZoneId=hosted_zone_id)
|
||||
rrs = response["ResourceRecordSets"]
|
||||
rrs[0]["GeoLocation"].should.equal({"ContinentCode": "EU"})
|
||||
rrs[1]["GeoLocation"].should.equal({"CountryCode": "US", "SubdivisionCode": "NY"})
|
||||
|
||||
|
||||
@mock_route53
|
||||
def test_change_resource_record_invalid():
|
||||
conn = boto3.client("route53", region_name="us-east-1")
|
||||
|
|
|
|||
|
|
@ -30,6 +30,18 @@ def test_delete_parameter():
|
|||
len(response["Parameters"]).should.equal(0)
|
||||
|
||||
|
||||
@mock_ssm
|
||||
def test_delete_nonexistent_parameter():
|
||||
client = boto3.client("ssm", region_name="us-east-1")
|
||||
|
||||
with assert_raises(ClientError) as ex:
|
||||
client.delete_parameter(Name="test_noexist")
|
||||
ex.exception.response["Error"]["Code"].should.equal("ParameterNotFound")
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
"Parameter test_noexist not found."
|
||||
)
|
||||
|
||||
|
||||
@mock_ssm
|
||||
def test_delete_parameters():
|
||||
client = boto3.client("ssm", region_name="us-east-1")
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
import boto
|
||||
from boto.swf.exceptions import SWFResponseError
|
||||
import boto3
|
||||
from botocore.exceptions import ClientError
|
||||
import sure # noqa
|
||||
|
||||
from moto import mock_swf_deprecated
|
||||
from moto import mock_swf
|
||||
|
||||
|
||||
# RegisterActivityType endpoint
|
||||
|
|
@ -110,6 +113,77 @@ def test_deprecate_non_existent_activity_type():
|
|||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
# DeprecateActivityType endpoint
|
||||
@mock_swf
|
||||
def test_undeprecate_activity_type():
|
||||
client = boto3.client("swf", region_name="us-east-1")
|
||||
client.register_domain(
|
||||
name="test-domain", workflowExecutionRetentionPeriodInDays="60"
|
||||
)
|
||||
client.register_activity_type(
|
||||
domain="test-domain", name="test-activity", version="v1.0"
|
||||
)
|
||||
client.deprecate_activity_type(
|
||||
domain="test-domain", activityType={"name": "test-activity", "version": "v1.0"}
|
||||
)
|
||||
client.undeprecate_activity_type(
|
||||
domain="test-domain", activityType={"name": "test-activity", "version": "v1.0"}
|
||||
)
|
||||
|
||||
resp = client.describe_activity_type(
|
||||
domain="test-domain", activityType={"name": "test-activity", "version": "v1.0"}
|
||||
)
|
||||
resp["typeInfo"]["status"].should.equal("REGISTERED")
|
||||
|
||||
|
||||
@mock_swf
|
||||
def test_undeprecate_already_undeprecated_activity_type():
|
||||
client = boto3.client("swf", region_name="us-east-1")
|
||||
client.register_domain(
|
||||
name="test-domain", workflowExecutionRetentionPeriodInDays="60"
|
||||
)
|
||||
client.register_activity_type(
|
||||
domain="test-domain", name="test-activity", version="v1.0"
|
||||
)
|
||||
client.deprecate_activity_type(
|
||||
domain="test-domain", activityType={"name": "test-activity", "version": "v1.0"}
|
||||
)
|
||||
client.undeprecate_activity_type(
|
||||
domain="test-domain", activityType={"name": "test-activity", "version": "v1.0"}
|
||||
)
|
||||
|
||||
client.undeprecate_activity_type.when.called_with(
|
||||
domain="test-domain", activityType={"name": "test-activity", "version": "v1.0"}
|
||||
).should.throw(ClientError)
|
||||
|
||||
|
||||
@mock_swf
|
||||
def test_undeprecate_never_deprecated_activity_type():
|
||||
client = boto3.client("swf", region_name="us-east-1")
|
||||
client.register_domain(
|
||||
name="test-domain", workflowExecutionRetentionPeriodInDays="60"
|
||||
)
|
||||
client.register_activity_type(
|
||||
domain="test-domain", name="test-activity", version="v1.0"
|
||||
)
|
||||
|
||||
client.undeprecate_activity_type.when.called_with(
|
||||
domain="test-domain", activityType={"name": "test-activity", "version": "v1.0"}
|
||||
).should.throw(ClientError)
|
||||
|
||||
|
||||
@mock_swf
|
||||
def test_undeprecate_non_existent_activity_type():
|
||||
client = boto3.client("swf", region_name="us-east-1")
|
||||
client.register_domain(
|
||||
name="test-domain", workflowExecutionRetentionPeriodInDays="60"
|
||||
)
|
||||
|
||||
client.undeprecate_activity_type.when.called_with(
|
||||
domain="test-domain", activityType={"name": "test-activity", "version": "v1.0"}
|
||||
).should.throw(ClientError)
|
||||
|
||||
|
||||
# DescribeActivityType endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_describe_activity_type():
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
import boto
|
||||
from boto.swf.exceptions import SWFResponseError
|
||||
import boto3
|
||||
from botocore.exceptions import ClientError
|
||||
import sure # noqa
|
||||
|
||||
from moto import mock_swf_deprecated
|
||||
from moto import mock_swf
|
||||
|
||||
|
||||
# RegisterDomain endpoint
|
||||
|
|
@ -94,6 +97,56 @@ def test_deprecate_non_existent_domain():
|
|||
)
|
||||
|
||||
|
||||
# UndeprecateDomain endpoint
|
||||
@mock_swf
|
||||
def test_undeprecate_domain():
|
||||
client = boto3.client("swf", region_name="us-east-1")
|
||||
client.register_domain(
|
||||
name="test-domain", workflowExecutionRetentionPeriodInDays="60"
|
||||
)
|
||||
client.deprecate_domain(name="test-domain")
|
||||
client.undeprecate_domain(name="test-domain")
|
||||
|
||||
resp = client.describe_domain(name="test-domain")
|
||||
|
||||
resp["domainInfo"]["status"].should.equal("REGISTERED")
|
||||
|
||||
|
||||
@mock_swf
|
||||
def test_undeprecate_already_undeprecated_domain():
|
||||
client = boto3.client("swf", region_name="us-east-1")
|
||||
client.register_domain(
|
||||
name="test-domain", workflowExecutionRetentionPeriodInDays="60"
|
||||
)
|
||||
client.deprecate_domain(name="test-domain")
|
||||
client.undeprecate_domain(name="test-domain")
|
||||
|
||||
client.undeprecate_domain.when.called_with(name="test-domain").should.throw(
|
||||
ClientError
|
||||
)
|
||||
|
||||
|
||||
@mock_swf
|
||||
def test_undeprecate_never_deprecated_domain():
|
||||
client = boto3.client("swf", region_name="us-east-1")
|
||||
client.register_domain(
|
||||
name="test-domain", workflowExecutionRetentionPeriodInDays="60"
|
||||
)
|
||||
|
||||
client.undeprecate_domain.when.called_with(name="test-domain").should.throw(
|
||||
ClientError
|
||||
)
|
||||
|
||||
|
||||
@mock_swf
|
||||
def test_undeprecate_non_existent_domain():
|
||||
client = boto3.client("swf", region_name="us-east-1")
|
||||
|
||||
client.undeprecate_domain.when.called_with(name="non-existent").should.throw(
|
||||
ClientError
|
||||
)
|
||||
|
||||
|
||||
# DescribeDomain endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_describe_domain():
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import boto3
|
|||
from moto import mock_swf_deprecated
|
||||
from moto import mock_swf
|
||||
from boto.swf.exceptions import SWFResponseError
|
||||
from botocore.exceptions import ClientError
|
||||
|
||||
|
||||
# RegisterWorkflowType endpoint
|
||||
|
|
@ -112,6 +113,77 @@ def test_deprecate_non_existent_workflow_type():
|
|||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
# UndeprecateWorkflowType endpoint
|
||||
@mock_swf
|
||||
def test_undeprecate_workflow_type():
|
||||
client = boto3.client("swf", region_name="us-east-1")
|
||||
client.register_domain(
|
||||
name="test-domain", workflowExecutionRetentionPeriodInDays="60"
|
||||
)
|
||||
client.register_workflow_type(
|
||||
domain="test-domain", name="test-workflow", version="v1.0"
|
||||
)
|
||||
client.deprecate_workflow_type(
|
||||
domain="test-domain", workflowType={"name": "test-workflow", "version": "v1.0"}
|
||||
)
|
||||
client.undeprecate_workflow_type(
|
||||
domain="test-domain", workflowType={"name": "test-workflow", "version": "v1.0"}
|
||||
)
|
||||
|
||||
resp = client.describe_workflow_type(
|
||||
domain="test-domain", workflowType={"name": "test-workflow", "version": "v1.0"}
|
||||
)
|
||||
resp["typeInfo"]["status"].should.equal("REGISTERED")
|
||||
|
||||
|
||||
@mock_swf
|
||||
def test_undeprecate_already_undeprecated_workflow_type():
|
||||
client = boto3.client("swf", region_name="us-east-1")
|
||||
client.register_domain(
|
||||
name="test-domain", workflowExecutionRetentionPeriodInDays="60"
|
||||
)
|
||||
client.register_workflow_type(
|
||||
domain="test-domain", name="test-workflow", version="v1.0"
|
||||
)
|
||||
client.deprecate_workflow_type(
|
||||
domain="test-domain", workflowType={"name": "test-workflow", "version": "v1.0"}
|
||||
)
|
||||
client.undeprecate_workflow_type(
|
||||
domain="test-domain", workflowType={"name": "test-workflow", "version": "v1.0"}
|
||||
)
|
||||
|
||||
client.undeprecate_workflow_type.when.called_with(
|
||||
domain="test-domain", workflowType={"name": "test-workflow", "version": "v1.0"}
|
||||
).should.throw(ClientError)
|
||||
|
||||
|
||||
@mock_swf
|
||||
def test_undeprecate_never_deprecated_workflow_type():
|
||||
client = boto3.client("swf", region_name="us-east-1")
|
||||
client.register_domain(
|
||||
name="test-domain", workflowExecutionRetentionPeriodInDays="60"
|
||||
)
|
||||
client.register_workflow_type(
|
||||
domain="test-domain", name="test-workflow", version="v1.0"
|
||||
)
|
||||
|
||||
client.undeprecate_workflow_type.when.called_with(
|
||||
domain="test-domain", workflowType={"name": "test-workflow", "version": "v1.0"}
|
||||
).should.throw(ClientError)
|
||||
|
||||
|
||||
@mock_swf
|
||||
def test_undeprecate_non_existent_workflow_type():
|
||||
client = boto3.client("swf", region_name="us-east-1")
|
||||
client.register_domain(
|
||||
name="test-domain", workflowExecutionRetentionPeriodInDays="60"
|
||||
)
|
||||
|
||||
client.undeprecate_workflow_type.when.called_with(
|
||||
domain="test-domain", workflowType={"name": "test-workflow", "version": "v1.0"}
|
||||
).should.throw(ClientError)
|
||||
|
||||
|
||||
# DescribeWorkflowType endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_describe_workflow_type():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue