UT: Deparametrize a test

TCP scan events do not contain OS information.
This commit is contained in:
Mike Salvatore 2022-09-30 13:10:57 -04:00
parent 97061ea61c
commit 2811009019
1 changed files with 2 additions and 7 deletions

View File

@ -262,19 +262,14 @@ def test_machine_not_upserted(event, handler, machine_repository: IMachineReposi
assert not machine_repository.upsert_machine.called
@pytest.mark.parametrize(
"event,handler",
[(PING_SCAN_EVENT, HANDLE_PING_SCAN_METHOD), (TCP_SCAN_EVENT, HANDLE_TCP_SCAN_METHOD)],
indirect=["handler"],
)
def test_machine_not_upserted_if_existing_machine_has_os(
event, handler, machine_repository: IMachineRepository, request
scan_event_handler, machine_repository: IMachineRepository, request
):
machine_with_os = TARGET_MACHINE
machine_with_os.operating_system = OperatingSystem.WINDOWS
machine_repository.get_machine_by_ip = MagicMock(return_value=machine_with_os)
handler(event)
scan_event_handler.handle_ping_scan_event(PING_SCAN_EVENT)
assert not machine_repository.upsert_machine.called