当前位置: 首页>>代码示例>>Python>>正文


Python ObservationFactory.create方法代码示例

本文整理汇总了Python中geokey.contributions.tests.model_factories.ObservationFactory.create方法的典型用法代码示例。如果您正苦于以下问题:Python ObservationFactory.create方法的具体用法?Python ObservationFactory.create怎么用?Python ObservationFactory.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在geokey.contributions.tests.model_factories.ObservationFactory的用法示例。


在下文中一共展示了ObservationFactory.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_get_data_min_max_number_filter

# 需要导入模块: from geokey.contributions.tests.model_factories import ObservationFactory [as 别名]
# 或者: from geokey.contributions.tests.model_factories.ObservationFactory import create [as 别名]
    def test_get_data_min_max_number_filter(self):
            user = UserFactory.create()
            project = ProjectFactory.create()
            category_1 = CategoryFactory(**{'project': project})
            NumericFieldFactory.create(**{
                'key': 'number',
                'category': category_1
            })
            category_2 = CategoryFactory(**{'project': project})
            NumericFieldFactory.create(**{
                'key': 'bla',
                'category': category_2
            })

            UserGroupFactory.create(
                add_users=[user],
                **{
                    'project': project,
                    'filters': {
                        category_1.id: {'number': {
                            'minval': '10',
                            'maxval': '22'
                        }}
                    }
                }
            )

            for x in range(0, 5):
                ObservationFactory.create(**{
                    'project': project,
                    'category': category_1,
                    'properties': {'number': 5}}
                )

                ObservationFactory.create(**{
                    'project': project,
                    'category': category_1,
                    'properties': {'number': 12}}
                )

                ObservationFactory.create(**{
                    'project': project,
                    'category': category_1,
                    'properties': {'number': 20}}
                )

                ObservationFactory.create(**{
                    'project': project,
                    'category': category_1,
                    'properties': {'number': 25}}
                )

                ObservationFactory.create(**{
                    'project': project,
                    'category': category_2,
                    'properties': {'number': 12}}
                )

            self.assertEqual(project.get_all_contributions(user).count(), 10)
开发者ID:Josh1billion,项目名称:geokey,代码行数:61,代码来源:test_models.py

示例2: setUp

# 需要导入模块: from geokey.contributions.tests.model_factories import ObservationFactory [as 别名]
# 或者: from geokey.contributions.tests.model_factories.ObservationFactory import create [as 别名]
    def setUp(self):
        """Setup for test."""
        self.user = UserFactory.create()
        self.category_tweet = CategoryFactory.create(
            name="Tweets")

        self.observation = ObservationFactory.create()
        self.observation_tweet = ObservationFactory.create(
            category=self.category_tweet)
开发者ID:ExCiteS,项目名称:geokey,代码行数:11,代码来源:test_utils.py

示例3: test_log_create_draft

# 需要导入模块: from geokey.contributions.tests.model_factories import ObservationFactory [as 别名]
# 或者: from geokey.contributions.tests.model_factories.ObservationFactory import create [as 别名]
    def test_log_create_draft(self):
        """Test when observation gets created as a draft."""
        log_count_init = LoggerHistory.objects.count()
        ObservationFactory.create(**{
            'status': 'draft',
            'creator': self.user,
            'location': self.location,
            'project': self.project,
            'category': self.category})

        self.assertEqual(LoggerHistory.objects.count(), log_count_init)
开发者ID:ExCiteS,项目名称:geokey,代码行数:13,代码来源:test_log_observation.py

示例4: test_daily_digest

# 需要导入模块: from geokey.contributions.tests.model_factories import ObservationFactory [as 别名]
# 或者: from geokey.contributions.tests.model_factories.ObservationFactory import create [as 别名]
    def test_daily_digest(self):
        do_not_notify = UserF.create()
        moderator = UserF.create()
        contributor = UserF.create()
        UserF.create()

        project = ProjectF.create(
            add_admins=[moderator],
            add_contributors=[contributor]
        )
        AdminsFactory.create(**{
            'project': project,
            'user': do_not_notify,
            'contact': False
        })

        suspended = ObservationFactory.create(
            created_at=(datetime.utcnow() - timedelta(2)).replace(tzinfo=utc),
            project=project,
            creator=contributor,
            status='active'
        )

        updated = ObservationFactory.create(
            project=project,
            creator=contributor
        )

        approved = ObservationFactory.create(
            project=project,
            creator=contributor,
            status='pending'
        )

        yesterday = datetime.utcnow().replace(tzinfo=utc)

        suspended.update(
            properties=None,
            status='pending',
            updator=UserF.create()
        )
        updated.update(properties={'key': 'value'}, updator=UserF.create())
        approved.update(properties=None, status='active', updator=moderator)

        for user in [moderator, contributor]:
            ObservationFactory.create(
                project=project,
                creator=user,
                status='pending'
            )

        command = Command()
        command.send_daily_digest(yesterday)
        self.assertEquals(len(mail.outbox), 3)
