Refactor tests.db.fake_data.factories into a package
This commit is contained in:
parent
7e23033d84
commit
f891fac3dc
10 changed files with 236 additions and 172 deletions
27
tests/db/fake_data/factories/restaurants.py
Normal file
27
tests/db/fake_data/factories/restaurants.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
"""Factory to create `Restaurant` instances."""
|
||||
|
||||
import factory
|
||||
import faker
|
||||
from factory import alchemy
|
||||
|
||||
from tests.db.fake_data.factories import utils
|
||||
from urban_meal_delivery import db
|
||||
|
||||
|
||||
_restaurant_names = faker.Faker()
|
||||
|
||||
|
||||
class RestaurantFactory(alchemy.SQLAlchemyModelFactory):
|
||||
"""Create instances of the `db.Restaurant` model."""
|
||||
|
||||
class Meta:
|
||||
model = db.Restaurant
|
||||
sqlalchemy_get_or_create = ('id',)
|
||||
|
||||
id = factory.Sequence(lambda num: num) # noqa:WPS125
|
||||
created_at = factory.LazyFunction(utils.early_in_the_morning)
|
||||
name = factory.LazyFunction(
|
||||
lambda: f"{_restaurant_names.first_name()}'s Restaurant",
|
||||
)
|
||||
# address -> set by the `make_restaurant` fixture as there is only one `city`
|
||||
estimated_prep_duration = 1000
|
||||
Loading…
Add table
Add a link
Reference in a new issue