UT: Use MagicMock to simulate internal server error in test_island_mode_post__invalid_mode()

This commit is contained in:
Shreya Malviya 2022-09-21 18:43:26 +05:30
parent 1afafd20dd
commit 60db495cee
1 changed files with 6 additions and 0 deletions

View File

@ -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(