本文整理汇总了Python中geokey.categories.tests.model_factories.CategoryFactory.expiry_field方法的典型用法代码示例。如果您正苦于以下问题:Python CategoryFactory.expiry_field方法的具体用法?Python CategoryFactory.expiry_field怎么用?Python CategoryFactory.expiry_field使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类geokey.categories.tests.model_factories.CategoryFactory
的用法示例。
在下文中一共展示了CategoryFactory.expiry_field方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_update_expiry_field
# 需要导入模块: from geokey.categories.tests.model_factories import CategoryFactory [as 别名]
# 或者: from geokey.categories.tests.model_factories.CategoryFactory import expiry_field [as 别名]
def test_update_expiry_field(self):
category = CategoryFactory()
field = DateTimeFieldFactory(**{
'key': 'expires_at',
'category': category
})
category.expiry_field = field
category.save()
observation = ObservationFactory(**{
'project': category.project,
'category': category,
'expiry_field': None,
'properties': {
'expires_at': '2016-09-19T15:51:32.804Z'
}
})
observation.update_expiry_field()
observation.save()
ref = Observation.objects.get(pk=observation.id)
self.assertEqual(
ref.expiry_field,
datetime.datetime(2016, 9, 19, 15, 51, 32, 804000, tzinfo=pytz.utc)
)
示例2: test_update_expiry_field_empty_properties
# 需要导入模块: from geokey.categories.tests.model_factories import CategoryFactory [as 别名]
# 或者: from geokey.categories.tests.model_factories.CategoryFactory import expiry_field [as 别名]
def test_update_expiry_field_empty_properties(self):
category = CategoryFactory()
field = DateTimeFieldFactory(**{
'key': 'expires_at',
'category': category
})
category.expiry_field = field
category.save()
observation = ObservationFactory(**{
'project': category.project,
'category': category,
'expiry_field': None,
'properties': {}
})
observation.update_expiry_field()
observation.save()
ref = Observation.objects.get(pk=observation.id)
self.assertEqual(ref.expiry_field, None)