-
Couldn't load subscription status.
- Fork 4
Implement stream() for FakeService #87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Marenz
commented
Sep 19, 2024
- TestService: Minor refactor of imports
- Add support in FakeService for stream()
Signed-off-by: Mathias L. Baumann <[email protected]>
039d62e to
23ff599
Compare
| self._last_id = 0 | ||
| self._stream_channel = Broadcast(name="dispatch-stream") | ||
| self._stream_sender = self._stream_channel.new_sender() | ||
| self.dispatches = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you have this, it makes no sense to have the default_factory in dispatches: dict[int, list[Dispatch]] = dataclasses.field(default_factory=dict).
I would add a default_factory for the channel too instead of implementing __init__() though.
23ff599 to
1ebd6b8
Compare
|
|
||
| def __post_init__(self) -> None: | ||
| """Initialize the stream sender.""" | ||
| self._stream_sender = self._stream_channel.new_sender() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest I don't see a point on having FakeService be a dataclass at this point, it is causing more harm than good. You have one public property and 3 property hacks. Why not making it a regular class with a regular __init__()?
Also adds a test for it. Signed-off-by: Mathias L. Baumann <[email protected]>
Signed-off-by: Mathias L. Baumann <[email protected]>
1ebd6b8 to
eb7e8bc
Compare
|
Updated accordingly |