2021-09-15 11:54:45 +02:00
|
|
|
"""Factory to create `Restaurant` instances."""
|
|
|
|
|
|
|
|
|
|
import factory
|
|
|
|
|
import faker
|
|
|
|
|
from factory import alchemy
|
|
|
|
|
|
|
|
|
|
from tests.db.fake_data.factories import utils
|
2026-11-23 18:06:53 +01:00
|
|
|
from velofy import db
|
2021-09-15 11:54:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
_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",)
|
|
|
|
|
|
2026-11-28 02:01:12 +01:00
|
|
|
id = factory.Sequence(lambda num: num)
|
2021-09-15 11:54:45 +02:00
|
|
|
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
|