From 5f95b6309ec07323dae3c8c3a3f8c30b7234bf59 Mon Sep 17 00:00:00 2001 From: vitor-aignosi Date: Mon, 5 May 2025 10:06:05 -0300 Subject: [PATCH] SIENTIAPDE-988 Enhance IngestorManager and related tests with notification handling integration - Added notification_handler parameter to IngestorManager and OpcManager initialization for improved event handling. - Updated unit tests to include notification_handler in the Ingestor and IngestorManager instantiation, ensuring proper coverage of new functionality. - Refactored test cases to validate the integration of notification handling across components. --- ingestor/managers/ingestor_manager.py | 2 +- tests/unit/managers/test_ingestor_manager.py | 5 +++-- tests/unit/test_ingestor.py | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ingestor/managers/ingestor_manager.py b/ingestor/managers/ingestor_manager.py index b86eb99..8c05c44 100644 --- a/ingestor/managers/ingestor_manager.py +++ b/ingestor/managers/ingestor_manager.py @@ -54,7 +54,7 @@ class IngestorManager(): f"Initializing OpcManager at {server_config['url']}") manager = OpcManager( server_config['name'], server_config['url'], data_manager, logger, server_config['server_uri'], - server_config.get('cert_path'), server_config.get( + self.notification_handler, server_config.get('cert_path'), server_config.get( 'private_key_path'), server_config.get('server_cert_path') ) diff --git a/tests/unit/managers/test_ingestor_manager.py b/tests/unit/managers/test_ingestor_manager.py index 003cf6d..4929a5a 100644 --- a/tests/unit/managers/test_ingestor_manager.py +++ b/tests/unit/managers/test_ingestor_manager.py @@ -41,7 +41,7 @@ def test___init__(notification_handler_mock, resource_manager_mock, data_manager opc_manager_mock.assert_not_called() data_manager_mock.assert_called_once_with( - "localhost:9092", ingestor.logger) + "localhost:9092", ingestor.logger, ingestor.notification_handler) resource_manager_mock.assert_called_once_with( "localhost", 6379, 60, 60, "test_pod", None, None) @@ -70,7 +70,8 @@ def test_initialize_opc_from_config(opc_manager, ingestor_manager): opc_manager.assert_called_once_with( server_config['name'], server_config['url'], ingestor_manager.data_manager, ingestor_manager.logger, - server_config['server_uri'], server_config['cert_path'], server_config['private_key_path'], + server_config['server_uri'], ingestor_manager.notification_handler, + server_config['cert_path'], server_config['private_key_path'], server_config['server_cert_path'] ) diff --git a/tests/unit/test_ingestor.py b/tests/unit/test_ingestor.py index 5a5b603..448363c 100644 --- a/tests/unit/test_ingestor.py +++ b/tests/unit/test_ingestor.py @@ -123,9 +123,9 @@ def test_prepare_ingestor(ingestor_manager_mock, ingestor): ingestor.pod_id, ingestor.poll_interval, ingestor.logger, + ingestor.notification_handler, ingestor.redis_username, - ingestor.redis_password, - ingestor.notification_handler + ingestor.redis_password ) ingestor_manager.declare_active.assert_called_once() ingestor_manager.get_slot_leases.assert_called_once()