Rev gateway tests

This commit is contained in:
Cyber MacGeddon 2025-07-14 12:59:14 +01:00
parent 7f0dfdf520
commit 198c4303d7
3 changed files with 15 additions and 9 deletions

View file

@ -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()

View file

@ -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"
)

View file

@ -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