Exemple #1
0
 def test_creates_unique_timedelta_recipe_using_quantity_argument(self):
     dummies = mommy.make_recipe('test.generic.serial_datetime',
                                 _quantity=3)
     self.assertEqual(dummies[0].default_date_field,
                      TEST_TIME.date() + timedelta(days=1))
     self.assertEqual(dummies[1].default_date_field,
                      TEST_TIME.date() + timedelta(days=2))
     self.assertEqual(dummies[2].default_date_field,
                      TEST_TIME.date() + timedelta(days=3))
 def test_increment_by_timedelta(self):
     dummy = mommy.make_recipe("test.generic.serial_datetime")
     self.assertEqual(dummy.default_date_field, (TEST_TIME.date() + timedelta(days=1)))
     self.assertEqual(dummy.default_date_time_field, tz_aware(TEST_TIME + timedelta(hours=3)))
     self.assertEqual(dummy.default_time_field, (TEST_TIME + timedelta(seconds=15)).time())
     dummy = mommy.make_recipe("test.generic.serial_datetime")
     self.assertEqual(dummy.default_date_field, (TEST_TIME.date() + timedelta(days=2)))
     self.assertEqual(dummy.default_date_time_field, tz_aware(TEST_TIME + timedelta(hours=6)))
     self.assertEqual(dummy.default_time_field, (TEST_TIME + timedelta(seconds=30)).time())
Exemple #3
0
 def test_increment_by_timedelta(self):
     dummy = mommy.make_recipe('test.generic.serial_datetime')
     self.assertEqual(dummy.default_date_field, (TEST_TIME.date() + timedelta(days=1)))
     self.assertEqual(dummy.default_date_time_field, tz_aware(TEST_TIME + timedelta(hours=3)))
     self.assertEqual(dummy.default_time_field, (TEST_TIME + timedelta(seconds=15)).time())
     dummy = mommy.make_recipe('test.generic.serial_datetime')
     self.assertEqual(dummy.default_date_field, (TEST_TIME.date() + timedelta(days=2)))
     self.assertEqual(dummy.default_date_time_field, tz_aware(TEST_TIME + timedelta(hours=6)))
     self.assertEqual(dummy.default_time_field, (TEST_TIME + timedelta(seconds=30)).time())
)

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,
    default_decimal_field = seq(Decimal('20.1'), increment_by=Decimal('2.4')),
    default_int_field = seq(10, increment_by=3),
    default_float_field = seq(1.23, increment_by=1.8)
)

serial_datetime = Recipe(DummyDefaultFieldsModel,
    default_date_field = seq(TEST_TIME.date(), timedelta(days=1)),
    default_date_time_field = seq(TEST_TIME, timedelta(hours=3)),
    default_time_field = seq(TEST_TIME.time(), timedelta(seconds=15))
)

dog = Recipe(Dog,
    breed = 'Pug',
    owner = foreign_key(person)
)

homeless_dog = Recipe(Dog,
    breed = 'Pug',
)

other_dog = Recipe(Dog,
    breed = 'Basset',
Exemple #5
0
    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,
                           default_decimal_field=seq(
                               Decimal('20.1'), increment_by=Decimal('2.4')),
                           default_int_field=seq(10, increment_by=3),
                           default_float_field=seq(1.23, increment_by=1.8))

serial_datetime = Recipe(DummyDefaultFieldsModel,
                         default_date_field=seq(TEST_TIME.date(),
                                                timedelta(days=1)),
                         default_date_time_field=seq(TEST_TIME,
                                                     timedelta(hours=3)),
                         default_time_field=seq(TEST_TIME.time(),
                                                timedelta(seconds=15)))

dog = Recipe(Dog, breed='Pug', owner=foreign_key(person))

other_dog = Recipe(Dog, breed='Basset', owner=foreign_key('person'))

other_dog_unicode = Recipe(Dog, breed='Basset', owner=foreign_key(u('person')))

dummy_unique_field = Recipe(
    DummyUniqueIntegerFieldModel,
    value=seq(10),
 def test_creates_unique_timedelta_recipe_using_quantity_argument(self):
     dummies = mommy.make_recipe("test.generic.serial_datetime", _quantity=3)
     self.assertEqual(dummies[0].default_date_field, TEST_TIME.date() + timedelta(days=1))
     self.assertEqual(dummies[1].default_date_field, TEST_TIME.date() + timedelta(days=2))
     self.assertEqual(dummies[2].default_date_field, TEST_TIME.date() + timedelta(days=3))