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:
parent
3bc18455a2
commit
195ba81c56
@ -368,9 +368,12 @@ class EventsBackend(BaseBackend):
|
|||||||
|
|
||||||
if rule:
|
if rule:
|
||||||
rule.remove_targets(ids)
|
rule.remove_targets(ids)
|
||||||
return True
|
return {"FailedEntries": [], "FailedEntryCount": 0}
|
||||||
|
else:
|
||||||
return False
|
raise JsonRESTError(
|
||||||
|
"ResourceNotFoundException",
|
||||||
|
"An entity that you specified does not exist",
|
||||||
|
)
|
||||||
|
|
||||||
def test_event_pattern(self):
|
def test_event_pattern(self):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
@ -238,7 +238,10 @@ class EventsHandler(BaseResponse):
|
|||||||
"ResourceNotFoundException", "Rule " + rule_name + " does not exist."
|
"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):
|
def test_event_pattern(self):
|
||||||
pass
|
pass
|
||||||
|
@ -195,13 +195,27 @@ def test_remove_targets():
|
|||||||
targets_before = len(targets)
|
targets_before = len(targets)
|
||||||
assert targets_before > 0
|
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 = client.list_targets_by_rule(Rule=rule_name)["Targets"]
|
||||||
targets_after = len(targets)
|
targets_after = len(targets)
|
||||||
assert targets_before - 1 == targets_after
|
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
|
@mock_events
|
||||||
def test_put_targets():
|
def test_put_targets():
|
||||||
client = boto3.client("events", "us-west-2")
|
client = boto3.client("events", "us-west-2")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user