From a0a176f07af9b34e55f13c5994e3e290f3ac7eb9 Mon Sep 17 00:00:00 2001 From: Ashish Jabble Date: Wed, 18 Oct 2023 20:24:46 +0530 Subject: [PATCH] python unit tests fixes when run in suite; issue with scheduler shared instance is not resetting on completion of test scenario (#1203) Signed-off-by: ashish-jabble --- .../core/api/control_service/test_script_management.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/unit/python/fledge/services/core/api/control_service/test_script_management.py b/tests/unit/python/fledge/services/core/api/control_service/test_script_management.py index 596762bc91..b7d2b34517 100644 --- a/tests/unit/python/fledge/services/core/api/control_service/test_script_management.py +++ b/tests/unit/python/fledge/services/core/api/control_service/test_script_management.py @@ -84,6 +84,7 @@ async def test_get_all_scripts(self, client): with patch.object(c_mgr, 'get_category_all_items', return_value=get_cat) as patch_get_all_items: resp = await client.get('/fledge/control/script') assert 200 == resp.status + server.Server.scheduler = None result = await resp.text() json_response = json.loads(result) assert 'scripts' in json_response @@ -162,6 +163,7 @@ async def mock_manual_schedule(name): with patch.object(server.Server.scheduler, 'get_schedule_by_name', return_value=get_sch) as patch_get_schedule_by_name: resp = await client.get('/fledge/control/script/{}'.format(script_name)) + server.Server.scheduler = None assert 200 == resp.status result = await resp.text() json_response = json.loads(result) @@ -583,6 +585,7 @@ def d_schedule(*args): with patch.object(AuditLogger, 'information', return_value=arv) as audit_info_patch: resp = await client.delete('/fledge/control/script/{}'.format(script_name)) + server.Server.scheduler = None assert 200 == resp.status result = await resp.text() json_response = json.loads(result) @@ -739,6 +742,7 @@ async def test_schedule_found_for_configuration_script(self, client): with patch.object(server.Server.scheduler, 'get_schedules', return_value=get_sch) as patch_get_schedules: resp = await client.post('/fledge/control/script/{}/schedule'.format(script_name)) + server.Server.scheduler = None assert 400 == resp.status result = await resp.text() json_response = json.loads(result) @@ -788,6 +792,7 @@ async def test_schedule_configuration_for_script(self, client): with patch.object(server.Server.scheduler, 'queue_task', return_value=queue) as patch_queue_task: resp = await client.post('/fledge/control/script/{}/schedule'.format(script_name)) + server.Server.scheduler = None assert 200 == resp.status result = await resp.text() json_response = json.loads(result)