Merge branch 'master' into bugfix/1615-cloudwatch-statistics
This commit is contained in:
commit
69587c151c
22 changed files with 310 additions and 36 deletions
|
|
@ -148,10 +148,41 @@ dummy_import_template = {
|
|||
}
|
||||
}
|
||||
|
||||
dummy_redrive_template = {
|
||||
"AWSTemplateFormatVersion": "2010-09-09",
|
||||
"Resources": {
|
||||
"MainQueue": {
|
||||
"Type": "AWS::SQS::Queue",
|
||||
"Properties": {
|
||||
"QueueName": "mainqueue.fifo",
|
||||
"FifoQueue": True,
|
||||
"ContentBasedDeduplication": False,
|
||||
"RedrivePolicy": {
|
||||
"deadLetterTargetArn": {
|
||||
"Fn::GetAtt": [
|
||||
"DeadLetterQueue",
|
||||
"Arn"
|
||||
]
|
||||
},
|
||||
"maxReceiveCount": 5
|
||||
}
|
||||
}
|
||||
},
|
||||
"DeadLetterQueue": {
|
||||
"Type": "AWS::SQS::Queue",
|
||||
"Properties": {
|
||||
"FifoQueue": True
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
dummy_template_json = json.dumps(dummy_template)
|
||||
dummy_update_template_json = json.dumps(dummy_update_template)
|
||||
dummy_output_template_json = json.dumps(dummy_output_template)
|
||||
dummy_import_template_json = json.dumps(dummy_import_template)
|
||||
dummy_redrive_template_json = json.dumps(dummy_redrive_template)
|
||||
|
||||
|
||||
|
||||
@mock_cloudformation
|
||||
|
|
@ -746,3 +777,19 @@ def test_stack_with_imports():
|
|||
output = output_stack.outputs[0]['OutputValue']
|
||||
queue = ec2_resource.get_queue_by_name(QueueName=output)
|
||||
queue.should_not.be.none
|
||||
|
||||
|
||||
@mock_sqs
|
||||
@mock_cloudformation
|
||||
def test_non_json_redrive_policy():
|
||||
cf = boto3.resource('cloudformation', region_name='us-east-1')
|
||||
|
||||
stack = cf.create_stack(
|
||||
StackName="test_stack1",
|
||||
TemplateBody=dummy_redrive_template_json
|
||||
)
|
||||
|
||||
stack.Resource('MainQueue').resource_status\
|
||||
.should.equal("CREATE_COMPLETE")
|
||||
stack.Resource('DeadLetterQueue').resource_status\
|
||||
.should.equal("CREATE_COMPLETE")
|
||||
|
|
|
|||
|
|
@ -204,6 +204,7 @@ def test_get_metric_statistics():
|
|||
dict(
|
||||
MetricName='metric',
|
||||
Value=1.5,
|
||||
Timestamp=utc_now
|
||||
)
|
||||
]
|
||||
)
|
||||
|
|
@ -211,7 +212,7 @@ def test_get_metric_statistics():
|
|||
stats = conn.get_metric_statistics(
|
||||
Namespace='tester',
|
||||
MetricName='metric',
|
||||
StartTime=utc_now,
|
||||
StartTime=utc_now - timedelta(seconds=60),
|
||||
EndTime=utc_now + timedelta(seconds=60),
|
||||
Period=60,
|
||||
Statistics=['SampleCount', 'Sum']
|
||||
|
|
|
|||
|
|
@ -13,6 +13,10 @@ def test_log_group_create():
|
|||
conn = boto3.client('logs', 'us-west-2')
|
||||
log_group_name = 'dummy'
|
||||
response = conn.create_log_group(logGroupName=log_group_name)
|
||||
|
||||
response = conn.describe_log_groups(logGroupNamePrefix=log_group_name)
|
||||
assert len(response['logGroups']) == 1
|
||||
|
||||
response = conn.delete_log_group(logGroupName=log_group_name)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -818,6 +818,48 @@ def test_create_cluster_from_snapshot():
|
|||
new_cluster['Endpoint']['Port'].should.equal(1234)
|
||||
|
||||
|
||||
@mock_redshift
|
||||
def test_create_cluster_from_snapshot_with_waiter():
|
||||
client = boto3.client('redshift', region_name='us-east-1')
|
||||
original_cluster_identifier = 'original-cluster'
|
||||
original_snapshot_identifier = 'original-snapshot'
|
||||
new_cluster_identifier = 'new-cluster'
|
||||
|
||||
client.create_cluster(
|
||||
ClusterIdentifier=original_cluster_identifier,
|
||||
ClusterType='single-node',
|
||||
NodeType='ds2.xlarge',
|
||||
MasterUsername='username',
|
||||
MasterUserPassword='password',
|
||||
)
|
||||
client.create_cluster_snapshot(
|
||||
SnapshotIdentifier=original_snapshot_identifier,
|
||||
ClusterIdentifier=original_cluster_identifier
|
||||
)
|
||||
response = client.restore_from_cluster_snapshot(
|
||||
ClusterIdentifier=new_cluster_identifier,
|
||||
SnapshotIdentifier=original_snapshot_identifier,
|
||||
Port=1234
|
||||
)
|
||||
response['Cluster']['ClusterStatus'].should.equal('creating')
|
||||
|
||||
client.get_waiter('cluster_restored').wait(
|
||||
ClusterIdentifier=new_cluster_identifier,
|
||||
WaiterConfig={
|
||||
'Delay': 1,
|
||||
'MaxAttempts': 2,
|
||||
}
|
||||
)
|
||||
|
||||
response = client.describe_clusters(
|
||||
ClusterIdentifier=new_cluster_identifier
|
||||
)
|
||||
new_cluster = response['Clusters'][0]
|
||||
new_cluster['NodeType'].should.equal('ds2.xlarge')
|
||||
new_cluster['MasterUsername'].should.equal('username')
|
||||
new_cluster['Endpoint']['Port'].should.equal(1234)
|
||||
|
||||
|
||||
@mock_redshift
|
||||
def test_create_cluster_from_non_existent_snapshot():
|
||||
client = boto3.client('redshift', region_name='us-east-1')
|
||||
|
|
|
|||
|
|
@ -1405,6 +1405,19 @@ def test_boto3_deleted_versionings_list():
|
|||
assert len(listed['Contents']) == 1
|
||||
|
||||
|
||||
@mock_s3
|
||||
def test_boto3_delete_versioned_bucket():
|
||||
client = boto3.client('s3', region_name='us-east-1')
|
||||
|
||||
client.create_bucket(Bucket='blah')
|
||||
client.put_bucket_versioning(Bucket='blah', VersioningConfiguration={'Status': 'Enabled'})
|
||||
|
||||
resp = client.put_object(Bucket='blah', Key='test1', Body=b'test1')
|
||||
client.delete_object(Bucket='blah', Key='test1', VersionId=resp["VersionId"])
|
||||
|
||||
client.delete_bucket(Bucket='blah')
|
||||
|
||||
|
||||
@mock_s3
|
||||
def test_boto3_head_object_if_modified_since():
|
||||
s3 = boto3.client('s3', region_name='us-east-1')
|
||||
|
|
|
|||
|
|
@ -136,3 +136,59 @@ def test_send_raw_email():
|
|||
send_quota = conn.get_send_quota()
|
||||
sent_count = int(send_quota['SentLast24Hours'])
|
||||
sent_count.should.equal(2)
|
||||
|
||||
|
||||
@mock_ses
|
||||
def test_send_raw_email_without_source():
|
||||
conn = boto3.client('ses', region_name='us-east-1')
|
||||
|
||||
message = MIMEMultipart()
|
||||
message['Subject'] = 'Test'
|
||||
message['From'] = 'test@example.com'
|
||||
message['To'] = 'to@example.com, foo@example.com'
|
||||
|
||||
# Message body
|
||||
part = MIMEText('test file attached')
|
||||
message.attach(part)
|
||||
|
||||
# Attachment
|
||||
part = MIMEText('contents of test file here')
|
||||
part.add_header('Content-Disposition', 'attachment; filename=test.txt')
|
||||
message.attach(part)
|
||||
|
||||
kwargs = dict(
|
||||
RawMessage={'Data': message.as_string()},
|
||||
)
|
||||
|
||||
conn.send_raw_email.when.called_with(**kwargs).should.throw(ClientError)
|
||||
|
||||
conn.verify_email_identity(EmailAddress="test@example.com")
|
||||
conn.send_raw_email(**kwargs)
|
||||
|
||||
send_quota = conn.get_send_quota()
|
||||
sent_count = int(send_quota['SentLast24Hours'])
|
||||
sent_count.should.equal(2)
|
||||
|
||||
|
||||
@mock_ses
|
||||
def test_send_raw_email_without_source_or_from():
|
||||
conn = boto3.client('ses', region_name='us-east-1')
|
||||
|
||||
message = MIMEMultipart()
|
||||
message['Subject'] = 'Test'
|
||||
message['To'] = 'to@example.com, foo@example.com'
|
||||
|
||||
# Message body
|
||||
part = MIMEText('test file attached')
|
||||
message.attach(part)
|
||||
# Attachment
|
||||
part = MIMEText('contents of test file here')
|
||||
part.add_header('Content-Disposition', 'attachment; filename=test.txt')
|
||||
message.attach(part)
|
||||
|
||||
kwargs = dict(
|
||||
RawMessage={'Data': message.as_string()},
|
||||
)
|
||||
|
||||
conn.send_raw_email.when.called_with(**kwargs).should.throw(ClientError)
|
||||
|
||||
|
|
|
|||
|
|
@ -13,23 +13,24 @@ from moto.sns.models import DEFAULT_TOPIC_POLICY, DEFAULT_EFFECTIVE_DELIVERY_POL
|
|||
@mock_sns
|
||||
def test_create_and_delete_topic():
|
||||
conn = boto3.client("sns", region_name="us-east-1")
|
||||
conn.create_topic(Name="some-topic")
|
||||
for topic_name in ('some-topic', '-some-topic-', '_some-topic_', 'a' * 256):
|
||||
conn.create_topic(Name=topic_name)
|
||||
|
||||
topics_json = conn.list_topics()
|
||||
topics = topics_json["Topics"]
|
||||
topics.should.have.length_of(1)
|
||||
topics[0]['TopicArn'].should.equal(
|
||||
"arn:aws:sns:{0}:123456789012:some-topic"
|
||||
.format(conn._client_config.region_name)
|
||||
)
|
||||
topics_json = conn.list_topics()
|
||||
topics = topics_json["Topics"]
|
||||
topics.should.have.length_of(1)
|
||||
topics[0]['TopicArn'].should.equal(
|
||||
"arn:aws:sns:{0}:123456789012:{1}"
|
||||
.format(conn._client_config.region_name, topic_name)
|
||||
)
|
||||
|
||||
# Delete the topic
|
||||
conn.delete_topic(TopicArn=topics[0]['TopicArn'])
|
||||
# Delete the topic
|
||||
conn.delete_topic(TopicArn=topics[0]['TopicArn'])
|
||||
|
||||
# And there should now be 0 topics
|
||||
topics_json = conn.list_topics()
|
||||
topics = topics_json["Topics"]
|
||||
topics.should.have.length_of(0)
|
||||
# And there should now be 0 topics
|
||||
topics_json = conn.list_topics()
|
||||
topics = topics_json["Topics"]
|
||||
topics.should.have.length_of(0)
|
||||
|
||||
@mock_sns
|
||||
def test_create_topic_should_be_indempodent():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue