コード例 #1
0
 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)
コード例 #2
0
ファイル: test_recipes.py プロジェクト: berinhard/model_mommy
 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)
コード例 #3
0
 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
     )
コード例 #4
0
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,
コード例 #5
0
def gen_datetime():
    return now()
コード例 #6
0
def gen_date():
    return now().date()
コード例 #7
0
def gen_time():
    return now().time()
コード例 #8
0
ファイル: generators.py プロジェクト: VerosK/model_mommy
def gen_time():
    return now().time()
コード例 #9
0
ファイル: generators.py プロジェクト: VerosK/model_mommy
def gen_datetime():
    return now()
コード例 #10
0
ファイル: generators.py プロジェクト: VerosK/model_mommy
def gen_date():
    return now().date()
コード例 #11
0
 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()
コード例 #12
0
#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))
コード例 #13
0
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: