Skip to content

Conversation

@Marenz
Copy link
Contributor

@Marenz Marenz commented Sep 19, 2024

  • TestService: Minor refactor of imports
  • Add support in FakeService for stream()

Signed-off-by: Mathias L. Baumann <[email protected]>
@Marenz Marenz requested review from a team as code owners September 19, 2024 16:38
@Marenz Marenz requested review from ktickner and shsms September 19, 2024 16:38
@github-actions github-actions bot added part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests part:test-utils Affects the test utilities part:dispatcher labels Sep 19, 2024
@Marenz Marenz enabled auto-merge September 23, 2024 13:33
@Marenz Marenz force-pushed the streamstream branch 2 times, most recently from 039d62e to 23ff599 Compare September 24, 2024 10:35
self._last_id = 0
self._stream_channel = Broadcast(name="dispatch-stream")
self._stream_sender = self._stream_channel.new_sender()
self.dispatches = {}
Copy link
Contributor

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.


def __post_init__(self) -> None:
"""Initialize the stream sender."""
self._stream_sender = self._stream_channel.new_sender()
Copy link
Contributor

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]>
@Marenz
Copy link
Contributor Author

Marenz commented Sep 25, 2024

Updated accordingly

@Marenz Marenz added this pull request to the merge queue Sep 25, 2024
Merged via the queue into frequenz-floss:v0.x.x with commit aec339d Sep 25, 2024
14 checks passed
@Marenz Marenz deleted the streamstream branch September 25, 2024 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

part:dispatcher part:docs Affects the documentation part:test-utils Affects the test utilities part:tests Affects the unit, integration and performance (benchmarks) tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants