From 7cf424a3b2af427f54e41f33aafbcbd3e28b371a Mon Sep 17 00:00:00 2001 From: Cyber MacGeddon Date: Thu, 16 Apr 2026 17:17:32 +0100 Subject: [PATCH] Remove dupe attribute set --- .../unit/test_base/test_flow_base_modules.py | 2 +- tests/unit/test_base/test_flow_processor.py | 54 +++++++++++-------- .../unit/test_cores/test_knowledge_manager.py | 4 +- .../test_gateway/test_dispatch_manager.py | 14 ++--- .../trustgraph/gateway/dispatch/manager.py | 2 +- 5 files changed, 42 insertions(+), 34 deletions(-) diff --git a/tests/unit/test_base/test_flow_base_modules.py b/tests/unit/test_base/test_flow_base_modules.py index 33a3c4c2..5bbd7a18 100644 --- a/tests/unit/test_base/test_flow_base_modules.py +++ b/tests/unit/test_base/test_flow_base_modules.py @@ -11,7 +11,7 @@ def test_parameter_spec_is_a_spec_and_adds_parameter_value(): flow = MagicMock(parameter={}) processor = MagicMock() - spec.add(flow, processor, {"temperature": 0.7}) + spec.add(flow, processor, {"parameters": {"temperature": 0.7}}) assert isinstance(spec, Spec) assert "temperature" in flow.parameter diff --git a/tests/unit/test_base/test_flow_processor.py b/tests/unit/test_base/test_flow_processor.py index 8672831a..dc2e602f 100644 --- a/tests/unit/test_base/test_flow_processor.py +++ b/tests/unit/test_base/test_flow_processor.py @@ -19,9 +19,11 @@ class TestFlowProcessorSimple(IsolatedAsyncioTestCase): async def test_flow_processor_initialization_basic(self, mock_register_config, mock_async_init): """Test basic FlowProcessor initialization""" # Arrange - mock_async_init.return_value = None + def set_id(**params): + pass + mock_async_init.side_effect = set_id mock_register_config.return_value = None - + config = { 'id': 'test-flow-processor', 'taskgroup': AsyncMock() @@ -33,10 +35,10 @@ class TestFlowProcessorSimple(IsolatedAsyncioTestCase): # Assert # Verify AsyncProcessor.__init__ was called mock_async_init.assert_called_once() - + # Verify register_config_handler was called with the correct handler mock_register_config.assert_called_once_with( - processor.on_configure_flows, types=["active-flow"] + processor.on_configure_flows, types=["processor:test-flow-processor"] ) # Verify FlowProcessor-specific initialization @@ -50,9 +52,11 @@ class TestFlowProcessorSimple(IsolatedAsyncioTestCase): async def test_register_specification(self, mock_register_config, mock_async_init): """Test registering a specification""" # Arrange - mock_async_init.return_value = None + def set_id(**params): + pass + mock_async_init.side_effect = set_id mock_register_config.return_value = None - + config = { 'id': 'test-flow-processor', 'taskgroup': AsyncMock() @@ -77,7 +81,7 @@ class TestFlowProcessorSimple(IsolatedAsyncioTestCase): # Arrange mock_async_init.return_value = None mock_register_config.return_value = None - + config = { 'id': 'test-flow-processor', 'taskgroup': AsyncMock() @@ -110,7 +114,7 @@ class TestFlowProcessorSimple(IsolatedAsyncioTestCase): # Arrange mock_async_init.return_value = None mock_register_config.return_value = None - + config = { 'id': 'test-flow-processor', 'taskgroup': AsyncMock() @@ -143,7 +147,7 @@ class TestFlowProcessorSimple(IsolatedAsyncioTestCase): # Arrange mock_async_init.return_value = None mock_register_config.return_value = None - + config = { 'id': 'test-flow-processor', 'taskgroup': AsyncMock() @@ -165,7 +169,7 @@ class TestFlowProcessorSimple(IsolatedAsyncioTestCase): # Arrange mock_async_init.return_value = None mock_register_config.return_value = None - + config = { 'id': 'test-flow-processor', 'taskgroup': AsyncMock() @@ -182,8 +186,8 @@ class TestFlowProcessorSimple(IsolatedAsyncioTestCase): 'test-flow': {'config': 'test-config'} } config_data = { - 'active-flow': { - 'test-processor': '{"test-flow": {"config": "test-config"}}' + 'processor:test-processor': { + 'test-flow': '{"config": "test-config"}' } } @@ -203,7 +207,7 @@ class TestFlowProcessorSimple(IsolatedAsyncioTestCase): # Arrange mock_async_init.return_value = None mock_register_config.return_value = None - + config = { 'id': 'test-flow-processor', 'taskgroup': AsyncMock() @@ -214,8 +218,8 @@ class TestFlowProcessorSimple(IsolatedAsyncioTestCase): # Configuration without flows for this processor config_data = { - 'active-flow': { - 'other-processor': '{"other-flow": {"config": "other-config"}}' + 'processor:other-processor': { + 'other-flow': '{"config": "other-config"}' } } @@ -234,7 +238,7 @@ class TestFlowProcessorSimple(IsolatedAsyncioTestCase): # Arrange mock_async_init.return_value = None mock_register_config.return_value = None - + config = { 'id': 'test-flow-processor', 'taskgroup': AsyncMock() @@ -263,7 +267,7 @@ class TestFlowProcessorSimple(IsolatedAsyncioTestCase): # Arrange mock_async_init.return_value = None mock_register_config.return_value = None - + config = { 'id': 'test-flow-processor', 'taskgroup': AsyncMock() @@ -278,8 +282,8 @@ class TestFlowProcessorSimple(IsolatedAsyncioTestCase): # First configuration - start flow1 config_data1 = { - 'active-flow': { - 'test-processor': '{"flow1": {"config": "config1"}}' + 'processor:test-processor': { + 'flow1': '{"config": "config1"}' } } @@ -287,8 +291,8 @@ class TestFlowProcessorSimple(IsolatedAsyncioTestCase): # Second configuration - stop flow1, start flow2 config_data2 = { - 'active-flow': { - 'test-processor': '{"flow2": {"config": "config2"}}' + 'processor:test-processor': { + 'flow2': '{"config": "config2"}' } } @@ -310,7 +314,9 @@ class TestFlowProcessorSimple(IsolatedAsyncioTestCase): async def test_start_calls_parent(self, mock_parent_start, mock_register_config, mock_async_init): """Test that start() calls parent start method""" # Arrange - mock_async_init.return_value = None + def set_id(**params): + pass + mock_async_init.side_effect = set_id mock_register_config.return_value = None mock_parent_start.return_value = None @@ -332,7 +338,9 @@ class TestFlowProcessorSimple(IsolatedAsyncioTestCase): async def test_add_args_calls_parent(self, mock_register_config, mock_async_init): """Test that add_args() calls parent add_args method""" # Arrange - mock_async_init.return_value = None + def set_id(**params): + pass + mock_async_init.side_effect = set_id mock_register_config.return_value = None mock_parser = MagicMock() diff --git a/tests/unit/test_cores/test_knowledge_manager.py b/tests/unit/test_cores/test_knowledge_manager.py index 76095690..80c27fe8 100644 --- a/tests/unit/test_cores/test_knowledge_manager.py +++ b/tests/unit/test_cores/test_knowledge_manager.py @@ -30,8 +30,8 @@ def mock_flow_config(): mock_config.flows = { "test-flow": { "interfaces": { - "triples-store": "test-triples-queue", - "graph-embeddings-store": "test-ge-queue" + "triples-store": {"flow": "test-triples-queue"}, + "graph-embeddings-store": {"flow": "test-ge-queue"} } } } diff --git a/tests/unit/test_gateway/test_dispatch_manager.py b/tests/unit/test_gateway/test_dispatch_manager.py index 83969fdd..4ebcb5b9 100644 --- a/tests/unit/test_gateway/test_dispatch_manager.py +++ b/tests/unit/test_gateway/test_dispatch_manager.py @@ -277,7 +277,7 @@ class TestDispatcherManager: # Setup test flow manager.flows["test_flow"] = { "interfaces": { - "triples-store": {"queue": "test_queue"} + "triples-store": {"flow": "test_queue"} } } @@ -298,7 +298,7 @@ class TestDispatcherManager: backend=mock_backend, ws="ws", running="running", - queue={"queue": "test_queue"} + queue="test_queue" ) mock_dispatcher.start.assert_called_once() assert result == mock_dispatcher @@ -328,7 +328,7 @@ class TestDispatcherManager: # Setup test flow manager.flows["test_flow"] = { "interfaces": { - "triples-store": {"queue": "test_queue"} + "triples-store": {"flow": "test_queue"} } } @@ -350,7 +350,7 @@ class TestDispatcherManager: # Setup test flow manager.flows["test_flow"] = { "interfaces": { - "triples-store": {"queue": "test_queue"} + "triples-store": {"flow": "test_queue"} } } @@ -370,7 +370,7 @@ class TestDispatcherManager: backend=mock_backend, ws="ws", running="running", - queue={"queue": "test_queue"}, + queue="test_queue", consumer="api-gateway-test-uuid", subscriber="api-gateway-test-uuid" ) @@ -481,7 +481,7 @@ class TestDispatcherManager: # Setup test flow manager.flows["test_flow"] = { "interfaces": { - "text-load": {"queue": "text_load_queue"} + "text-load": {"flow": "text_load_queue"} } } @@ -502,7 +502,7 @@ class TestDispatcherManager: # Verify dispatcher was created with correct parameters mock_dispatcher_class.assert_called_once_with( backend=mock_backend, - queue={"queue": "text_load_queue"} + queue="text_load_queue" ) mock_dispatcher.start.assert_called_once() mock_dispatcher.process.assert_called_once_with("data", "responder") diff --git a/trustgraph-flow/trustgraph/gateway/dispatch/manager.py b/trustgraph-flow/trustgraph/gateway/dispatch/manager.py index 462a5bec..592120b1 100644 --- a/trustgraph-flow/trustgraph/gateway/dispatch/manager.py +++ b/trustgraph-flow/trustgraph/gateway/dispatch/manager.py @@ -320,7 +320,7 @@ class DispatcherManager: elif kind in sender_dispatchers: dispatcher = sender_dispatchers[kind]( backend = self.backend, - queue = qconfig, + queue = qconfig["flow"], ) else: raise RuntimeError("Invalid kind")