From aeaabbccc4b40f639632432a87d3f63ca4296d39 Mon Sep 17 00:00:00 2001 From: Ilija Lazoroski Date: Thu, 18 Aug 2022 10:31:10 +0200 Subject: [PATCH] UT: Test EventSerializerRegistry --- .../test_event_serializer_registry.py | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 monkey/tests/unit_tests/common/event_serializers/test_event_serializer_registry.py diff --git a/monkey/tests/unit_tests/common/event_serializers/test_event_serializer_registry.py b/monkey/tests/unit_tests/common/event_serializers/test_event_serializer_registry.py new file mode 100644 index 000000000..0e56fcb1b --- /dev/null +++ b/monkey/tests/unit_tests/common/event_serializers/test_event_serializer_registry.py @@ -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