From 60db495cee63a22426c922ce52389e46f9d32041 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Wed, 21 Sep 2022 18:43:26 +0530 Subject: [PATCH] UT: Use MagicMock to simulate internal server error in test_island_mode_post__invalid_mode() --- .../monkey_island/cc/resources/test_island_mode.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/monkey/tests/unit_tests/monkey_island/cc/resources/test_island_mode.py b/monkey/tests/unit_tests/monkey_island/cc/resources/test_island_mode.py index 0b9403362..7d48e3b2f 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/resources/test_island_mode.py +++ b/monkey/tests/unit_tests/monkey_island/cc/resources/test_island_mode.py @@ -52,6 +52,12 @@ def test_island_mode_post__invalid_mode(flask_client): def test_island_mode_post__internal_server_error(build_flask_client): container = StubDIContainer() + in_memory_simulation_repository = InMemorySimulationRepository() + container.register_instance(ISimulationRepository, in_memory_simulation_repository) + + mock_island_event_queue = MagicMock(spec=IIslandEventQueue) + mock_island_event_queue.publish.side_effect = Exception + container.register_instance(IIslandEventQueue, mock_island_event_queue) with build_flask_client(container) as flask_client: resp = flask_client.put(