From d729b514e53abf1d010297e2426a074aaccb34c8 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Fri, 16 Sep 2022 12:43:56 +0530 Subject: [PATCH] UT: Use PydanticAgentEventSerializer in place of PydanticEventSerializer --- .../test_pydantic_event_serializer.py | 4 ++-- .../cc/repository/test_mongo_event_repository.py | 6 +++--- .../monkey_island/cc/resources/test_events.py | 10 ++++++---- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/monkey/tests/unit_tests/common/event_serializers/test_pydantic_event_serializer.py b/monkey/tests/unit_tests/common/event_serializers/test_pydantic_event_serializer.py index cd545e432..eaa54eb02 100644 --- a/monkey/tests/unit_tests/common/event_serializers/test_pydantic_event_serializer.py +++ b/monkey/tests/unit_tests/common/event_serializers/test_pydantic_event_serializer.py @@ -8,7 +8,7 @@ from pydantic import Field from common.event_serializers import ( EVENT_TYPE_FIELD, IAgentEventSerializer, - PydanticEventSerializer, + PydanticAgentEventSerializer, ) from common.events import AbstractAgentEvent @@ -31,7 +31,7 @@ class PydanticEvent(AbstractAgentEvent): @pytest.fixture def pydantic_event_serializer() -> IAgentEventSerializer: - return PydanticEventSerializer(PydanticEvent) + return PydanticAgentEventSerializer(PydanticEvent) @pytest.mark.parametrize( diff --git a/monkey/tests/unit_tests/monkey_island/cc/repository/test_mongo_event_repository.py b/monkey/tests/unit_tests/monkey_island/cc/repository/test_mongo_event_repository.py index 1da6366e2..6a1f232ef 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/repository/test_mongo_event_repository.py +++ b/monkey/tests/unit_tests/monkey_island/cc/repository/test_mongo_event_repository.py @@ -6,7 +6,7 @@ import mongomock import pytest from pydantic import Field -from common.event_serializers import AgentEventSerializerRegistry, PydanticEventSerializer +from common.event_serializers import AgentEventSerializerRegistry, PydanticAgentEventSerializer from common.events import AbstractAgentEvent from monkey_island.cc.repository import ( IEventRepository, @@ -36,8 +36,8 @@ EVENTS: List[AbstractAgentEvent] = [ @pytest.fixture def event_serializer_registry() -> AgentEventSerializerRegistry: registry = AgentEventSerializerRegistry() - registry[FakeAgentEvent] = PydanticEventSerializer(FakeAgentEvent) - registry[FakeAgentItemEvent] = PydanticEventSerializer(FakeAgentItemEvent) + registry[FakeAgentEvent] = PydanticAgentEventSerializer(FakeAgentEvent) + registry[FakeAgentItemEvent] = PydanticAgentEventSerializer(FakeAgentItemEvent) return registry diff --git a/monkey/tests/unit_tests/monkey_island/cc/resources/test_events.py b/monkey/tests/unit_tests/monkey_island/cc/resources/test_events.py index 0a9ea7777..74a69a6da 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/resources/test_events.py +++ b/monkey/tests/unit_tests/monkey_island/cc/resources/test_events.py @@ -6,7 +6,7 @@ import pytest from tests.common import StubDIContainer from common.event_queue import IAgentEventQueue -from common.event_serializers import AgentEventSerializerRegistry, PydanticEventSerializer +from common.event_serializers import AgentEventSerializerRegistry, PydanticAgentEventSerializer from common.events import AbstractAgentEvent from monkey_island.cc.resources import Events @@ -90,9 +90,11 @@ def mock_agent_event_queue(): @pytest.fixture def event_serializer_registry() -> AgentEventSerializerRegistry: event_serializer_registry = AgentEventSerializerRegistry() - event_serializer_registry[SomeAgentEvent] = PydanticEventSerializer(SomeAgentEvent) - event_serializer_registry[OtherAgentEvent] = PydanticEventSerializer(OtherAgentEvent) - event_serializer_registry[DifferentAgentEvent] = PydanticEventSerializer(DifferentAgentEvent) + event_serializer_registry[SomeAgentEvent] = PydanticAgentEventSerializer(SomeAgentEvent) + event_serializer_registry[OtherAgentEvent] = PydanticAgentEventSerializer(OtherAgentEvent) + event_serializer_registry[DifferentAgentEvent] = PydanticAgentEventSerializer( + DifferentAgentEvent + ) return event_serializer_registry