Add test for boto3 integration

This commit is contained in:
Guilherme Martins Crocetti 2020-03-22 18:03:42 -03:00
parent a1f664d2bb
commit 98a17dfc46
2 changed files with 32 additions and 5 deletions

View File

@ -597,12 +597,10 @@ def test_create_stack_kinesis():
@mock_cloudformation_deprecated
def test_create_stack_events():
def test_create_stack_events_rule():
conn = boto.connect_cloudformation()
dummy_template = {
events_template = {
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Stack Kinesis Test 1",
"Parameters": {},
"Resources": {
"event": {
"Type": "AWS::Events::Rule",
@ -613,7 +611,7 @@ def test_create_stack_events():
}
},
}
conn.create_stack("test_stack_events_1", template_body=json.dumps(dummy_template))
conn.create_stack("test_stack_events_1", template_body=json.dumps(events_template))
stack = conn.describe_stacks()[0]
resources = stack.list_resources()

View File

@ -29,6 +29,7 @@ from moto import (
mock_ec2_deprecated,
mock_elb,
mock_elb_deprecated,
mock_events,
mock_iam_deprecated,
mock_kms,
mock_lambda,
@ -2379,3 +2380,31 @@ def test_create_log_group_using_fntransform():
logs_conn = boto3.client("logs", region_name="us-west-2")
log_group = logs_conn.describe_log_groups()["logGroups"][0]
log_group["logGroupName"].should.equal("some-log-group")
@mock_cloudformation
@mock_events
def test_stack_events_rule_integration():
events_template = {
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"event": {
"Type": "AWS::Events::Rule",
"Properties": {
"Name": "quick-fox",
"State": "ENABLED",
"ScheduleExpression": "rate(5 minutes)",
},
}
},
}
cf_conn = boto3.client("cloudformation", "us-west-2")
cf_conn.create_stack(
StackName="test_stack", TemplateBody=json.dumps(events_template),
)
result = boto3.client("events", "us-west-2").list_rules()
result["Rules"].should.have.length_of(1)
result["Rules"][0]["Name"].should.equal("quick-fox")
result["Rules"][0]["State"].should.equal("ENABLED")
result["Rules"][0]["ScheduleExpression"].should.equal("rate(5 minutes)")