Skip to content

Commit

Permalink
Fix cloudwatch events delete_rule. Closes #884.
Browse files Browse the repository at this point in the history
  • Loading branch information
spulec committed Apr 13, 2017
1 parent 23f6f94 commit bf935c2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions moto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from .ecs import mock_ecs, mock_ecs_deprecated # flake8: noqa
from .elb import mock_elb, mock_elb_deprecated # flake8: noqa
from .emr import mock_emr, mock_emr_deprecated # flake8: noqa
from .events import mock_events # flake8: noqa
from .glacier import mock_glacier, mock_glacier_deprecated # flake8: noqa
from .opsworks import mock_opsworks, mock_opsworks_deprecated # flake8: noqa
from .iam import mock_iam, mock_iam_deprecated # flake8: noqa
Expand Down
3 changes: 2 additions & 1 deletion moto/events/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ def error(self, type_, message='', status=400):

def delete_rule(self):
body = self.load_body()
name = body.get('NamePrefix')
name = body.get('Name')

if not name:
return self.error('ValidationException', 'Parameter Name is required.')
events_backend.delete_rule(name)

return '', self.response_headers

Expand Down
9 changes: 9 additions & 0 deletions tests/test_events/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,15 @@ def test_list_rules():
assert(len(rules['Rules']) == len(RULES))


@mock_events
def test_delete_rule():
client = generate_environment()

client.delete_rule(Name=RULES[0]['Name'])
rules = client.list_rules()
assert(len(rules['Rules']) == len(RULES) - 1)


@mock_events
def test_list_targets_by_rule():
rule_name = get_random_rule()['Name']
Expand Down

0 comments on commit bf935c2

Please sign in to comment.