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


Python model_factories.TextFieldFactory类代码示例

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


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

示例1: 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

示例2: test_category_serialization

    def test_category_serialization(self):
        user = UserFactory.create()

        project = ProjectFactory.create(
            add_admins=[user]
        )
        CategoryFactory.create(**{'project': project})
        CategoryFactory.create(
            **{'project': project, 'status': 'inactive'}
        )
        o1 = CategoryFactory.create(**{'project': project})
        TextFieldFactory.create(**{'category': o1})
        o2 = CategoryFactory.create(**{'project': project})
        TextFieldFactory.create(**{'category': o2})

        request = self.factory.get(
            '/api/projects/%s/' % project.id)
        force_authenticate(request, user=user)
        view = SingleProject.as_view()
        response = view(request, project_id=project.id).render()

        self.assertEqual(response.status_code, 200)
        self.assertEqual(
            2,
            len(json.loads(response.content).get('categories'))
        )
开发者ID:ExCiteS,项目名称:geokey,代码行数:26,代码来源:test_views.py

示例3: 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

示例4: test_serialize_instance

    def test_serialize_instance(self):
        observation = ObservationFactory.create(
            **{'properties': {'key': 'value'}}
        )
        TextFieldFactory.create(**{
            'key': 'key',
            'category': observation.category})
        serializer = ContributionSerializer(
            observation,
            context={'user': self.contributor, 'project': self.project}
        )
        result = serializer.data

        self.assertEqual(
            result.get('properties').get('key'),
            'value'
        )
        self.assertEqual(
            result.get('meta').get('category').get('id'),
            observation.category.id)
        self.assertEqual(
            result.get('location').get('name'),
            observation.location.name)
        self.assertEqual(
            result.get('location').get('description'),
            observation.location.description)
        self.assertEqual(
            json.loads(observation.location.geometry.geojson),
            json.loads(result['location']['geometry'])
        )
开发者ID:tainita01,项目名称:geokey,代码行数:30,代码来源:test_serializers.py

示例5: 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

示例6: test_get_with_bbox_and_search

    def test_get_with_bbox_and_search(self):
        category = CategoryFactory(**{'project': self.project})
        TextFieldFactory.create(**{'key': 'text', 'category': category})
        geom1 = 'POINT (-55.555 -66.666)'
        geom2 = 'POINT (44.0010 33)'

        loc1 = LocationFactory.create()
        loc1.geometry = geom1
        loc1.save()

        loc2 = LocationFactory.create()
        loc2.geometry = geom2
        loc2.save()

        for x in range(0, 1):
            ObservationFactory.create(**{
                'project': self.project,
                'category': category,
                'properties': {'text': 'blah'},
                'location': loc1}

            )

            ObservationFactory.create(**{
                'project': self.project,
                'category': category,
                'properties': {'text': 'blub'},
                'location': loc2}
                
            )

        response = self.get(self.admin, bbox='41,32,45,35', search='blah')
        self.assertEqual(response.status_code, 200)
        self.assertEqual(len(json.loads(response.content).get('features')), 1)
开发者ID:ExCiteS,项目名称:geokey,代码行数:34,代码来源:test_views.py

示例7: 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

示例8: 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

示例9: 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

示例10: setUp

    def setUp(self):
        o_type = CategoryFactory.create()
        TextFieldFactory.create(**{'key': 'key', 'category': o_type})

        ObservationFactory.create_batch(5, **{
            'properties': {'key': 'xyz, blah, Abc'},
            'category': o_type
        })
        ObservationFactory.create_batch(5, **{
            'properties': {'key': 'blub'},
            'category': o_type
        })
开发者ID:oliverroick,项目名称:geokey,代码行数:12,代码来源:test_manager.py

示例11: 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

示例12: test_pre_delete_field

    def test_pre_delete_field(self):

        project = ProjectFactory.create(status='active')
        category = CategoryFactory.create(project=project)
        field = TextFieldFactory.create(category=category)

        aq_project = AirQualityProjectFactory.create(
            status='active',
            project=project
        )
        aq_category = AirQualityCategoryFactory.create(
            category=category,
            project=aq_project
        )
        aq_field = AirQualityFieldFactory.create(
            field=field,
            category=aq_category
        )

        pre_delete_field(TextField, instance=field)

        reference = AirQualityProject.objects.get(pk=aq_project.id)
        self.assertEqual(reference.status, 'inactive')
        self.assertEqual(
            AirQualityField.objects.filter(pk=aq_field.id).exists(),
            False
        )
        self.assertEquals(len(mail.outbox), 1)
开发者ID:ExCiteS,项目名称:geokey-airquality,代码行数:28,代码来源:test_models.py

示例13: 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

示例14: test_pre_observation_save

    def test_pre_observation_save(self):
        o_type = CategoryFactory.create()
        TextFieldFactory.create(
            **{'key': 'key', 'category': o_type, 'order': 0}
        )

        lookup = LookupFieldFactory.create(
            **{'category': o_type, 'key': 'lookup', 'order': 1}
        )
        kermit = LookupValueFactory.create(**{
            'field': lookup,
            'name': 'Kermit'
        })
        LookupValueFactory.create(**{
            'field': lookup,
            'name': 'Gonzo'
        })

        m_lookup = MultipleLookupFieldFactory.create(
            **{'category': o_type, 'key': 'm_lookup', 'order': 2}
        )
        m_kermit = MultipleLookupValueFactory.create(**{
            'field': m_lookup,
            'name': 'Kermit'
        })
        MultipleLookupValueFactory.create(**{
            'field': m_lookup,
            'name': 'Gonzo'
        })
        m_piggy = MultipleLookupValueFactory.create(**{
            'field': m_lookup,
            'name': 'Ms Piggy'
        })

        o = ObservationFactory.create(**{
            'properties': {
                'key': 'blah',
                'lookup': kermit.id,
                'm_lookup': [m_kermit.id, m_piggy.id]
            },
            'category': o_type
        })

        pre_save_observation_update(Observation, instance=o)
        self.assertIn('Ms Piggy', o.search_matches)
        self.assertIn('Kermit', o.search_matches)
        self.assertIn('blah', o.search_matches)
开发者ID:nagyistoce,项目名称:geokey,代码行数:47,代码来源:test_model.py

示例15: test_get_data_subset_user_group_filter

    def test_get_data_subset_user_group_filter(self):
        user = UserFactory.create()
        project = ProjectFactory.create()

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

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

        subset = SubsetFactory.create(**{
            'project': project,
            'filters': {category_1.id: {}}
        })

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

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

            ObservationFactory.create(**{
                'project': project,
                'category': category_1,
                'status': 'pending'}
            )

            ObservationFactory.create(**{
                'project': project,
                'category': category_2}
            )
        self.assertEqual(
            project.get_all_contributions(user, subset=subset.id).count(),
            0
        )
开发者ID:Josh1billion,项目名称:geokey,代码行数:46,代码来源:test_models.py


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