From 4c3289647ba5ebe3eb463c62092a50064de4cce5 Mon Sep 17 00:00:00 2001 From: vitor-aignosi Date: Fri, 17 Oct 2025 16:09:41 -0300 Subject: [PATCH] SIENTIAPDE-1318 Refactor app.py and enhance unit tests for better clarity and structure - Updated `app.py` to improve async compatibility with a clearer comment. - Added blank lines in `test_ingestor.py` for improved readability and organization of test cases. --- ingestor/app.py | 2 +- tests/unit/test_ingestor.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ingestor/app.py b/ingestor/app.py index 4bc526c..54231eb 100644 --- a/ingestor/app.py +++ b/ingestor/app.py @@ -55,7 +55,7 @@ async def main(): metrics.APP_LOOP_COUNT.labels(pod_id=POD_ID).inc() # Increment loop counter # Use asyncio.sleep instead of exit_signal.wait for better async compatibility - await asyncio.sleep(ingestor.poll_interval) # NOSONAR + await asyncio.sleep(ingestor.poll_interval) # NOSONAR except KeyboardInterrupt: # Handle Ctrl+C gracefully print('KeyboardInterrupt received. Setting exit_signal flag.') diff --git a/tests/unit/test_ingestor.py b/tests/unit/test_ingestor.py index cd8d7ed..b636f2b 100644 --- a/tests/unit/test_ingestor.py +++ b/tests/unit/test_ingestor.py @@ -192,6 +192,7 @@ async def test_manage_leases_no_ingestor_manager(ingestor_manager_started): assert await ingestor_manager_started.manage_leases(2, 2, 5) is None + @mark.asyncio async def test_manage_leases_no_available_slots_no_extra_slots(ingestor_manager_started): ingestor_manager_started.handle_acquired_tags = MagicMock() @@ -294,6 +295,7 @@ async def test_loop_no_ingestor_manager(ingestor_manager_started): assert await ingestor_manager_started.loop() is None + @mark.asyncio async def test_update_ingestor_manager(ingestor_manager_started): ingestor_manager_started.ingestor_manager.managed_tags = { @@ -318,8 +320,9 @@ async def test_update_ingestor_manager(ingestor_manager_started): [call('slot_to_update'), call('slot_to_delete')] ) + @mark.asyncio async def test_update_ingestor_manager_no_ingestor_manager(ingestor_manager_started): ingestor_manager_started.ingestor_manager = None - await ingestor_manager_started.update_ingestor_manager({}) \ No newline at end of file + await ingestor_manager_started.update_ingestor_manager({})