diff --git a/tests/unit/test_gateway/test_config_receiver.py b/tests/unit/test_gateway/test_config_receiver.py index bfb5c672..5c91a241 100644 --- a/tests/unit/test_gateway/test_config_receiver.py +++ b/tests/unit/test_gateway/test_config_receiver.py @@ -312,12 +312,15 @@ class TestConfigReceiver: "flow2": {"name": "test_flow_2", "steps": []} } - # Mock the flow methods using patch.object to avoid coroutine creation during assignment - start_flow_mock = Mock() - stop_flow_mock = Mock() + # Mock the flow methods to return awaitables + async def mock_start_flow(*args): + pass - with patch.object(config_receiver, 'start_flow', start_flow_mock), \ - patch.object(config_receiver, 'stop_flow', stop_flow_mock): + async def mock_stop_flow(*args): + pass + + with patch.object(config_receiver, 'start_flow', side_effect=mock_start_flow) as start_flow_mock, \ + patch.object(config_receiver, 'stop_flow', side_effect=mock_stop_flow) as stop_flow_mock: # Create mock message with flow1 removed and flow3 added mock_msg = Mock() diff --git a/tests/unit/test_gateway/test_dispatch_config.py b/tests/unit/test_gateway/test_dispatch_config.py index 8932190b..60722ea3 100644 --- a/tests/unit/test_gateway/test_dispatch_config.py +++ b/tests/unit/test_gateway/test_dispatch_config.py @@ -55,7 +55,7 @@ class TestConfigRequestor: with patch.object(ServiceRequestor, 'start', return_value=None), \ patch.object(ServiceRequestor, 'process', return_value=None): requestor = ConfigRequestor( - pulsar_client=MagicMock(), + pulsar_client=Mock(), consumer="test-consumer", subscriber="test-subscriber" ) diff --git a/tests/unit/test_gateway/test_service.py b/tests/unit/test_gateway/test_service.py index 37c00a0f..607ef61a 100644 --- a/tests/unit/test_gateway/test_service.py +++ b/tests/unit/test_gateway/test_service.py @@ -226,9 +226,10 @@ class TestRunFunction: mock_args.metrics_port = 8000 mock_parse_args.return_value = mock_args - # Mock the Api instance and its run method + # Mock the Api instance and its methods to avoid any async behavior mock_api_instance = Mock() mock_api_instance.run = Mock() + mock_api_instance.app_factory = Mock() mock_api.return_value = mock_api_instance # Mock vars() to return a dict @@ -259,9 +260,10 @@ class TestRunFunction: mock_args.metrics = False mock_parse_args.return_value = mock_args - # Mock the Api instance and its run method + # Mock the Api instance and its methods to avoid any async behavior mock_api_instance = Mock() mock_api_instance.run = Mock() + mock_api_instance.app_factory = Mock() mock_api.return_value = mock_api_instance # Mock vars() to return a dict @@ -291,9 +293,10 @@ class TestRunFunction: mock_args.metrics = False mock_parse_args.return_value = mock_args - # Mock the Api instance and its run method + # Mock the Api instance and its methods to avoid any async behavior mock_api_instance = Mock() mock_api_instance.run = Mock() + mock_api_instance.app_factory = Mock() mock_api.return_value = mock_api_instance # Mock vars() to return a dict with all expected arguments