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:
parent
41f75f507d
commit
e4e543bd40
19 changed files with 1677 additions and 10 deletions
|
|
@ -54,10 +54,22 @@ def restaurant(address, make_restaurant):
|
|||
|
||||
@pytest.fixture
|
||||
def order(make_order, restaurant):
|
||||
"""An `Order` object for the `restaurant`."""
|
||||
"""An ad-hoc `Order` object for the `restaurant`."""
|
||||
return make_order(restaurant=restaurant)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pre_order(make_order, restaurant):
|
||||
"""A scheduled `Order` object for the `restaurant`."""
|
||||
return make_order(restaurant=restaurant, scheduled=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def replayed_order(make_replay_order, order):
|
||||
"""A `ReplayedOrder` object for the `restaurant`."""
|
||||
return make_replay_order(order=order)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def grid(city):
|
||||
"""A `Grid` with a pixel area of 1 square kilometer."""
|
||||
|
|
@ -68,3 +80,20 @@ def grid(city):
|
|||
def pixel(grid):
|
||||
"""The `Pixel` in the lower-left corner of the `grid`."""
|
||||
return db.Pixel(id=1, grid=grid, n_x=0, n_y=0)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def simulation_data(city):
|
||||
"""The data for the one and only `ReplaySimulation` object as a `dict`."""
|
||||
return {
|
||||
'id': 1,
|
||||
'city': city,
|
||||
'strategy': 'best_possible_routing',
|
||||
'run': 0,
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def simulation(simulation_data):
|
||||
"""The one and only `ReplaySimulation` object."""
|
||||
return db.ReplaySimulation(**simulation_data)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue