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


Python model_factories.NumericFieldFactory类代码示例

本文整理汇总了Python中geokey.categories.tests.model_factories.NumericFieldFactory的典型用法代码示例。如果您正苦于以下问题:Python NumericFieldFactory类的具体用法?Python NumericFieldFactory怎么用?Python NumericFieldFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_import_csv_last

    def test_import_csv_last(self):
        category = CategoryFactory.create()
        NumericFieldFactory.create(**{
            'name': 'ID',
            'key': 'id',
            'category': category
        })
        TextFieldFactory.create(**{
            'name': 'Name',
            'key': 'name',
            'category': category
        })
        TextFieldFactory.create(**{
            'name': 'Description',
            'key': 'description',
            'category': category
        })

        data_import = DataImportFactory.create(**{
            'fields': ['id', 'name', 'description'],
            'category': category,
            'project': category.project,
            'geom_field': 'geom'
        })

        data_import.import_csv(UserFactory.create())
        self.assertEqual(Observation.objects.count(), 2)
开发者ID:ExCiteS,项目名称:geokey-import,代码行数:27,代码来源:test_models.py

示例2: test_import_geomtry_inbetween

    def test_import_geomtry_inbetween(self):
        the_file = get_csv_file(['id', 'name', 'geom', 'description'])

        category = CategoryFactory.create()
        NumericFieldFactory.create(**{
            'name': 'ID',
            'key': 'id',
            'category': category
        })
        TextFieldFactory.create(**{
            'name': 'Name',
            'key': 'name',
            'category': category
        })
        TextFieldFactory.create(**{
            'name': 'Description',
            'key': 'description',
            'category': category
        })

        data_import = DataImportFactory.create(**{
            'fields': ['id', 'name', 'description'],
            'category': category,
            'project': category.project,
            'csv_file': File(open(the_file.name))
        })

        data_import.import_csv(UserFactory.create())
        self.assertEqual(Observation.objects.count(), 2)
开发者ID:ExCiteS,项目名称:geokey-import,代码行数:29,代码来源:test_models.py

示例3: test_update_draft_observation

    def test_update_draft_observation(self):
        creator = UserF()
        location = LocationFactory()
        category = CategoryFactory()
        TextFieldFactory.create(**{
            'key': 'text',
            'category': category,
            'required': True,
            'order': 0
        })
        NumericFieldFactory.create(**{
            'key': 'number',
            'category': category,
            'order': 1
        })
        data = {'number': 12}
        observation = Observation.create(
            properties=data, creator=creator, location=location,
            category=category, project=category.project,
            status='draft'
        )

        updater = UserF()
        update = {'number': 13}
        observation.update(properties=update, updator=updater, status='draft')

        self.assertEqual(observation.properties.get('number'), 13)
        self.assertEqual(observation.version, 1)
开发者ID:nagyistoce,项目名称:geokey,代码行数:28,代码来源:test_model.py

示例4: setUp

    def setUp(self):
        self.admin = UserF.create()
        self.contributor = UserF.create()
        self.view_member = UserF.create()
        self.non_member = UserF.create()

        self.project = ProjectF(
            add_admins=[self.admin],
            add_contributors=[self.contributor],
            add_viewers=[self.view_member]
        )
        self.category = CategoryFactory(**{
            'status': 'active',
            'project': self.project
        })

        TextFieldFactory.create(**{
            'key': 'key_1',
            'category': self.category,
            'order': 0
        })
        NumericFieldFactory.create(**{
            'key': 'key_2',
            'category': self.category,
            'order': 1
        })
开发者ID:tainita01,项目名称:geokey,代码行数:26,代码来源:test_serializers.py

