class CustomModel(model.Model): datetime = fields.DateTime(auto_now_on_create=True) class Meta: collection = 'test'
class CustomModel(model.Model): name = fields.String() dt = fields.DateTime() class Meta: collection = 'test'
async def test_db_deserialize(self): field = fields.DateTime() dt = datetime.datetime(2015, 7, 13) self.assertEqual(dt, await field.db_deserialize(dt))
async def test_on_create__without_auto(self): field = fields.DateTime() self.assertEqual(await field.on_create(None), None)
async def test_on_create(self): field = fields.DateTime(auto_now_on_create=True) self.assertIsInstance(await field.on_create(None), datetime.datetime)
async def test_on_save__without_auto(self): field = fields.DateTime() self.assertEqual(None, await field.on_save(None))