|
6 | 6 | import pytest |
7 | 7 |
|
8 | 8 | from dialogchain import processors, exceptions |
9 | | -from dialogchain.connectors import BaseConnector |
| 9 | +from dialogchain.connectors import Source, Destination |
10 | 10 |
|
11 | 11 |
|
12 | | -class MockConnector(BaseConnector): |
13 | | - """Mock connector for testing processors.""" |
| 12 | +class MockSource(Source): |
| 13 | + """Mock source for testing processors.""" |
14 | 14 |
|
15 | | - def __init__(self, config): |
16 | | - super().__init__(config) |
17 | | - self.sent_messages = [] |
| 15 | + def __init__(self, uri: str = "mock://test"): |
| 16 | + self.uri = uri |
18 | 17 | self.received_messages = [] |
19 | 18 |
|
20 | | - async def connect(self): |
21 | | - self.is_connected = True |
22 | | - |
23 | | - async def disconnect(self): |
24 | | - self.is_connected = False |
| 19 | + async def receive(self) -> AsyncIterator[Any]: |
| 20 | + """Yield messages from the source.""" |
| 21 | + while self.received_messages: |
| 22 | + yield self.received_messages.pop(0) |
| 23 | + |
| 24 | + |
| 25 | +class MockDestination(Destination): |
| 26 | + """Mock destination for testing processors.""" |
25 | 27 |
|
26 | | - async def send(self, message, **kwargs): |
27 | | - self.sent_messages.append((message, kwargs)) |
28 | | - return {"status": "ok"} |
| 28 | + def __init__(self, uri: str = "mock://test"): |
| 29 | + self.uri = uri |
| 30 | + self.sent_messages = [] |
29 | 31 |
|
30 | | - async def receive(self, **kwargs): |
31 | | - if self.received_messages: |
32 | | - return self.received_messages.pop(0) |
33 | | - return None |
| 32 | + async def send(self, message: Any) -> None: |
| 33 | + """Send message to the destination.""" |
| 34 | + self.sent_messages.append(message) |
34 | 35 |
|
35 | 36 |
|
36 | 37 | class TestBaseProcessor: |
|
0 commit comments