forked from p34709852/monkey
UT: Change pydantic_event_serializer -> pydantic_agent_event_serializer in test_pydantic_agent_event_serializer.py
This commit is contained in:
parent
d694591d1e
commit
2f748516a8
|
@ -30,7 +30,7 @@ class PydanticEvent(AbstractAgentEvent):
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def pydantic_event_serializer() -> IAgentEventSerializer:
|
def pydantic_agent_event_serializer() -> IAgentEventSerializer:
|
||||||
return PydanticAgentEventSerializer(PydanticEvent)
|
return PydanticAgentEventSerializer(PydanticEvent)
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,28 +38,30 @@ def pydantic_event_serializer() -> IAgentEventSerializer:
|
||||||
"event",
|
"event",
|
||||||
[NotAgentEvent(some_field=1, other_field=2.0), SomeAgentEvent(source=AGENT_ID, bogus=2)],
|
[NotAgentEvent(some_field=1, other_field=2.0), SomeAgentEvent(source=AGENT_ID, bogus=2)],
|
||||||
)
|
)
|
||||||
def test_pydantic_event_serializer__serialize_wrong_type(pydantic_event_serializer, event):
|
def test_pydantic_agent_event_serializer__serialize_wrong_type(
|
||||||
|
pydantic_agent_event_serializer, event
|
||||||
|
):
|
||||||
with pytest.raises(TypeError):
|
with pytest.raises(TypeError):
|
||||||
pydantic_event_serializer.serialize(event)
|
pydantic_agent_event_serializer.serialize(event)
|
||||||
|
|
||||||
|
|
||||||
def test_pydantic_event_serializer__deserialize_wrong_type(pydantic_event_serializer):
|
def test_pydantic_agent_event_serializer__deserialize_wrong_type(pydantic_agent_event_serializer):
|
||||||
with pytest.raises(TypeError):
|
with pytest.raises(TypeError):
|
||||||
pydantic_event_serializer.deserialize("bla")
|
pydantic_agent_event_serializer.deserialize("bla")
|
||||||
|
|
||||||
|
|
||||||
def test_pydanitc_event_serializer__de_serialize(pydantic_event_serializer):
|
def test_pydantic_agent_event_serializer__de_serialize(pydantic_agent_event_serializer):
|
||||||
pydantic_event = PydanticEvent(source=AGENT_ID, some_field="some_field")
|
pydantic_event = PydanticEvent(source=AGENT_ID, some_field="some_field")
|
||||||
|
|
||||||
serialized_event = pydantic_event_serializer.serialize(pydantic_event)
|
serialized_event = pydantic_agent_event_serializer.serialize(pydantic_event)
|
||||||
deserialized_object = pydantic_event_serializer.deserialize(serialized_event)
|
deserialized_object = pydantic_agent_event_serializer.deserialize(serialized_event)
|
||||||
|
|
||||||
assert type(serialized_event) != type(deserialized_object)
|
assert type(serialized_event) != type(deserialized_object)
|
||||||
assert deserialized_object == pydantic_event
|
assert deserialized_object == pydantic_event
|
||||||
|
|
||||||
|
|
||||||
def test_pydanitc_event_serializer__serialize_inclued_type(pydantic_event_serializer):
|
def test_pydantic_event_serializer__serialize_inclued_type(pydantic_agent_event_serializer):
|
||||||
pydantic_event = PydanticEvent(source=AGENT_ID, some_field="some_field")
|
pydantic_event = PydanticEvent(source=AGENT_ID, some_field="some_field")
|
||||||
|
|
||||||
serialized_event = pydantic_event_serializer.serialize(pydantic_event)
|
serialized_event = pydantic_agent_event_serializer.serialize(pydantic_event)
|
||||||
assert serialized_event[EVENT_TYPE_FIELD] == PydanticEvent.__name__
|
assert serialized_event[EVENT_TYPE_FIELD] == PydanticEvent.__name__
|
||||||
|
|
Loading…
Reference in New Issue