UT: Use PydanticAgentEventSerializer in place of PydanticEventSerializer

This commit is contained in:
Shreya Malviya 2022-09-16 12:43:56 +05:30 committed by Mike Salvatore
parent 43fd978ce4
commit d729b514e5
3 changed files with 11 additions and 9 deletions

View File

@ -8,7 +8,7 @@ from pydantic import Field
from common.event_serializers import ( from common.event_serializers import (
EVENT_TYPE_FIELD, EVENT_TYPE_FIELD,
IAgentEventSerializer, IAgentEventSerializer,
PydanticEventSerializer, PydanticAgentEventSerializer,
) )
from common.events import AbstractAgentEvent from common.events import AbstractAgentEvent
@ -31,7 +31,7 @@ class PydanticEvent(AbstractAgentEvent):
@pytest.fixture @pytest.fixture
def pydantic_event_serializer() -> IAgentEventSerializer: def pydantic_event_serializer() -> IAgentEventSerializer:
return PydanticEventSerializer(PydanticEvent) return PydanticAgentEventSerializer(PydanticEvent)
@pytest.mark.parametrize( @pytest.mark.parametrize(

View File

@ -6,7 +6,7 @@ import mongomock
import pytest import pytest
from pydantic import Field from pydantic import Field
from common.event_serializers import AgentEventSerializerRegistry, PydanticEventSerializer from common.event_serializers import AgentEventSerializerRegistry, PydanticAgentEventSerializer
from common.events import AbstractAgentEvent from common.events import AbstractAgentEvent
from monkey_island.cc.repository import ( from monkey_island.cc.repository import (
IEventRepository, IEventRepository,
@ -36,8 +36,8 @@ EVENTS: List[AbstractAgentEvent] = [
@pytest.fixture @pytest.fixture
def event_serializer_registry() -> AgentEventSerializerRegistry: def event_serializer_registry() -> AgentEventSerializerRegistry:
registry = AgentEventSerializerRegistry() registry = AgentEventSerializerRegistry()
registry[FakeAgentEvent] = PydanticEventSerializer(FakeAgentEvent) registry[FakeAgentEvent] = PydanticAgentEventSerializer(FakeAgentEvent)
registry[FakeAgentItemEvent] = PydanticEventSerializer(FakeAgentItemEvent) registry[FakeAgentItemEvent] = PydanticAgentEventSerializer(FakeAgentItemEvent)
return registry return registry

View File

@ -6,7 +6,7 @@ import pytest
from tests.common import StubDIContainer from tests.common import StubDIContainer
from common.event_queue import IAgentEventQueue 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 common.events import AbstractAgentEvent
from monkey_island.cc.resources import Events from monkey_island.cc.resources import Events
@ -90,9 +90,11 @@ def mock_agent_event_queue():
@pytest.fixture @pytest.fixture
def event_serializer_registry() -> AgentEventSerializerRegistry: def event_serializer_registry() -> AgentEventSerializerRegistry:
event_serializer_registry = AgentEventSerializerRegistry() event_serializer_registry = AgentEventSerializerRegistry()
event_serializer_registry[SomeAgentEvent] = PydanticEventSerializer(SomeAgentEvent) event_serializer_registry[SomeAgentEvent] = PydanticAgentEventSerializer(SomeAgentEvent)
event_serializer_registry[OtherAgentEvent] = PydanticEventSerializer(OtherAgentEvent) event_serializer_registry[OtherAgentEvent] = PydanticAgentEventSerializer(OtherAgentEvent)
event_serializer_registry[DifferentAgentEvent] = PydanticEventSerializer(DifferentAgentEvent) event_serializer_registry[DifferentAgentEvent] = PydanticAgentEventSerializer(
DifferentAgentEvent
)
return event_serializer_registry return event_serializer_registry