1111
1212# Import our test HTTPSource
1313from .test_https import HTTPSource
14+ from dialogchain .engine import CamelRouterEngine
1415
1516# Get the directory of the current file
1617TEST_DIR = Path (__file__ ).parent
@@ -109,10 +110,18 @@ async def test_mock_server_endpoints(mock_server, config):
109110 assert "event" in events [0 ], f"Event missing 'event' key: { events [0 ]} "
110111 assert "value" in events [0 ], f"Event missing 'value' key: { events [0 ]} "
111112
113+ class TestCamelRouterEngine (CamelRouterEngine ):
114+ """Test engine that can handle HTTP sources"""
115+
116+ async def create_source (self , uri : str ):
117+ """Create source connector from URI"""
118+ if uri .startswith ('http' ):
119+ return HTTPSource (uri )
120+ return await super ().create_source (uri )
121+
112122@pytest .mark .asyncio
113123async def test_dialogchain_with_mock_server (mock_server , config ):
114124 """Test DialogChain with the mock server"""
115- from dialogchain .engine import CamelRouterEngine
116125 from dialogchain .connectors import HTTPDestination
117126
118127 # Get the port from config
@@ -135,18 +144,8 @@ async def test_dialogchain_with_mock_server(mock_server, config):
135144 ]
136145 }
137146
138- # Initialize the engine with test config
139- engine = CamelRouterEngine (test_config , verbose = True )
140-
141- # Patch the create_source method to use our HTTPSource
142- original_create_source = engine .create_source
143-
144- def patched_create_source (uri ):
145- if uri .startswith ('http' ):
146- return HTTPSource (uri )
147- return original_create_source (uri )
148-
149- engine .create_source = patched_create_source
147+ # Initialize our test engine with the config
148+ engine = TestCamelRouterEngine (test_config , verbose = True )
150149
151150 # Test the route processing
152151 async with aiohttp .ClientSession () as session :
0 commit comments