feat: update events remove_targets API response (#3340)

* feat: update events remove_targets API response

* test: add missing test for expected exception
This commit is contained in:
Giovanni Torres 2020-09-29 06:51:17 -04:00 committed by GitHub
parent 3bc18455a2
commit 195ba81c56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 5 deletions

View File

@ -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()

View File

@ -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

View File

@ -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")