refactor(substreams-testing): Remove shallow functions, be more 🐍
This commit is contained in:
committed by
tvinagre
parent
1f9fe8d583
commit
139f7ac3f5
@@ -50,10 +50,6 @@ class ProtocolComponentExpectation(BaseModel):
|
|||||||
|
|
||||||
return "\n".join(differences)
|
return "\n".join(differences)
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def from_dto(dto: ProtocolComponent) -> "ProtocolComponentExpectation":
|
|
||||||
return ProtocolComponentExpectation(**dto.dict())
|
|
||||||
|
|
||||||
|
|
||||||
class ProtocolComponentWithTestConfig(ProtocolComponentExpectation):
|
class ProtocolComponentWithTestConfig(ProtocolComponentExpectation):
|
||||||
"""Represents a ProtocolComponent with its main attributes and test configuration."""
|
"""Represents a ProtocolComponent with its main attributes and test configuration."""
|
||||||
@@ -63,9 +59,6 @@ class ProtocolComponentWithTestConfig(ProtocolComponentExpectation):
|
|||||||
description="Flag indicating whether to skip simulation for this component",
|
description="Flag indicating whether to skip simulation for this component",
|
||||||
)
|
)
|
||||||
|
|
||||||
def into_protocol_component(self) -> ProtocolComponentExpectation:
|
|
||||||
return ProtocolComponentExpectation(**self.dict())
|
|
||||||
|
|
||||||
|
|
||||||
class IntegrationTest(BaseModel):
|
class IntegrationTest(BaseModel):
|
||||||
"""Configuration for an individual test."""
|
"""Configuration for an individual test."""
|
||||||
|
|||||||
@@ -137,9 +137,9 @@ class TestRunner:
|
|||||||
f"'{comp_id}' not found in protocol components."
|
f"'{comp_id}' not found in protocol components."
|
||||||
)
|
)
|
||||||
|
|
||||||
diff = ProtocolComponentExpectation.from_dto(
|
diff = ProtocolComponentExpectation(
|
||||||
components_by_id[comp_id]
|
**components_by_id[comp_id].dict()
|
||||||
).compare(expected_component.into_protocol_component())
|
).compare(ProtocolComponentExpectation(**expected_component.dict()))
|
||||||
if diff is not None:
|
if diff is not None:
|
||||||
return TestResult.Failed(diff)
|
return TestResult.Failed(diff)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user