Add ORM models for the pixel grids
- add Grid, Pixel, and AddressPixelAssociation ORM models - each Grid belongs to a City an is characterized by the side_length of all the square Pixels contained in it - Pixels aggregate Addresses => many-to-many relationship (that is modeled with SQLAlchemy's Association Pattern to implement a couple of constraints)
This commit is contained in:
parent
6cb4be80f6
commit
f996376b13
15 changed files with 665 additions and 36 deletions
|
|
@ -1,14 +1,16 @@
|
|||
"""Fixtures for testing the ORM layer with fake data."""
|
||||
|
||||
from tests.db.fake_data.fixture_makers import make_address # noqa:F401
|
||||
from tests.db.fake_data.fixture_makers import make_courier # noqa:F401
|
||||
from tests.db.fake_data.fixture_makers import make_customer # noqa:F401
|
||||
from tests.db.fake_data.fixture_makers import make_order # noqa:F401
|
||||
from tests.db.fake_data.fixture_makers import make_restaurant # noqa:F401
|
||||
from tests.db.fake_data.static_fixtures import address # noqa:F401
|
||||
from tests.db.fake_data.static_fixtures import city # noqa:F401
|
||||
from tests.db.fake_data.static_fixtures import city_data # noqa:F401
|
||||
from tests.db.fake_data.static_fixtures import courier # noqa:F401
|
||||
from tests.db.fake_data.static_fixtures import customer # noqa:F401
|
||||
from tests.db.fake_data.static_fixtures import order # noqa:F401
|
||||
from tests.db.fake_data.static_fixtures import restaurant # noqa:F401
|
||||
from tests.db.fake_data.fixture_makers import make_address
|
||||
from tests.db.fake_data.fixture_makers import make_courier
|
||||
from tests.db.fake_data.fixture_makers import make_customer
|
||||
from tests.db.fake_data.fixture_makers import make_order
|
||||
from tests.db.fake_data.fixture_makers import make_restaurant
|
||||
from tests.db.fake_data.static_fixtures import address
|
||||
from tests.db.fake_data.static_fixtures import city
|
||||
from tests.db.fake_data.static_fixtures import city_data
|
||||
from tests.db.fake_data.static_fixtures import courier
|
||||
from tests.db.fake_data.static_fixtures import customer
|
||||
from tests.db.fake_data.static_fixtures import grid
|
||||
from tests.db.fake_data.static_fixtures import order
|
||||
from tests.db.fake_data.static_fixtures import pixel
|
||||
from tests.db.fake_data.static_fixtures import restaurant
|
||||
|
|
|
|||
|
|
@ -56,3 +56,15 @@ def restaurant(address, make_restaurant):
|
|||
def order(make_order, restaurant):
|
||||
"""An `Order` object for the `restaurant`."""
|
||||
return make_order(restaurant=restaurant)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def grid(city):
|
||||
"""A `Grid` with a pixel area of 1 square kilometer."""
|
||||
return db.Grid(city=city, side_length=1000)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pixel(grid):
|
||||
"""The `Pixel` in the lower-left corner of the `grid`."""
|
||||
return db.Pixel(grid=grid, n_x=0, n_y=0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue