From ce8219aa6d9fc92525c6f0077328289d3af01c3b Mon Sep 17 00:00:00 2001 From: Kekoa Kaaikala Date: Tue, 27 Sep 2022 20:53:56 +0000 Subject: [PATCH] UT: Implement test_handle_scan_data__upserts_node --- .../test_handle_scan_data.py | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/monkey/tests/unit_tests/monkey_island/cc/agent_event_handlers/test_handle_scan_data.py b/monkey/tests/unit_tests/monkey_island/cc/agent_event_handlers/test_handle_scan_data.py index 08555edc1..a339a208b 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/agent_event_handlers/test_handle_scan_data.py +++ b/monkey/tests/unit_tests/monkey_island/cc/agent_event_handlers/test_handle_scan_data.py @@ -81,13 +81,24 @@ def test_handle_scan_data__upserts_machine( expected_machine.operating_system = OperatingSystem.LINUX assert machine_repository.upsert_machine.called_with(expected_machine) - assert node_repository.upsert_communication.called_with( - MACHINE.id, expected_machine.id, CommunicationType.SCANNED + + +def test_handle_scan_data__upserts_node( + handler: handle_scan_data, + machine_repository: IMachineRepository, + node_repository: INodeRepository, +): + event = PingScanEvent( + source=AGENT_ID, + target=IPv4Address("10.10.10.1"), + scan_data=PingScanData(True, OperatingSystem.LINUX), ) + machine_repository.get_machine_by_id = MagicMock(return_value=STORED_MACHINE) + handler(event) - -def test_handle_scan_data__upserts_node(handler: handle_scan_data): - pass + assert node_repository.upsert_communication.called_with( + MACHINE.id, STORED_MACHINE.id, CommunicationType.SCANNED + ) def test_handle_scan_data__node_not_upserted_if_no_matching_agent(handler: handle_scan_data):