Skip to content

Commit

Permalink
fixup! Add FlapStates._clear_flap_internal()
Browse files Browse the repository at this point in the history
  • Loading branch information
lunkwill42 committed Jul 17, 2024
1 parent d43dcb2 commit e1fdf07
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions tests/flaps_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,18 +179,19 @@ def test_when_event_does_not_exist_it_should_do_nothing(

assert not state.events.get("localhost", port.ifindex, PortStateEvent)

def test_when_port_does_not_exist_it_should_do_nothing(
self,
state_with_flapstats,
):
state = state_with_flapstats
fake_ifindex = 9999
def test_when_event_but_not_port_exists_it_should_do_nothing(self, state_with_flapstats_and_portstate_event):
state = state_with_flapstats_and_portstate_event
port: Port = next(iter(state.devices.devices["localhost"].ports.values()))
# Remove the port from device state for this test
del state.devices.devices["localhost"].ports[port.ifindex]

state.flapping._clear_flap_internal(
("localhost", fake_ifindex), "nobody", "Flapstate manually cleared", state=state
("localhost", port.ifindex), "nobody", "Flapstate manually cleared", state=state
)

assert not state.events.get("localhost", fake_ifindex, PortStateEvent)
event = state.events.get("localhost", port.ifindex, PortStateEvent)
assert event
assert event.flapstate == FlapState.FLAPPING # still flapping!


class TestFlappingStatesClearFlap:
Expand Down

0 comments on commit e1fdf07

Please sign in to comment.