UT: Test EventSerializerRegistry

This commit is contained in:
Ilija Lazoroski 2022-08-18 10:31:10 +02:00
parent e83503e65a
commit aeaabbccc4
1 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,28 @@
from dataclasses import dataclass, field
from common.event_serializers import EventSerializerRegistry
from common.events import AbstractEvent
@dataclass(frozen=True)
class SomeEvent(AbstractEvent):
some_param: int = field(default=435)
@dataclass(frozen=True)
class OtherEvent(AbstractEvent):
other_param: float = field(default=123.456)
def test_event_serializer_registry():
event_serializer_registry = EventSerializerRegistry()
some_event = SomeEvent(some_param=123)
other_event = OtherEvent()
event_serializer_registry[SomeEvent] = some_event
event_serializer_registry[OtherEvent] = other_event
assert event_serializer_registry[some_event.__class__] == some_event
assert event_serializer_registry[other_event.__class__] == other_event