Skip to content

Commit

Permalink
Rename tests
Browse files Browse the repository at this point in the history
Co-authored-by: Morten Brekkevold <[email protected]>
  • Loading branch information
stveit and lunkwill42 authored Aug 29, 2024
1 parent 2128133 commit 82f94ca
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions tests/events_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def test_delete_should_remove_closed_event_from_index_if_still_in_index(self):
index = EventIndex("foobar", None, ReachabilityEvent)
assert not events._events_by_index.get(index)

def test_record_downtime_should_not_update_event_if_lasttrans_is_not_set(self):
def test_when_lasttrans_is_not_set_record_downtime_should_not_update_event(self):
events = Events()
old_event = events.get_or_create_event("foobar", None, ReachabilityEvent)
old_event.reachability = ReachabilityState.NORESPONSE
Expand All @@ -272,7 +272,7 @@ def test_record_downtime_should_not_update_event_if_lasttrans_is_not_set(self):
assert new_event.lasttrans is None
assert new_event.ac_down is None

def test_record_downtime_should_not_update_event_if_downtime_is_calculated_to_zero_or_less(self, monkeypatch):
def test_when_downtime_is_calculated_to_zero_or_less_record_downtime_should_not_update_event(self, monkeypatch):
events = Events()
old_event = events.get_or_create_event("foobar", None, ReachabilityEvent)
old_event.reachability = ReachabilityState.NORESPONSE
Expand Down
10 changes: 5 additions & 5 deletions tests/tasks/test_linkstatetask.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ def test_when_interface_data_is_empty_update_interfaces_should_keep_processing(s
)

@pytest.mark.asyncio
async def test_should_set_lasttrans_for_new_portstate_event(self, linkstatetask_with_one_link_down):
async def test_when_event_is_new_it_should_set_lasttrans(self, linkstatetask_with_one_link_down):
task = linkstatetask_with_one_link_down
await task.run()
event = task.state.events.get(task.device.name, 2, PortStateEvent)
assert event.lasttrans

@pytest.mark.asyncio
async def test_should_update_lasttrans_for_portstate_event_going_from_down_to_up(self, linkstatetask_with_links_up):
async def test_when_event_transitions_from_to_up_it_should_update_lasttrans(self, linkstatetask_with_links_up):
task = linkstatetask_with_links_up
initial_lasttrans = now() - timedelta(minutes=5)

Expand All @@ -106,7 +106,7 @@ async def test_should_update_lasttrans_for_portstate_event_going_from_down_to_up
assert updated_event.lasttrans > initial_lasttrans

@pytest.mark.asyncio
async def test_should_update_lasttrans_for_portstate_event_going_from_down_to_admindown(
async def test_when_event_transitions_from_down_to_admindown_it_should_update_lasttrans(
self, linkstatetask_with_admin_down
):
task = linkstatetask_with_admin_down
Expand All @@ -127,7 +127,7 @@ async def test_should_update_lasttrans_for_portstate_event_going_from_down_to_ad
assert updated_event.lasttrans > initial_lasttrans

@pytest.mark.asyncio
async def test_should_update_ac_down_for_portstate_event_going_from_down_to_up(self, linkstatetask_with_links_up):
async def test_when_event_transitions_from_down_to_up_it_should_update_ac_down(self, linkstatetask_with_links_up):
task = linkstatetask_with_links_up
initial_lasttrans = now() - timedelta(minutes=5)
initial_ac_down = timedelta(0)
Expand All @@ -148,7 +148,7 @@ async def test_should_update_ac_down_for_portstate_event_going_from_down_to_up(s
assert updated_event.ac_down > initial_ac_down

@pytest.mark.asyncio
async def test_should_update_ac_down_for_portstate_event_going_from_down_to_admin_down(
async def test_when_event_transitions_from_down_to_admindown_it_should_update_ac_down(
self, linkstatetask_with_admin_down
):
task = linkstatetask_with_admin_down
Expand Down
8 changes: 4 additions & 4 deletions tests/tasks/test_reachabletask.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ async def test_run_extra_job_should_not_update_event_when_device_is_unreachable(
assert event.reachability == ReachabilityState.NORESPONSE

@pytest.mark.asyncio
async def test_should_set_lasttrans_for_new_reachable_event(self, unreachable_task):
async def test_when_event_is_new_it_should_set_lasttrans(self, unreachable_task):
task = unreachable_task
with pytest.raises(DeviceUnreachableError):
await task.run()
event = task.state.events.get(task.device.name, None, ReachabilityEvent)
assert event.lasttrans

@pytest.mark.asyncio
async def test_should_update_lasttrans_for_reachable_event_going_from_no_response_to_reachable(
async def test_when_event_transitions_from_no_response_to_reachable_it_should_update_lasttrans(
self, reachable_task
):
task = reachable_task
Expand All @@ -98,7 +98,7 @@ async def test_should_update_lasttrans_for_reachable_event_going_from_no_respons
assert updated_event.lasttrans > initial_lasttrans

@pytest.mark.asyncio
async def test_should_update_lasttrans_for_reachable_event_going_from_reachable_to_no_response(
async def test_when_event_transitions_from_reachable_to_no_response_it_should_update_lasttrans(
self, unreachable_task
):
task = unreachable_task
Expand All @@ -116,7 +116,7 @@ async def test_should_update_lasttrans_for_reachable_event_going_from_reachable_
assert updated_event.lasttrans > initial_lasttrans

@pytest.mark.asyncio
async def test_should_update_ac_down_for_reachable_event_going_from_no_response_to_reachable(self, reachable_task):
async def test_when_event_transitions_from_no_response_to_reachable_it_should_update_ac_down(self, reachable_task):
task = reachable_task
initial_ac_down = timedelta(0)
initial_lasttrans = now() - timedelta(minutes=5)
Expand Down
8 changes: 4 additions & 4 deletions tests/trapobservers/link_traps_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ async def test_when_link_trap_refers_to_unknown_port_it_should_ignore_trap_early
assert not await observer.handle_trap(trap)
assert not handle_link_transition.called, "handle_link_transition was called"

async def test_should_set_lasttrans_for_new_portstate_event(
async def test_when_event_is_new_it_should_set_lasttrans(
self, state_with_localhost_with_port, localhost_receiver
):
assert not state_with_localhost_with_port.events.get(
Expand Down Expand Up @@ -262,7 +262,7 @@ def test_when_link_transitions_to_non_flapping_it_should_remove_flap_state(self,

assert index not in state_with_localhost_with_port.flapping.interfaces

def test_when_link_transitions_from_up_to_flapping_lasttrans_for_related_event_should_be_updated(
def test_when_link_transitions_from_up_to_flapping_it_should_update_lasttrans_for_related_event(
self, state_with_localhost_with_port
):
observer = LinkTrapObserver(state=state_with_localhost_with_port, polldevs={})
Expand All @@ -287,7 +287,7 @@ def test_when_link_transitions_from_up_to_flapping_lasttrans_for_related_event_s
assert updated_event.portstate == InterfaceState.DOWN
assert updated_event.lasttrans > initial_lasttrans

async def test_when_link_transitions_from_flapping_to_up_lasttrans_for_related_event_should_be_updated(
async def test_when_link_transitions_from_flapping_to_up_it_should_update_lasttrans_for_related_event(
self, state_with_localhost_with_port
):
observer = LinkTrapObserver(state=state_with_localhost_with_port, polldevs={})
Expand All @@ -314,7 +314,7 @@ async def test_when_link_transitions_from_flapping_to_up_lasttrans_for_related_e
assert updated_event.portstate == InterfaceState.UP
assert updated_event.lasttrans > initial_lasttrans

async def test_when_link_transitions_from_flapping_to_up_ac_down_for_related_event_should_be_updated(
async def test_when_link_transitions_from_flapping_to_up_it_should_update_ac_down_for_related_event(
self, state_with_localhost_with_port
):
observer = LinkTrapObserver(state=state_with_localhost_with_port, polldevs={})
Expand Down

0 comments on commit 82f94ca

Please sign in to comment.