Add tests for Events::Rule integration with cf

This commit is contained in:
Guilherme Martins Crocetti 2020-03-23 22:17:02 -03:00
parent c96efe531e
commit 788b8fb6e1
2 changed files with 61 additions and 29 deletions

View File

@ -596,28 +596,6 @@ def test_create_stack_kinesis():
assert len(resources) == 1
@mock_cloudformation_deprecated
def test_create_stack_events_rule():
conn = boto.connect_cloudformation()
events_template = {
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"event": {
"Type": "AWS::Events::Rule",
"Properties": {
"State": "ENABLED",
"ScheduleExpression": "rate(5 minutes)",
},
}
},
}
conn.create_stack("test_stack_events_1", template_body=json.dumps(events_template))
stack = conn.describe_stacks()[0]
resources = stack.list_resources()
resources.should.have.length_of(1)
def get_role_name():
with mock_iam_deprecated():
iam = boto.connect_iam()

View File

@ -2384,11 +2384,11 @@ def test_create_log_group_using_fntransform():
@mock_cloudformation
@mock_events
def test_stack_events_rule_integration():
def test_stack_events_create_rule_integration():
events_template = {
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"event": {
"Event": {
"Type": "AWS::Events::Rule",
"Properties": {
"Name": "quick-fox",
@ -2403,8 +2403,62 @@ def test_stack_events_rule_integration():
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)")
rules = boto3.client("events", "us-west-2").list_rules()
rules["Rules"].should.have.length_of(1)
rules["Rules"][0]["Name"].should.equal("quick-fox")
rules["Rules"][0]["State"].should.equal("ENABLED")
rules["Rules"][0]["ScheduleExpression"].should.equal("rate(5 minutes)")
@mock_cloudformation
@mock_events
def test_stack_events_delete_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),
)
rules = boto3.client("events", "us-west-2").list_rules()
rules["Rules"].should.have.length_of(1)
cf_conn.delete_stack(StackName="test_stack")
rules = boto3.client("events", "us-west-2").list_rules()
rules["Rules"].should.have.length_of(0)
@mock_cloudformation
@mock_events
def test_stack_events_create_rule_without_name_integration():
events_template = {
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"Event": {
"Type": "AWS::Events::Rule",
"Properties": {
"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),
)
rules = boto3.client("events", "us-west-2").list_rules()
rules["Rules"][0]["Name"].should.contain("test_stack-Event-")