mirror of
https://github.com/langgenius/dify.git
synced 2026-05-10 05:56:31 +08:00
fix unit tests
This commit is contained in:
parent
53c0dde3d5
commit
c294006ecf
@ -12,10 +12,11 @@ from models.model import AppMode
|
||||
|
||||
|
||||
class FakeSubscription:
|
||||
def __init__(self, message_queue: queue.Queue[bytes], state: dict[str, bool]) -> None:
|
||||
def __init__(self, message_queue: queue.Queue[bytes], state: dict[str, bool], replay: bool = False) -> None:
|
||||
self._queue = message_queue
|
||||
self._state = state
|
||||
self._closed = False
|
||||
self._replay = replay
|
||||
|
||||
def __enter__(self):
|
||||
self._state["subscribed"] = True
|
||||
@ -43,8 +44,8 @@ class FakeTopic:
|
||||
self._queue: queue.Queue[bytes] = queue.Queue()
|
||||
self._state = {"subscribed": False}
|
||||
|
||||
def subscribe(self) -> FakeSubscription:
|
||||
return FakeSubscription(self._queue, self._state)
|
||||
def subscribe(self, replay: bool = False) -> FakeSubscription:
|
||||
return FakeSubscription(self._queue, self._state, replay)
|
||||
|
||||
def publish(self, payload: bytes) -> None:
|
||||
self._queue.put(payload)
|
||||
|
||||
@ -96,8 +96,9 @@ class _SessionMaker:
|
||||
|
||||
|
||||
class _SubscriptionContext:
|
||||
def __init__(self, subscription: Any) -> None:
|
||||
def __init__(self, subscription: Any, replay: bool = False) -> None:
|
||||
self._subscription = subscription
|
||||
self._replay = replay
|
||||
|
||||
def __enter__(self) -> Any:
|
||||
return self._subscription
|
||||
@ -110,8 +111,8 @@ class _Topic:
|
||||
def __init__(self, subscription: Any) -> None:
|
||||
self._subscription = subscription
|
||||
|
||||
def subscribe(self) -> _SubscriptionContext:
|
||||
return _SubscriptionContext(self._subscription)
|
||||
def subscribe(self, replay: bool = False) -> _SubscriptionContext:
|
||||
return _SubscriptionContext(self._subscription, replay)
|
||||
|
||||
|
||||
class _StaticSubscription:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user