示例5: test_filters

    def test_filters(self):
        category = CategoryFactory.create()
        TextFieldFactory.create(**{'category': category, 'key': 'text'})
        NumericFieldFactory.create(**{'category': category, 'key': 'number'})
        DateFieldFactory.create(**{'category': category, 'key': 'date'})
        DateTimeFieldFactory.create(
            **{'category': category, 'key': 'datetime'})
        TimeFieldFactory.create(**{'category': category, 'key': 'time'})
        lookup = LookupFieldFactory.create(
            **{'category': category, 'key': 'lookup'})
        val_1 = LookupValueFactory.create(**{'field': lookup})
        multiple = MultipleLookupFieldFactory.create(
            **{'category': category, 'key': 'multiple'})
        mul_1 = MultipleLookupValueFactory.create(**{'field': multiple})

        rule = RuleFactory.create(**{
            'category': category,
            'min_date': datetime.datetime(2007, 12, 5, 12, 00),
            'max_date': datetime.datetime(2012, 12, 5, 15, 00),
            'constraints': {
                'text': 'blah',
                'number': {'minval': 0, 'maxval': 10},
                'date': {'minval': 0, 'maxval': 10},
                'datetime': {'minval': 0, 'maxval': 10},
                'time': {'minval': 0, 'maxval': 10},
                'lookup': [val_1.id],
                'multiple': [mul_1.id]
            }
        })

        result = filters(rule)
        self.assertEqual(result.count('<li>'), 8)
开发者ID:tainita01,项目名称:geokey,代码行数:32,代码来源:test_template_tags.py

示例6: test_validate_full_invalid

    def test_validate_full_invalid(self):
        creator = UserF()
        location = LocationFactory()
        category = CategoryFactory()
        TextFieldFactory.create(**{
            'key': 'text',
            'category': category,
            'order': 0
        })
        NumericFieldFactory.create(**{
            'key': 'number',
            'category': category,
            'order': 1
        })
        data = {'text': 'Text', 'number': 12}
        observation = Observation.create(
            properties=data, creator=creator, location=location,
            category=category, project=category.project, status='active'
        )

        updater = UserF()
        update = {'text': 'Udpated Text', 'number': 'abc', 'version': 1}
        Observation.validate_full(category=category, data=update)
        observation.update(properties=update, updator=updater)

        self.assertEqual(observation.properties, data)
        self.assertEqual(observation.version, 1)
开发者ID:nagyistoce,项目名称:geokey,代码行数:27,代码来源:test_model.py

示例7: test_get_data_min_max_number_filter

    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,代码行数:59,代码来源:test_models.py

示例8: setUp

    def setUp(self):
        self.factory = APIRequestFactory()
        self.admin = UserF.create()
        self.contributor = UserF.create()
        self.non_member = UserF.create()

        self.project = ProjectF(
            add_admins=[self.admin],
            add_contributors=[self.contributor]
        )

        self.category = CategoryFactory(**{
            'status': 'active',
            'project': self.project
        })

        TextFieldFactory.create(**{
            'key': 'key_1',
            'category': self.category,
            'required': True,
            'order': 1
        })
        NumericFieldFactory.create(**{
            'key': 'key_2',
            'category': self.category,
            'minval': 0,
            'maxval': 1000,
            'order': 2
        })

        self.data = {
            "type": "Feature",
            "geometry": {
                "type": "Point",
                "coordinates": [
                    -0.13404607772827148,
                    51.52439200896907
                ]
            },
            "properties": {
                "key_1": "value 1",
                "key_2": 12
            },
            "meta": {
                "category": self.category.id,
            },
            "location": {
                "name": "UCL",
                "description": "UCL's main quad",
                "private": True
            }
        }
开发者ID:oliverroick,项目名称:geokey,代码行数:52,代码来源:test_views.py

示例9: test_log_create

    def test_log_create(self):
        """Test when numeric field gets created."""
        log_count_init = LoggerHistory.objects.count()
        field = NumericFieldFactory.create(**{
            'category': self.category})

        log = LoggerHistory.objects.last()
        log_count = LoggerHistory.objects.count()

        self.assertNotEqual(log.user, {
            'id': str(self.user.id),
            'display_name': self.user.display_name})
        self.assertEqual(log.project, {
            'id': str(self.project.id),
            'name': self.project.name})
        self.assertEqual(log.usergroup, None)
        self.assertEqual(log.category, {
            'id': str(self.category.id),
            'name': self.category.name})
        self.assertEqual(log.field, {
            'id': str(field.id),
            'name': field.name,
            'type': 'NumericField'})
        self.assertEqual(log.location, None)
        self.assertEqual(log.observation, None)
        self.assertEqual(log.comment, None)
        self.assertEqual(log.subset, None)
        self.assertEqual(log.action, {
            'id': 'created',
            'class': 'Field'})
        self.assertEqual(log_count, log_count_init + 1)
        self.assertEqual(log.historical, None)
