From 12fadd0ad65c454dadc8ec0a2541b8d14431e5d0 Mon Sep 17 00:00:00 2001 From: Cyber MacGeddon Date: Thu, 25 Sep 2025 23:55:41 +0100 Subject: [PATCH] Fix tests --- .../test_base/test_flow_parameter_specs.py | 24 ++++++++++++++----- .../test_base/test_llm_service_parameters.py | 24 ++++++++++++++----- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/tests/unit/test_base/test_flow_parameter_specs.py b/tests/unit/test_base/test_flow_parameter_specs.py index fd3a7035..7b28a60d 100644 --- a/tests/unit/test_base/test_flow_parameter_specs.py +++ b/tests/unit/test_base/test_flow_parameter_specs.py @@ -18,7 +18,9 @@ class TestFlowParameterSpecs(IsolatedAsyncioTestCase): def test_parameter_spec_registration(self, mock_async_init): """Test that parameter specs can be registered with flow processors""" # Arrange - mock_async_init.return_value = None + def mock_init(self, **kwargs): + self.config_handlers = [] # Initialize required attribute + mock_async_init.side_effect = mock_init config = { 'id': 'test-flow-processor', @@ -50,7 +52,9 @@ class TestFlowParameterSpecs(IsolatedAsyncioTestCase): def test_mixed_specification_types(self, mock_async_init): """Test registration of mixed specification types (parameters, consumers, producers)""" # Arrange - mock_async_init.return_value = None + def mock_init(self, **kwargs): + self.config_handlers = [] # Initialize required attribute + mock_async_init.side_effect = mock_init config = { 'id': 'test-flow-processor', @@ -85,7 +89,9 @@ class TestFlowParameterSpecs(IsolatedAsyncioTestCase): def test_parameter_spec_metadata(self, mock_async_init): """Test parameter specification metadata handling""" # Arrange - mock_async_init.return_value = None + def mock_init(self, **kwargs): + self.config_handlers = [] # Initialize required attribute + mock_async_init.side_effect = mock_init config = { 'id': 'test-flow-processor', @@ -118,7 +124,9 @@ class TestFlowParameterSpecs(IsolatedAsyncioTestCase): def test_duplicate_parameter_spec_handling(self, mock_async_init): """Test handling of duplicate parameter spec registration""" # Arrange - mock_async_init.return_value = None + def mock_init(self, **kwargs): + self.config_handlers = [] # Initialize required attribute + mock_async_init.side_effect = mock_init config = { 'id': 'test-flow-processor', @@ -147,7 +155,9 @@ class TestFlowParameterSpecs(IsolatedAsyncioTestCase): async def test_parameter_specs_available_to_flows(self, mock_async_init, mock_flow_class): """Test that parameter specs are available when flows are created""" # Arrange - mock_async_init.return_value = None + def mock_init(self, **kwargs): + self.config_handlers = [] # Initialize required attribute + mock_async_init.side_effect = mock_init config = { 'id': 'test-flow-processor', @@ -187,7 +197,9 @@ class TestParameterSpecValidation(IsolatedAsyncioTestCase): def test_parameter_spec_name_validation(self, mock_async_init): """Test parameter spec name validation""" # Arrange - mock_async_init.return_value = None + def mock_init(self, **kwargs): + self.config_handlers = [] # Initialize required attribute + mock_async_init.side_effect = mock_init config = { 'id': 'test-flow-processor', diff --git a/tests/unit/test_base/test_llm_service_parameters.py b/tests/unit/test_base/test_llm_service_parameters.py index e609e04b..78f079a5 100644 --- a/tests/unit/test_base/test_llm_service_parameters.py +++ b/tests/unit/test_base/test_llm_service_parameters.py @@ -18,7 +18,9 @@ class TestLlmServiceParameters(IsolatedAsyncioTestCase): def test_parameter_specs_registration(self, mock_async_init): """Test that LLM service registers model and temperature parameter specs""" # Arrange - mock_async_init.return_value = None + def mock_init(self, **kwargs): + self.config_handlers = [] # Initialize required attribute + mock_async_init.side_effect = mock_init config = { 'id': 'test-llm-service', @@ -40,7 +42,9 @@ class TestLlmServiceParameters(IsolatedAsyncioTestCase): def test_model_parameter_spec_properties(self, mock_async_init): """Test that model parameter spec has correct properties""" # Arrange - mock_async_init.return_value = None + def mock_init(self, **kwargs): + self.config_handlers = [] # Initialize required attribute + mock_async_init.side_effect = mock_init config = { 'id': 'test-llm-service', @@ -64,7 +68,9 @@ class TestLlmServiceParameters(IsolatedAsyncioTestCase): def test_temperature_parameter_spec_properties(self, mock_async_init): """Test that temperature parameter spec has correct properties""" # Arrange - mock_async_init.return_value = None + def mock_init(self, **kwargs): + self.config_handlers = [] # Initialize required attribute + mock_async_init.side_effect = mock_init config = { 'id': 'test-llm-service', @@ -88,7 +94,9 @@ class TestLlmServiceParameters(IsolatedAsyncioTestCase): async def test_on_request_extracts_parameters_from_flow(self, mock_async_init): """Test that on_request method extracts model and temperature from flow""" # Arrange - mock_async_init.return_value = None + def mock_init(self, **kwargs): + self.config_handlers = [] # Initialize required attribute + mock_async_init.side_effect = mock_init config = { 'id': 'test-llm-service', @@ -147,7 +155,9 @@ class TestLlmServiceParameters(IsolatedAsyncioTestCase): async def test_on_request_handles_missing_parameters_gracefully(self, mock_async_init): """Test that on_request handles missing parameters gracefully""" # Arrange - mock_async_init.return_value = None + def mock_init(self, **kwargs): + self.config_handlers = [] # Initialize required attribute + mock_async_init.side_effect = mock_init config = { 'id': 'test-llm-service', @@ -198,7 +208,9 @@ class TestLlmServiceParameters(IsolatedAsyncioTestCase): async def test_on_request_error_handling_preserves_behavior(self, mock_async_init): """Test that parameter extraction doesn't break existing error handling""" # Arrange - mock_async_init.return_value = None + def mock_init(self, **kwargs): + self.config_handlers = [] # Initialize required attribute + mock_async_init.side_effect = mock_init config = { 'id': 'test-llm-service',