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


Python ObservationFactory.create_batch方法代码示例

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


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

示例1: test

# 需要导入模块: from geokey.contributions.tests.model_factories import ObservationFactory [as 别名]
# 或者: from geokey.contributions.tests.model_factories.ObservationFactory import create_batch [as 别名]
    def test(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
        })

        ObservationFactory.create_batch(5, **{
            'project': project,
            'category': category_1,
            'properties': {'text': 'yes'}}
        )

        viewer = UserF.create()
        view = GroupingFactory(add_viewers=[viewer], **{'project': project})
        RuleFactory(**{
            'grouping': view,
            'category': category_1,
            'constraints': {'text': 'yes'}
        })

        serializer = GroupingSerializer(view, context={'user': admin})
        self.assertEqual(len(serializer.get_data(view).get('features')), 5)
        self.assertEqual(serializer.get_num_contributions(view), 5)
开发者ID:tainita01,项目名称:geokey,代码行数:33,代码来源:test_serializer.py

示例2: test_download_data_as_tsv

# 需要导入模块: from geokey.contributions.tests.model_factories import ObservationFactory [as 别名]
# 或者: from geokey.contributions.tests.model_factories.ObservationFactory import create_batch [as 别名]
    def test_download_data_as_tsv(self):
        project = ProjectFactory.create(**{'isprivate': False})
        EpiCollectProjectModel.objects.create(project=project, enabled=True)
        ObservationFactory.create_batch(
            20, **{'project': project, 'properties': {'key': 'value'}})

        factory = APIRequestFactory()
        url = reverse('geokey_epicollect:download', kwargs={
            'project_id': project.id
        }) + '?xml=false'
        request = factory.get(url)
        view = EpiCollectDownloadView.as_view()
        response = view(request, project_id=project.id)
        self.assertEqual(response.status_code, 200)
开发者ID:ExCiteS,项目名称:geokey-epicollect,代码行数:16,代码来源:test_views.py

示例3: test_get_user_contributions

# 需要导入模块: from geokey.contributions.tests.model_factories import ObservationFactory [as 别名]
# 或者: from geokey.contributions.tests.model_factories.ObservationFactory import create_batch [as 别名]
    def test_get_user_contributions(self):
        user = UserFactory.create()
        project = ProjectFactory.create()
        ObservationFactory.create_batch(
            5,
            **{'creator': user, 'project': project}
        )
        serializer = ProjectSerializer(project, context={'user': user})
        self.assertEqual(5, serializer.get_user_contributions(project))

        serializer = ProjectSerializer(
            project, context={'user': AnonymousUser()}
        )
        self.assertEqual(0, serializer.get_user_contributions(project))
开发者ID:Josh1billion,项目名称:geokey,代码行数:16,代码来源:test_serializers.py

示例4: test_get_created_before_and_after

# 需要导入模块: from geokey.contributions.tests.model_factories import ObservationFactory [as 别名]
# 或者: from geokey.contributions.tests.model_factories.ObservationFactory import create_batch [as 别名]
    def test_get_created_before_and_after(self):
        user = UserFactory.create()
        project = ProjectFactory.create()
        category_1 = CategoryFactory(**{'project': project})

        UserGroupFactory.create(
            add_users=[user],
            **{
                'project': project,
                'filters': {
                    category_1.id: {
                        'min_date': '2013-01-01 00:00:00',
                        'max_date': '2013-10-01 00:00:00'}
                }
            }
        )

        obs = ObservationFactory.create_batch(5, **{
            'project': project,
            'category': category_1
        })

        for o in obs:
            o.created_at = datetime(2014, 7, 23, 10, 34, 1, tzinfo=pytz.utc)
            o.save()

        obs = ObservationFactory.create_batch(5, **{
            'project': project,
            'category': category_1
        })

        for o in obs:
            o.created_at = datetime(2013, 7, 23, 10, 34, 1, tzinfo=pytz.utc)
            o.save()

        obs = ObservationFactory.create_batch(5, **{
            'project': project,
            'category': category_1
        })

        for o in obs:
            o.created_at = datetime(2012, 7, 23, 10, 34, 1, tzinfo=pytz.utc)
            o.save()

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

示例5: test_get_created_before_and_after

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

        obs = ObservationFactory.create_batch(5, **{
            'project': project,
            'category': category_1
        })

        for o in obs:
            o.created_at = datetime(2014, 7, 23, 10, 34, 1, tzinfo=pytz.utc)
            o.save()

        obs = ObservationFactory.create_batch(5, **{
            'project': project,
            'category': category_1
        })

        for o in obs:
            o.created_at = datetime(2013, 7, 23, 10, 34, 1, tzinfo=pytz.utc)
            o.save()

        obs = ObservationFactory.create_batch(5, **{
            'project': project,
            'category': category_1
        })

        for o in obs:
            o.created_at = datetime(2012, 7, 23, 10, 34, 1, tzinfo=pytz.utc)
            o.save()

        view = GroupingFactory(**{'project': project})
        RuleFactory(**{
            'grouping': view,
            'category': category_1,
            'min_date': datetime(2013, 1, 1, 0, 0, 0, tzinfo=pytz.utc),
            'max_date': datetime(2013, 10, 1, 0, 0, 0, tzinfo=pytz.utc)
        })

        self.assertEqual(view.data(user).count(), 5)
开发者ID:tainita01,项目名称:geokey,代码行数:43,代码来源:test_model.py

示例6: test_get_data_with_none_rule

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

        UserGroupFactory.create(
            add_users=[user],
            **{'project': project, 'filters': None}
        )

        ObservationFactory.create_batch(5, **{
            'project': project,
            'category': category_1}
        )
        ObservationFactory.create_batch(5, **{
            'project': project,
            'category': category_2}
        )
        ObservationFactory.create_batch(5, **{
            'project': project,
            'category': category_3}
        )

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


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