Skip to content

Commit 564074d

Browse files
author
Tom Softreck
committed
update
1 parent fda7d84 commit 564074d

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

tests/unit/test_processors.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,32 @@
66
import pytest
77

88
from dialogchain import processors, exceptions
9-
from dialogchain.connectors import BaseConnector
9+
from dialogchain.connectors import Source, Destination
1010

1111

12-
class MockConnector(BaseConnector):
13-
"""Mock connector for testing processors."""
12+
class MockSource(Source):
13+
"""Mock source for testing processors."""
1414

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
1817
self.received_messages = []
1918

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."""
2527

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 = []
2931

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)
3435

3536

3637
class TestBaseProcessor:

0 commit comments

Comments
 (0)