开发者ID:tainita01,项目名称:geokey,代码行数:56,代码来源:test_commands.py

示例5: test_delete_with_observation

# 需要导入模块: from geokey.contributions.tests.model_factories import ObservationFactory [as 别名]
# 或者: from geokey.contributions.tests.model_factories.ObservationFactory import create [as 别名]
    def test_delete_with_observation(self):
        category = CategoryFactory.create()
        observation = ObservationFactory.create(**{"category": category})
        category.delete()

        Category.objects.get(pk=category.id)
        Observation.objects.get(pk=observation.id)
开发者ID:oliverroick,项目名称:geokey,代码行数:9,代码来源:test_model.py

示例6: test_get_type_name

# 需要导入模块: from geokey.contributions.tests.model_factories import ObservationFactory [as 别名]
# 或者: from geokey.contributions.tests.model_factories.ObservationFactory import create [as 别名]
 def test_get_type_name(self):
     audio_file = AudioFile.objects.create(
         name='Test name',
         description='Test Description',
         contribution=ObservationFactory.create(),
         creator=UserFactory.create(),
         audio=get_image()
     )
     self.assertEqual(audio_file.type_name, 'AudioFile')
开发者ID:Josh1billion,项目名称:geokey,代码行数:11,代码来源:test_model.py

示例7: test_get_type_name

# 需要导入模块: from geokey.contributions.tests.model_factories import ObservationFactory [as 别名]
# 或者: from geokey.contributions.tests.model_factories.ObservationFactory import create [as 别名]
 def test_get_type_name(self):
     document_file = DocumentFile.objects.create(
         name='Test name',
         description='Test Description',
         contribution=ObservationFactory.create(),
         creator=UserFactory.create(),
         document=get_pdf_document()
     )
     self.assertEqual(document_file.type_name, 'DocumentFile')
开发者ID:ExCiteS,项目名称:geokey,代码行数:11,代码来源:test_models.py

示例8: test_delete_file

# 需要导入模块: from geokey.contributions.tests.model_factories import ObservationFactory [as 别名]
# 或者: from geokey.contributions.tests.model_factories.ObservationFactory import create [as 别名]
 def test_delete_file(self):
     audio_file = AudioFile.objects.create(
         name='Test name',
         description='Test Description',
         contribution=ObservationFactory.create(),
         creator=UserFactory.create(),
         audio=get_image()
     )
     audio_file.delete()
     self.assertEqual(audio_file.status, 'deleted')
开发者ID:ExCiteS,项目名称:geokey,代码行数:12,代码来源:test_models.py

示例9: test_delete_file

# 需要导入模块: from geokey.contributions.tests.model_factories import ObservationFactory [as 别名]
# 或者: from geokey.contributions.tests.model_factories.ObservationFactory import create [as 别名]
 def test_delete_file(self):
     image_file = ImageFile.objects.create(
         name='Test name',
         description='Test Description',
         contribution=ObservationFactory.create(),
         creator=UserFactory.create(),
         image=get_image()
     )
     image_file.delete()
     self.assertEquals(image_file.status, 'deleted')
开发者ID:Josh1billion,项目名称:geokey,代码行数:12,代码来源:test_model.py

示例10: test_create_image

# 需要导入模块: from geokey.contributions.tests.model_factories import ObservationFactory [as 别名]
# 或者: from geokey.contributions.tests.model_factories.ObservationFactory import create [as 别名]
    def test_create_image(self):
        image_file = MediaFile.objects.create(
            name='Test name',
            description='Test Description',
            contribution=ObservationFactory.create(),
            creator=UserF.create(),
            the_file=get_image()
        )

        self.assertIsNotNone(image_file.image)
        self.assertEqual(image_file.type_name, 'ImageFile')
