diff --git a/moto/elbv2/models.py b/moto/elbv2/models.py index 9092084e6..fa9cd6426 100644 --- a/moto/elbv2/models.py +++ b/moto/elbv2/models.py @@ -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 diff --git a/tests/test_elbv2/test_elbv2.py b/tests/test_elbv2/test_elbv2.py index be3f484e0..fb140cb69 100644 --- a/tests/test_elbv2/test_elbv2.py +++ b/tests/test_elbv2/test_elbv2.py @@ -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