From 29355e9d14de0a8551d6a34908ce8afe52f6ebc9 Mon Sep 17 00:00:00 2001 From: Kekoa Kaaikala Date: Tue, 27 Sep 2022 21:04:42 +0000 Subject: [PATCH] UT: Implement test_handle_scan_data__node_not_upserted_if_no_matching_machine --- .../cc/agent_event_handlers/test_handle_scan_data.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 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 66349656a..1309c33f8 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 @@ -109,8 +109,16 @@ def test_handle_scan_data__node_not_upserted_if_no_matching_agent( assert not node_repository.upsert_communication.called -def test_handle_scan_data__node_not_upserted_if_no_matching_machine(handler: handle_scan_data): - pass +def test_handle_scan_data__node_not_upserted_if_no_matching_machine( + handler: handle_scan_data, + machine_repository: IMachineRepository, + node_repository: INodeRepository, +): + machine_repository.get_machine_by_id = MagicMock(side_effect=UnknownRecordError) + + handler(EVENT) + + assert not node_repository.upsert_communication.called def test_handle_scan_data__upserts_machine_if_did_not_exist(handler: handle_scan_data):