开发者ID:tainita01,项目名称:geokey,代码行数:13,代码来源:test_manager.py

示例11: test_get_data_text_filter

# 需要导入模块: from geokey.contributions.tests.model_factories import ObservationFactory [as 别名]
# 或者: from geokey.contributions.tests.model_factories.ObservationFactory import create [as 别名]
    def test_get_data_text_filter(self):
        user = UserFactory.create()
        project = ProjectFactory.create()

        category_1 = CategoryFactory(**{'project': project})
        TextFieldFactory(**{
            'key': 'text',
            'category': category_1
        })
        category_2 = CategoryFactory(**{'project': project})
        TextFieldFactory(**{
            'key': 'bla',
            'category': category_2
        })

        UserGroupFactory.create(
            add_users=[user],
            **{
                'project': project,
                'filters': {category_1.id: {'text': 'yes'}}
            }
        )

        for x in range(0, 5):
            ObservationFactory.create(**{
                'project': project,
                'category': category_1,
                'properties': {'text': 'yes %s' % x}}
            )

            ObservationFactory.create(**{
                'project': project,
                'category': category_1,
                'status': 'pending',
                'properties': {'text': 'yes %s' % x}}
            )

            ObservationFactory.create(**{
                'project': project,
                'category': category_1,
                'properties': {'text': 'no %s' % x}}
            )

            ObservationFactory.create(**{
                'project': project,
                'category': category_2,
                'properties': {'bla': 'yes %s' % x}}
            )

        self.assertEqual(project.get_all_contributions(user).count(), 5)
开发者ID:Josh1billion,项目名称:geokey,代码行数:52,代码来源:test_models.py

示例12: test_get_data_combined

# 需要导入模块: from geokey.contributions.tests.model_factories import ObservationFactory [as 别名]
# 或者: from geokey.contributions.tests.model_factories.ObservationFactory import create [as 别名]
    def test_get_data_combined(self):
        user = UserF.create()
        project = ProjectF.create(add_admins=[user])
        category_1 = CategoryFactory(**{'project': project})
        category_2 = CategoryFactory(**{'project': project})
        category_3 = CategoryFactory(**{'project': project})
        view = GroupingFactory(**{'project': project})
        for x in range(0, 5):
            ObservationFactory.create(**{
                'project': project,
                'category': category_1}
            )
            ObservationFactory.create(**{
                'project': project,
                'category': category_2}
            )
            ObservationFactory.create(**{
                'project': project,
                'category': category_3}
            )

        RuleFactory(**{
            'grouping': view,
            'category': category_1
        })
        RuleFactory(**{
            'grouping': view,
            'category': category_2
        })

        self.assertEqual(view.data(user).count(), 10)
        for observation in view.data(user):
            self.assertNotEqual(
                observation.category, category_3)
开发者ID:tainita01,项目名称:geokey,代码行数:36,代码来源:test_model.py

示例13: test_get_updated_data

# 需要导入模块: from geokey.contributions.tests.model_factories import ObservationFactory [as 别名]
# 或者: from geokey.contributions.tests.model_factories.ObservationFactory import create [as 别名]
    def test_get_updated_data(self):
        user = UserF.create()
        project = ProjectF.create(add_admins=[user])
        category_1 = CategoryFactory(**{'project': project})
        TextFieldFactory(**{
            'key': 'text',
            'category': category_1
        })

        observation = ObservationFactory.create(**{
            'project': project,
            'category': category_1,
            'properties': {'text': 'yes to update'}
        })

        for x in range(0, 5):
            ObservationFactory.create(**{
                'project': project,
                'category': category_1,
                'properties': {'text': 'yes ' + str(x)}
            })

            ObservationFactory.create(**{
                'project': project,
                'category': category_1,
                'properties': {'text': 'no ' + str(x)}
            })

        view = GroupingFactory(**{'project': project})
        RuleFactory(**{
            'grouping': view,
            'category': category_1,
            'constraints': {'text': 'yes'}
        })

        updater = UserF()
        update = {'text': 'yes, this has been updated', 'version': 1}
        observation.update(properties=update, updator=updater)
        self.assertEqual(view.data(user).count(), 6)
开发者ID:tainita01,项目名称:geokey,代码行数:41,代码来源:test_model.py

示例14: test_get_context_data

