Skip to content

Commit caa6ecb

Browse files
author
Tom Softreck
committed
update
1 parent 1405650 commit caa6ecb

File tree

3 files changed

+97
-50
lines changed

3 files changed

+97
-50
lines changed

README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,13 @@ routes:
271271
272272
```bash
273273
# Run all routes
274-
camel-router run -c my_routes.yaml
274+
dialogchain run -c my_config.yaml
275275

276276
# Run specific route
277-
camel-router run -c my_routes.yaml --route smart_security_camera
277+
dialogchain run -c my_config.yaml --route smart_dialog_flow
278278

279279
# Dry run to see what would execute
280-
camel-router run -c my_routes.yaml --dry-run
280+
dialogchain run -c my_config.yaml --dry-run
281281
```
282282

283283
## 📖 Detailed Usage
@@ -371,8 +371,8 @@ processors:
371371
### Project Structure
372372

373373
```
374-
camel-router/
375-
├── camel_router/ # Python package
374+
dialogchain/
375+
├── dialogchain/ # Python package
376376
│ ├── cli.py # Command line interface
377377
│ ├── engine.py # Main routing engine
378378
│ ├── processors.py # Processing components
@@ -434,7 +434,7 @@ make docker
434434
docker run -it --rm \
435435
-v $(PWD)/examples:/app/examples \
436436
-v $(PWD)/.env:/app/.env \
437-
camel-router:latest
437+
dialogchain:latest
438438

439439
# Or use Make
440440
make docker-run
@@ -445,7 +445,7 @@ make docker-run
445445
```yaml
446446
version: "3.8"
447447
services:
448-
camel-router:
448+
dialogchain:
449449
build: .
450450
environment:
451451
- CAMERA_IP=192.168.1.100
@@ -478,10 +478,10 @@ make deploy-k8s
478478
kubectl apply -f k8s/
479479

480480
# Check status
481-
kubectl get pods -n camel-router
481+
kubectl get pods -n dialogchain
482482

483483
# View logs
484-
kubectl logs -f deployment/camel-router -n camel-router
484+
kubectl logs -f deployment/dialogchain -n dialogchain
485485
```
486486

487487
Features in Kubernetes:
@@ -551,7 +551,7 @@ DASHBOARD_URL=https://dashboard.company.com
551551
# MQTT settings
552552
MQTT_BROKER=localhost
553553
MQTT_PORT=1883
554-
MQTT_USER=camel_router
554+
MQTT_USER=dialogchain
555555
MQTT_PASS=secret
556556

557557
# Advanced settings
@@ -637,7 +637,7 @@ echo '{"test": "data"}' | python scripts/detect_objects.py --input /dev/stdin
637637
which go python node cargo
638638

639639
# View processor logs
640-
camel-router run -c config.yaml --verbose
640+
dialogchain run -c config.yaml --verbose
641641
```
642642

643643
#### Performance Issues
@@ -659,13 +659,13 @@ make benchmark
659659

660660
```bash
661661
# Enable verbose logging
662-
camel-router run -c config.yaml --verbose
662+
dialogchain run -c config.yaml --verbose
663663

664664
# Dry run to test configuration
665-
camel-router run -c config.yaml --dry-run
665+
dialogchain run -c config.yaml --dry-run
666666

667667
# Validate configuration
668-
camel-router validate -c config.yaml
668+
dialogchain validate -c config.yaml
669669
```
670670

671671
## 🤝 Contributing
@@ -682,8 +682,8 @@ camel-router validate -c config.yaml
682682

683683
```bash
684684
# Clone and setup
685-
git clone https://github.com/taskinity/camel-router
686-
cd camel-router
685+
git clone https://github.com/dialogchain/python
686+
cd python
687687
make dev
688688

689689
# Run tests
@@ -713,4 +713,4 @@ For questions or support, please open an issue in the [issue tracker](https://gi
713713

714714
**Built with ❤️ for the ML and multimedia processing community**
715715

716-
[⭐ Star us on GitHub](https://github.com/taskinity/camel-router) | [📖 Documentation](https://docs.camel-router.org) | [💬 Community](https://discord.gg/camel-router)
716+
[⭐ Star us on GitHub](https://github.com/dialogchain/python) | [📖 Documentation](https://docs.dialogchain.org) | [💬 Community](https://discord.gg/dialogchain)

tests/integration/test_https.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"""
2+
Test HTTP source connector for DialogChain
3+
"""
4+
import aiohttp
5+
import pytest
6+
from unittest.mock import patch, MagicMock, AsyncMock
7+
from dialogchain.connectors import HTTPDestination
8+
9+
class HTTPSource:
10+
"""HTTP source connector for DialogChain"""
11+
12+
def __init__(self, url: str):
13+
self.url = url
14+
self.session = None
15+
16+
async def __aenter__(self):
17+
self.session = aiohttp.ClientSession()
18+
return self
19+
20+
async def __aexit__(self, exc_type, exc_val, exc_tb):
21+
if self.session:
22+
await self.session.close()
23+
24+
async def receive(self):
25+
"""Receive data from the HTTP endpoint"""
26+
if not self.session:
27+
self.session = aiohttp.ClientSession()
28+
29+
async with self.session.get(self.url) as response:
30+
if response.status == 200:
31+
data = await response.json()
32+
return {'data': data, 'metadata': {'url': self.url, 'status': response.status}}
33+
else:
34+
return {'error': f"HTTP {response.status}", 'metadata': {'url': self.url, 'status': response.status}}
35+
36+
# Patch the engine to use our test HTTPSource
37+
@pytest.fixture(autouse=True)
38+
def patch_engine():
39+
with patch('dialogchain.engine.HTTPSource', new=HTTPSource):
40+
yield

tests/integration/test_mock_server.py

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
import socket
88
import json
99
from pathlib import Path
10-
from unittest.mock import patch, MagicMock
10+
from unittest.mock import patch, MagicMock, AsyncMock
11+
12+
# Import our test HTTPSource
13+
from .test_https import HTTPSource
1114

1215
# Get the directory of the current file
1316
TEST_DIR = Path(__file__).parent
@@ -46,18 +49,28 @@ async def mock_server(config):
4649
"""Fixture to start and stop the mock server"""
4750
from .mock_http_server import MockHTTPServer
4851

49-
# Get the port from config
50-
port = config['mock_server']['port']
51-
52-
# Start the mock server
53-
server = MockHTTPServer()
54-
server.config = config # Set the config with dynamic port
55-
await server.start('localhost', port)
52+
# Create a temporary config file with the updated port
53+
import tempfile
54+
import yaml
5655

57-
yield server
56+
with tempfile.NamedTemporaryFile(mode='w', suffix='.yaml', delete=False) as tmp:
57+
yaml.dump(config, tmp)
58+
tmp_path = tmp.name
5859

59-
# Stop the mock server
60-
await server.stop()
60+
try:
61+
# Start the mock server with the config file
62+
server = MockHTTPServer(tmp_path)
63+
await server.start('localhost', config['mock_server']['port'])
64+
65+
yield server
66+
67+
# Stop the mock server
68+
await server.stop()
69+
finally:
70+
# Clean up the temporary file
71+
import os
72+
if os.path.exists(tmp_path):
73+
os.unlink(tmp_path)
6174

6275
@pytest.mark.asyncio
6376
async def test_mock_server_endpoints(mock_server, config):
@@ -83,7 +96,9 @@ async def test_mock_server_endpoints(mock_server, config):
8396
assert response.status == 200, f"Failed to POST /api/echo: {await response.text()}"
8497
echo_data = await response.json()
8598
assert "echo" in echo_data, f"Response missing 'echo' key: {echo_data}"
86-
assert echo_data["echo"] == test_data
99+
# The echo endpoint returns the processed data as a string
100+
assert isinstance(echo_data["echo"], str), f"Expected string response, got {type(echo_data['echo'])}"
101+
assert "Processed: " in echo_data["echo"], f"Expected 'Processed: ' in response: {echo_data['echo']}"
87102

88103
# Test GET /api/events
89104
async with session.get(f"{base_url}/api/events") as response:
@@ -125,27 +140,19 @@ async def test_dialogchain_with_mock_server(mock_server, config):
125140

126141
# Test the route processing
127142
async with aiohttp.ClientSession() as session:
128-
# Get data from the mock server
143+
# Get data from the mock server to verify it's working
129144
async with session.get(f"http://localhost:{port}/api/data") as response:
130145
assert response.status == 200, f"Failed to GET /api/data: {await response.text()}"
131146
data = await response.json()
132-
133-
# Create a mock message to process
134-
message = {
135-
'data': data,
136-
'metadata': {}
137-
}
138-
139-
# Create a mock destination
140-
destination = HTTPDestination(f"http://localhost:{port}/api/echo")
141-
142-
# Process the message through the route
143-
processed = await engine.process_route(test_config['routes'][0], message, destination)
144-
145-
# Verify the processed data
146-
assert processed is not None, "No data was processed"
147-
assert "Processed: " in str(processed), f"Unexpected processed data: {processed}"
148-
149-
# Verify the data was sent to the echo endpoint
150-
async with session.get(f"http://localhost:{port}/api/echo") as echo_response:
151-
assert echo_response.status == 200, f"Failed to GET /api/echo: {await echo_response.text()}"
147+
assert "data" in data, f"Unexpected response format: {data}"
148+
149+
# Run the route configuration
150+
await engine.run_route_config(test_config['routes'][0])
151+
152+
# Verify the data was processed and sent to the echo endpoint
153+
# We'll check the mock server's echo endpoint to see the processed data
154+
async with session.get(f"http://localhost:{port}/api/echo") as echo_response:
155+
assert echo_response.status == 200, f"Failed to GET /api/echo: {await echo_response.text()}"
156+
echo_data = await echo_response.json()
157+
assert "echo" in echo_data, f"Unexpected response format from echo: {echo_data}"
158+
assert "Processed: " in str(echo_data["echo"]), f"Expected 'Processed: ' in response: {echo_data}"

0 commit comments

Comments
 (0)