Re-factor the ORM tests to use randomized fake data
- create `*Factory` classes with fakerboy and faker that generate randomized instances of the ORM models - add new pytest marker: "db" are the integration tests involving the database whereas "e2e" will be all other integration tests - streamline the docstrings in the ORM models
This commit is contained in:
parent
416a58f9dc
commit
78dba23d5d
19 changed files with 1092 additions and 721 deletions
58
tests/db/fake_data/static_fixtures.py
Normal file
58
tests/db/fake_data/static_fixtures.py
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
"""Fake data for testing the ORM layer."""
|
||||
|
||||
import pytest
|
||||
|
||||
from urban_meal_delivery import db
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def city_data():
|
||||
"""The data for the one and only `City` object as a `dict`."""
|
||||
return {
|
||||
'id': 1,
|
||||
'name': 'Paris',
|
||||
'kml': "<?xml version='1.0' encoding='UTF-8'?> ...",
|
||||
'_center_latitude': 48.856614,
|
||||
'_center_longitude': 2.3522219,
|
||||
'_northeast_latitude': 48.9021449,
|
||||
'_northeast_longitude': 2.4699208,
|
||||
'_southwest_latitude': 48.815573,
|
||||
'_southwest_longitude': 2.225193,
|
||||
'initial_zoom': 12,
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def city(city_data):
|
||||
"""The one and only `City` object."""
|
||||
return db.City(**city_data)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def address(make_address):
|
||||
"""An `Address` object in the `city`."""
|
||||
return make_address()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def courier(make_courier):
|
||||
"""A `Courier` object."""
|
||||
return make_courier()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def customer(make_customer):
|
||||
"""A `Customer` object."""
|
||||
return make_customer()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def restaurant(address, make_restaurant):
|
||||
"""A `Restaurant` object located at the `address`."""
|
||||
return make_restaurant(address=address)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def order(make_order, restaurant):
|
||||
"""An `Order` object for the `restaurant`."""
|
||||
return make_order(restaurant=restaurant)
|
||||
Loading…
Add table
Add a link
Reference in a new issue