from model_bakery.exceptions import InvalidQuantityException, RecipeIteratorEmpty from tests.generic.models import ( TEST_TIME, Person, DummyNumbersModel, DummyBlankFieldsModel, Dog, ) from tests.generic.baker_recipes import SmallDogRecipe, pug recipe_attrs = { "name": "John Doe", "nickname": "joe", "age": 18, "bio": "Someone in the crowd", "birthday": now().date(), "appointment": now(), "blog": "http://joe.blogspot.com", "days_since_last_login": 4, "birth_time": now(), } person_recipe = Recipe(Person, **recipe_attrs) @pytest.mark.django_db class TestDefiningRecipes: def test_import_seq_from_baker(self): """ Import seq method directly from baker module """ try:
Dog, DummyDefaultFieldsModel, DummyUniqueIntegerFieldModel, ) from datetime import timedelta person = Recipe( Person, name="John Doe", nickname="joe", age=18, bio="Someone in the crowd", blog="http://joe.blogspot.com", days_since_last_login=4, birthday=now().date(), appointment=now(), birth_time=now(), ) serial_person = Recipe( Person, name=seq("joe"), ) serial_numbers = Recipe( DummyDefaultFieldsModel, default_decimal_field=seq(Decimal("20.1")), default_int_field=seq(10), default_float_field=seq(1.23), )
def gen_time(): return now().time()
def gen_datetime(): return now()
def gen_date(): return now().date()
from unittest.mock import patch from datetime import timedelta from model_bakery import baker from model_bakery.recipe import Recipe, foreign_key, RecipeForeignKey from model_bakery.timezone import now, tz_aware from model_bakery.exceptions import InvalidQuantityException, RecipeIteratorEmpty from tests.generic.models import TEST_TIME, Person, DummyNumbersModel, DummyBlankFieldsModel, Dog from tests.generic.baker_recipes import SmallDogRecipe, pug recipe_attrs = { 'name': 'John Doe', 'nickname': 'joe', 'age': 18, 'bio': 'Someone in the crowd', 'birthday': now().date(), 'appointment': now(), 'blog': 'http://joe.blogspot.com', 'wanted_games_qtd': 4, 'birth_time': now() } person_recipe = Recipe(Person, **recipe_attrs) @pytest.mark.django_db class TestDefiningRecipes(): def test_import_seq_from_baker(self): """ Import seq method directly from baker module """ try: