Add ORM models for the simulation data

- add new ORM models `ReplaySimulation` and `ReplayedOrder`
  to store the data generated by the routing simulations
- add migrations script to create the corresponding database tables
  + create "replay_simulations" and "replayed_orders" tables
  + add missing check constraints to "orders" table
  + add unique constraint to "orders" table to enable compound key
  + drop unnecessary check constraints from the "orders" table
- add tests for the new ORM models
  + add `simulation`, `replayed_order`, `make_replay_order()`, and
    `pre_order` fixtures
  + add `ReplayedOrderFactor` faker class
- fix some typos
This commit is contained in:
Alexander Hess 2021-09-16 11:58:55 +02:00
commit e4e543bd40
Signed by: alexander
GPG key ID: 344EA5AB10D868E0
19 changed files with 1677 additions and 10 deletions

View file

@ -0,0 +1,17 @@
"""Test the ORM's `ReplaySimulation` model."""
class TestSpecialMethods:
"""Test special methods in `ReplaySimulation`."""
def test_create_simulation(self, simulation):
"""Test instantiation of a new `ReplaySimulation` object."""
assert simulation is not None
def test_text_representation(self, simulation):
"""`ReplaySimulation` has a non-literal text representation."""
result = repr(simulation)
assert result.startswith('<ReplaySimulation(')
assert simulation.city.name in result
assert simulation.strategy in result