Avoid lazy loads in .__repr__()
`ReplaySimulation`, `ReplayedOrder`, and `Forecast` accessed relationships in their `.__repr__()`, which emits queries or fails for detached instances. They now use the foreign key columns.
This commit is contained in:
parent
1f9d0effae
commit
7d53abc057
2 changed files with 8 additions and 7 deletions
|
|
@ -21,7 +21,7 @@ class TestSpecialMethods:
|
|||
"""`ReplayedOrder` has a non-literal text representation."""
|
||||
result = repr(replayed_order)
|
||||
|
||||
assert result == f"<ReplayedOrder(#{replayed_order.actual.id})>"
|
||||
assert result == f"<ReplayedOrder(#{replayed_order.actual_order_id})>"
|
||||
|
||||
|
||||
@pytest.mark.db
|
||||
|
|
|
|||
|
|
@ -13,5 +13,5 @@ class TestSpecialMethods:
|
|||
result = repr(simulation)
|
||||
|
||||
assert result.startswith("<ReplaySimulation(")
|
||||
assert simulation.city.name in result
|
||||
assert f"city #{simulation.city_id}" in result
|
||||
assert simulation.strategy in result
|
||||
|
|
|
|||
Loading…
Reference in a new issue