def setUp(self): self.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() } self.person_recipe = Recipe(Person, **self.recipe_attrs)
def setUp(self): self.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(), } self.person_recipe = Recipe(Person, **self.recipe_attrs)
def setUp(self): self.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() } self.person_recipe = Recipe( Person, **self.recipe_attrs )
from model_mommy.recipe import related from model_mommy.timezone import now from test.generic.models import TEST_TIME, Person, Dog, DummyDefaultFieldsModel, DummyUniqueIntegerFieldModel from six import u from datetime import timedelta person = Recipe(Person, name = 'John Doe', nickname = 'joe', age = 18, bio = 'Someone in the crowd', blog = 'http://joe.blogspot.com', wanted_games_qtd = 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) ) serial_numbers_by = Recipe(DummyDefaultFieldsModel,
def gen_datetime(): return now()
def gen_date(): return now().date()
def gen_time(): return now().time()
def __set_grading_points_for_last_feedbackset(self, cached_data, points=0, publishing_datetime=None): if not publishing_datetime: publishing_datetime = timezone.now() cached_data.last_feedbackset.grading_published_datetime = publishing_datetime cached_data.last_feedbackset.grading_points = points cached_data.last_feedbackset.save()
#coding: utf-8 #ATTENTION: Recipes defined for testing purposes only from decimal import Decimal from model_mommy.recipe import Recipe, foreign_key, seq from model_mommy.timezone import now from test.generic.models import Person, Dog, DummyDefaultFieldsModel, DummyUniqueIntegerFieldModel person = Recipe(Person, name='John Doe', nickname='joe', age=18, bio='Someone in the crowd', blog='http://joe.blogspot.com', wanted_games_qtd=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)) dog = Recipe(Dog, breed='Pug', owner=foreign_key(person))
from unittest.mock import patch from datetime import timedelta from model_mommy import mommy from model_mommy.recipe import Recipe, foreign_key, RecipeForeignKey from model_mommy.timezone import now, tz_aware from model_mommy.exceptions import InvalidQuantityException, RecipeIteratorEmpty from tests.generic.models import TEST_TIME, Person, DummyNumbersModel, DummyBlankFieldsModel, Dog from tests.generic.mommy_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_mommy(self): """ Import seq method directly from mommy module """ try: