diff --git a/moto/events/models.py b/moto/events/models.py index 4d5047891..8b7a084f7 100644 --- a/moto/events/models.py +++ b/moto/events/models.py @@ -368,9 +368,12 @@ class EventsBackend(BaseBackend): if rule: rule.remove_targets(ids) - return True - - return False + return {"FailedEntries": [], "FailedEntryCount": 0} + else: + raise JsonRESTError( + "ResourceNotFoundException", + "An entity that you specified does not exist", + ) def test_event_pattern(self): raise NotImplementedError() diff --git a/moto/events/responses.py b/moto/events/responses.py index c4e49fc80..a72a86975 100644 --- a/moto/events/responses.py +++ b/moto/events/responses.py @@ -238,7 +238,10 @@ class EventsHandler(BaseResponse): "ResourceNotFoundException", "Rule " + rule_name + " does not exist." ) - return "", self.response_headers + return ( + json.dumps({"FailedEntryCount": 0, "FailedEntries": []}), + self.response_headers, + ) def test_event_pattern(self): pass diff --git a/tests/test_events/test_events.py b/tests/test_events/test_events.py index 678e0a622..b65171603 100644 --- a/tests/test_events/test_events.py +++ b/tests/test_events/test_events.py @@ -195,13 +195,27 @@ def test_remove_targets(): targets_before = len(targets) assert targets_before > 0 - client.remove_targets(Rule=rule_name, Ids=[targets[0]["Id"]]) + response = client.remove_targets(Rule=rule_name, Ids=[targets[0]["Id"]]) + response["FailedEntryCount"].should.equal(0) + response["FailedEntries"].should.have.length_of(0) targets = client.list_targets_by_rule(Rule=rule_name)["Targets"] targets_after = len(targets) assert targets_before - 1 == targets_after +@mock_events +def test_remove_targets_errors(): + client = boto3.client("events", "us-east-1") + + client.remove_targets.when.called_with( + Rule="non-existent", Ids=["Id12345678"] + ).should.throw( + client.exceptions.ResourceNotFoundException, + "An entity that you specified does not exist", + ) + + @mock_events def test_put_targets(): client = boto3.client("events", "us-west-2")