开发者ID:ExCiteS,项目名称:geokey,代码行数:32,代码来源:test_log_numericfield.py

示例10: setUp

    def setUp(self):
        """Set up test method 'create_new_observation'."""
        self.admin = UserFactory.create()
        self.project = ProjectFactory.create(creator=self.admin)

        self.socialaccount = SocialAccount.objects.create(
            user=self.admin, provider='facebook', uid='1')
        self.category = CategoryFactory.create(
            name='Tweets',
            creator=self.admin,
            project=self.project
        )

        self.field_text = TextFieldFactory.create(
            key='tweet',
            category=self.category
        )

        self.tweet_id_field = NumericFieldFactory.create(
            key='tweet-id',
            category=self.category
        )

        self.si_pull = SocialInteractionPullFactory.create(
            socialaccount=self.socialaccount,
            project=self.project,
            creator=self.admin)

        self.geo_tweet = {
            'geometry': u'POINT (-0.1350858 51.5246635)',
            'text': u'#Project2 scorpion @adeuonce',
            'created_at': datetime(2017, 5, 23, 14, 43, 1),
            'id': 867028097530572801,
            'user': u'Pepito Grillo'}
开发者ID:ExCiteS,项目名称:geokey,代码行数:34,代码来源:test_utils.py

示例11: test_serialize_invalid_update

    def test_serialize_invalid_update(self):
        observation = ObservationFactory.create(
            **{'properties': {'number': 12}})
        NumericFieldFactory.create(**{
            'key': 'number',
            'category': observation.category})
        serializer = ContributionSerializer(
            observation,
            data={
                'properties': {
                    'number': "blah"
                }
            },
            context={'user': self.contributor, 'project': self.project}
        )
        serializer.is_valid(raise_exception=True)

        o = Observation.objects.get(pk=observation.id)
        self.assertEqual(o.attributes.get('number'), 12)
开发者ID:tainita01,项目名称:geokey,代码行数:19,代码来源:test_serializers.py

示例12: setUp

 def setUp(self):
     """Set up test."""
     self.user = UserFactory.create()
     self.project = ProjectFactory.create(**{
         'creator': self.user})
     self.category = CategoryFactory.create(**{
         'creator': self.user,
         'project': self.project})
     self.numericfield = NumericFieldFactory.create(**{
         'category': self.category})
开发者ID:ExCiteS,项目名称:geokey,代码行数:10,代码来源:test_log_numericfield.py

示例13: test_serialize_update

    def test_serialize_update(self):
        observation = ObservationFactory.create(
            **{'properties': {'number': 12}})
        NumericFieldFactory.create(**{
            'key': 'number',
            'category': observation.category})
        serializer = ContributionSerializer(
            observation,
            data={
                'properties': {
                    'number': 15
                }
            },
            context={'user': self.contributor, 'project': self.project}
        )
        serializer.is_valid()
        serializer.save()
        result = serializer.data

        self.assertEqual(
            result.get('properties').get('number'),
            15
        )
开发者ID:tainita01,项目名称:geokey,代码行数:23,代码来源:test_serializers.py

示例14: test_get_numericfield_filter

 def test_get_numericfield_filter(self):
     field = NumericFieldFactory.create(**{'name': 'Field'})
     self.assertEqual(
         get_numericfield_filter(field, {"minval": 5}),
         '<li>Field is greater than 5</li>'
     )
     self.assertEqual(
         get_numericfield_filter(field, {"maxval": 5}),
         '<li>Field is lower than 5</li>'
     )
     self.assertEqual(
         get_numericfield_filter(field, {"minval": 1, "maxval": 5}),
         '<li>Field is greater than 1 and lower than 5</li>'
     )
开发者ID:tainita01,项目名称:geokey,代码行数:14,代码来源:test_template_tags.py


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