fix bug that remove_rule doesnt remove rule correctly (#1074)

This commit is contained in:
Toshiya Kawasaki 2017-08-22 04:30:03 +09:00 committed by Jack Danger
parent ce7eabd44a
commit 2ace59a60e
2 changed files with 6 additions and 1 deletions

View File

@ -116,6 +116,9 @@ class FakeListener(BaseModel):
def rules(self):
return self._non_default_rules + [self._default_rule]
def remove_rule(self, rule):
self._non_default_rules.remove(rule)
def register(self, rule):
self._non_default_rules.append(rule)
self._non_default_rules = sorted(self._non_default_rules, key=lambda x: x.priority)
@ -410,7 +413,7 @@ class ELBv2Backend(BaseBackend):
for listener in listeners:
for rule in listener.rules:
if rule.arn == arn:
listener.rules.remove(rule)
listener.remove_rule(rule)
return
# should raise RuleNotFound Error according to the AWS API doc

View File

@ -770,6 +770,8 @@ def test_handle_listener_rules():
# delete
arn = first_rule['RuleArn']
conn.delete_rule(RuleArn=arn)
rules = conn.describe_rules(ListenerArn=http_listener_arn)['Rules']
len(rules).should.equal(2)
# test for invalid action type
safe_priority = 2