forked from p15670423/monkey
UT: Use AgentEventSerializerRegistry in place of EventSerializerRegistry
This commit is contained in:
parent
4a23f5a95b
commit
2568d52730
|
@ -3,7 +3,7 @@ from unittest.mock import MagicMock
|
|||
import pytest
|
||||
from pydantic import Field
|
||||
|
||||
from common.event_serializers import EventSerializerRegistry, IAgentEventSerializer
|
||||
from common.event_serializers import AgentEventSerializerRegistry, IAgentEventSerializer
|
||||
from common.events import AbstractAgentEvent
|
||||
|
||||
|
||||
|
@ -25,7 +25,7 @@ OTHER_SERIALIZER = MagicMock(spec=IAgentEventSerializer)
|
|||
|
||||
@pytest.fixture
|
||||
def event_serializer_registry():
|
||||
event_serializer_registry = EventSerializerRegistry()
|
||||
event_serializer_registry = AgentEventSerializerRegistry()
|
||||
|
||||
event_serializer_registry[SomeEvent] = SOME_SERIALIZER
|
||||
event_serializer_registry[OtherEvent] = OTHER_SERIALIZER
|
||||
|
|
|
@ -6,7 +6,7 @@ import mongomock
|
|||
import pytest
|
||||
from pydantic import Field
|
||||
|
||||
from common.event_serializers import EventSerializerRegistry, PydanticEventSerializer
|
||||
from common.event_serializers import AgentEventSerializerRegistry, PydanticEventSerializer
|
||||
from common.events import AbstractAgentEvent
|
||||
from monkey_island.cc.repository import (
|
||||
IEventRepository,
|
||||
|
@ -34,8 +34,8 @@ EVENTS: List[AbstractAgentEvent] = [
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
def event_serializer_registry() -> EventSerializerRegistry:
|
||||
registry = EventSerializerRegistry()
|
||||
def event_serializer_registry() -> AgentEventSerializerRegistry:
|
||||
registry = AgentEventSerializerRegistry()
|
||||
registry[FakeAgentEvent] = PydanticEventSerializer(FakeAgentEvent)
|
||||
registry[FakeAgentItemEvent] = PydanticEventSerializer(FakeAgentItemEvent)
|
||||
return registry
|
||||
|
|
|
@ -6,7 +6,7 @@ import pytest
|
|||
from tests.common import StubDIContainer
|
||||
|
||||
from common.event_queue import IAgentEventQueue
|
||||
from common.event_serializers import EventSerializerRegistry, PydanticEventSerializer
|
||||
from common.event_serializers import AgentEventSerializerRegistry, PydanticEventSerializer
|
||||
from common.events import AbstractAgentEvent
|
||||
from monkey_island.cc.resources import Events
|
||||
|
||||
|
@ -88,8 +88,8 @@ def mock_agent_event_queue():
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
def event_serializer_registry() -> EventSerializerRegistry:
|
||||
event_serializer_registry = EventSerializerRegistry()
|
||||
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)
|
||||
|
@ -102,7 +102,7 @@ def flask_client(build_flask_client, mock_agent_event_queue, event_serializer_re
|
|||
container = StubDIContainer()
|
||||
|
||||
container.register_instance(IAgentEventQueue, mock_agent_event_queue)
|
||||
container.register_instance(EventSerializerRegistry, event_serializer_registry)
|
||||
container.register_instance(AgentEventSerializerRegistry, event_serializer_registry)
|
||||
|
||||
with build_flask_client(container) as flask_client:
|
||||
yield flask_client
|
||||
|
|
Loading…
Reference in New Issue