本文整理汇总了Python中geokey.contributions.tests.model_factories.ObservationFactory.refresh_from_db方法的典型用法代码示例。如果您正苦于以下问题:Python ObservationFactory.refresh_from_db方法的具体用法?Python ObservationFactory.refresh_from_db怎么用?Python ObservationFactory.refresh_from_db使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类geokey.contributions.tests.model_factories.ObservationFactory
的用法示例。
在下文中一共展示了ObservationFactory.refresh_from_db方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_post_save_audio_file_count_update
# 需要导入模块: from geokey.contributions.tests.model_factories import ObservationFactory [as 别名]
# 或者: from geokey.contributions.tests.model_factories.ObservationFactory import refresh_from_db [as 别名]
def test_post_save_audio_file_count_update(self):
observation = ObservationFactory()
audio_file = AudioFile.objects.create(
name='Test name',
description='Test Description',
contribution=observation,
creator=UserFactory.create(),
audio=get_image()
)
AudioFile.objects.create(
status='deleted',
name='Test name',
description='Test Description',
contribution=observation,
creator=UserFactory.create(),
audio=get_image()
)
post_save_count_update(
AudioFile,
instance=audio_file,
created=True)
observation.refresh_from_db()
self.assertEqual(observation.num_media, 1)
self.assertEqual(observation.num_comments, 0)
示例2: test_post_save_document_file_count_update
# 需要导入模块: from geokey.contributions.tests.model_factories import ObservationFactory [as 别名]
# 或者: from geokey.contributions.tests.model_factories.ObservationFactory import refresh_from_db [as 别名]
def test_post_save_document_file_count_update(self):
observation = ObservationFactory()
document_file = DocumentFile.objects.create(
name='Test name',
description='Test Description',
contribution=observation,
creator=UserFactory.create(),
document=get_pdf_document()
)
DocumentFile.objects.create(
status='deleted',
name='Test name',
description='Test Description',
contribution=observation,
creator=UserFactory.create(),
document=get_pdf_document()
)
post_save_count_update(
DocumentFile,
instance=document_file,
created=True)
observation.refresh_from_db()
self.assertEqual(observation.num_media, 1)
self.assertEqual(observation.num_comments, 0)
示例3: test_post_save_video_file_count_update
# 需要导入模块: from geokey.contributions.tests.model_factories import ObservationFactory [as 别名]
# 或者: from geokey.contributions.tests.model_factories.ObservationFactory import refresh_from_db [as 别名]
def test_post_save_video_file_count_update(self):
observation = ObservationFactory()
video_file = VideoFile.objects.create(
name='Test name',
description='Test Description',
contribution=observation,
creator=UserFactory.create(),
video=get_image(),
youtube_link='http://example.com/1122323',
swf_link='http://example.com/1122323.swf'
)
VideoFile.objects.create(
status='deleted',
name='Test name',
description='Test Description',
contribution=observation,
creator=UserFactory.create(),
video=get_image(),
youtube_link='http://example.com/1122323',
swf_link='http://example.com/1122323.swf'
)
post_save_count_update(
VideoFile,
instance=video_file,
created=True)
observation.refresh_from_db()
self.assertEqual(observation.num_media, 1)
self.assertEqual(observation.num_comments, 0)