# 需要导入模块: from geokey.contributions.tests.model_factories import ObservationFactory [as 别名]
# 或者: from geokey.contributions.tests.model_factories.ObservationFactory import create [as 别名]
    def test_get_context_data(self):
        """Test getting context data."""
        user = UserFactory.create(**{'is_superuser': True})

        # 1 contribution, 1 comment
        project_1 = ProjectFactory.create()
        category_1 = CategoryFactory.create(project=project_1)
        contribution_1 = ObservationFactory.create(
            project=project_1,
            category=category_1)
        CommentFactory.create(commentto=contribution_1)

        # 2 contributions (1 deleted), 2 comments
        project_2 = ProjectFactory.create(add_admins=[user])
        category_2 = CategoryFactory.create(project=project_2)
        contribution_2 = ObservationFactory.create(
            project=project_2,
            category=category_2)
        CommentFactory.create(commentto=contribution_2)
        contribution_3 = ObservationFactory.create(
            project=project_2,
            category=category_2)
        CommentFactory.create(commentto=contribution_3)
        contribution_3.delete()

        # 2 contributions (1 deleted), 3 comments (1 deleted)
        project_3 = ProjectFactory.create(add_moderators=[user])
        category_3 = CategoryFactory.create(project=project_3)
        contribution_4 = ObservationFactory.create(
            project=project_3,
            category=category_3)
        CommentFactory.create(commentto=contribution_4)
        comment_to_delete = CommentFactory.create(commentto=contribution_4)
        comment_to_delete.delete()
        contribution_5 = ObservationFactory.create(
            project=project_3,
            category=category_3)
        CommentFactory.create(commentto=contribution_5)
        contribution_5.delete()

        # 1 contribution, 2 comments (1 deleted)
        project_4 = ProjectFactory.create(add_contributors=[user])
        category_4 = CategoryFactory.create(project=project_4)
        contribution_6 = ObservationFactory.create(
            project=project_4,
            category=category_4)
        CommentFactory.create(commentto=contribution_6)
        comment_to_delete = CommentFactory.create(commentto=contribution_6)
        comment_to_delete.delete()

        view = ManageProjects()
        context = view.get_context_data()
        self.assertEqual(len(context.get('projects')), 4)

        for project in context.get('projects'):
            project.refresh_from_db()
            self.assertEqual(project.contributions_count, 1)
            self.assertEqual(project.comments_count, 1)
            self.assertEqual(project.media_count, 0)
开发者ID:ExCiteS,项目名称:geokey,代码行数:61,代码来源:test_views.py

示例15: test_get_data_text_filter

# 需要导入模块: from geokey.contributions.tests.model_factories import ObservationFactory [as 别名]
# 或者: from geokey.contributions.tests.model_factories.ObservationFactory import create [as 别名]
    def test_get_data_text_filter(self):
        admin = UserF.create()
        project = ProjectF.create(add_admins=[admin])
        category_1 = CategoryFactory(**{'project': project})
        TextFieldFactory(**{
            'key': 'text',
            'category': category_1
        })
        category_2 = CategoryFactory(**{'project': project})
        TextFieldFactory(**{
            'key': 'bla',
            'category': category_2
        })

        for x in range(0, 5):
            ObservationFactory.create(**{
                'project': project,
                'category': category_1,
                'properties': {'text': 'yes ' + str(x)}}
            )

            ObservationFactory.create(**{
                'project': project,
                'category': category_1,
                'status': 'pending',
                'properties': {'text': 'yes ' + str(x)}}
            )

            ObservationFactory.create(**{
                'project': project,
                'category': category_1,
                'properties': {'text': 'no ' + str(x)}}
            )

            ObservationFactory.create(**{
                'project': project,
                'category': category_2,
                'properties': {'bla': 'yes ' + str(x)}}
            )

        viewer = UserF.create()
        view = GroupingFactory(add_viewers=[viewer], **{'project': project})
        RuleFactory(**{
            'grouping': view,
            'category': category_1,
            'constraints': {'text': 'yes'}
        })
        self.assertEqual(view.data(admin).count(), 10)
        self.assertEqual(view.data(viewer).count(), 5)
开发者ID:tainita01,项目名称:geokey,代码行数:51,代码来源:test_model.py


注:本文中的geokey.contributions.tests.model_factories.ObservationFactory.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。