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


Python layers.Layers类代码示例

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


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

示例1: test_enumerate_attribute_values

    def test_enumerate_attribute_values(self):
        from c2cgeoportal.views.layers import Layers

        layer_id = self._create_layer(public=True)
        tablename = "table_%d" % layer_id
        settings = {
            "layers": {
                "enum": {
                    "layer_test": {
                        "table": tablename,
                        "attributes": {
                            "label": {
                                "column_name": "name"
                            }
                        }
                    }
                }
            }
        }

        request = self._get_request(layer_id)
        request.registry.settings.update(settings)
        request.matchdict['layer_name'] = 'layer_test'
        request.matchdict['field_name'] = 'label'
        layers = Layers(request)
        response = layers.enumerate_attribute_values()
        self.assertEquals(response, {
            'items': [{
                'label': 'bar',
                'value': 'bar'
            }, {
                'label': 'foo',
                'value': 'foo'
            }]
        })
开发者ID:kailIII,项目名称:c2cgeoportal,代码行数:35,代码来源:test_layers.py

示例2: test_count_none_area

    def test_count_none_area(self):
        from c2cgeoportal.views.layers import Layers

        layer_id = self._create_layer(none_area=True)
        request = self._get_request(layer_id)

        layers = Layers(request)
        response = layers.count()
        self.assertEquals(response, 2)
开发者ID:,项目名称:,代码行数:9,代码来源:

示例3: test_metadata_exclude_properties

    def test_metadata_exclude_properties(self):
        from c2cgeoportal.views.layers import Layers

        layer_id = self._create_layer(exclude_properties=True)
        request = self._get_request(layer_id, username=u"__test_user")

        layers = Layers(request)
        cls = layers.metadata()
        self.assertFalse(hasattr(cls, "name"))
开发者ID:,项目名称:,代码行数:9,代码来源:

示例4: test_delete_none_area

    def test_delete_none_area(self):
        from c2cgeoportal.views.layers import Layers

        layer_id = self._create_layer(none_area=True)
        request = self._get_request(layer_id, username=u"__test_user")
        request.matchdict["feature_id"] = 1
        request.method = "DELETE"
        layers = Layers(request)
        response = layers.delete()
        self.assertEquals(response.status_int, 204)
开发者ID:,项目名称:,代码行数:10,代码来源:

示例5: test_delete

    def test_delete(self):
        from c2cgeoportal.views.layers import Layers

        layer_id = self._create_layer()
        request = self._get_request(layer_id, username=u'__test_user')
        request.matchdict['feature_id'] = 1
        request.method = 'DELETE'
        layers = Layers(request)
        response = layers.delete()
        self.assertEquals(response.status_int, 204)
开发者ID:kailIII,项目名称:c2cgeoportal,代码行数:10,代码来源:test_layers.py

示例6: test_read_many

    def test_read_many(self):
        from geojson.feature import FeatureCollection
        from c2cgeoportal.views.layers import Layers

        layer_id = self._create_layer()
        request = self._get_request(layer_id, username=u"__test_user")

        layers = Layers(request)
        collection = layers.read_many()
        self.assertTrue(isinstance(collection, FeatureCollection))
        self.assertEquals([f.properties["child"] for f in collection.features], [u"c1é"])
开发者ID:,项目名称:,代码行数:11,代码来源:

示例7: test_read_one_public_notfound

    def test_read_one_public_notfound(self):
        from pyramid.httpexceptions import HTTPNotFound
        from c2cgeoportal.views.layers import Layers

        layer_id = self._create_layer(public=True)
        request = self._get_request(layer_id)
        request.matchdict["feature_id"] = 10000

        layers = Layers(request)
        feature = layers.read_one()
        self.assertTrue(isinstance(feature, HTTPNotFound))
开发者ID:,项目名称:,代码行数:11,代码来源:

示例8: test_metadata

    def test_metadata(self):
        from c2cgeoportal.views.layers import Layers

        layer_id = self._create_layer()
        request = self._get_request(layer_id, username=u"__test_user")

        layers = Layers(request)
        cls = layers.metadata()
        self.assertEquals(cls.__table__.name, "table_%d" % layer_id)
        self.assertTrue(hasattr(cls, "name"))
        self.assertTrue("child" in cls.__dict__)
开发者ID:,项目名称:,代码行数:11,代码来源:

示例9: test_create_validation_fails

    def test_create_validation_fails(self):
        from c2cgeoportal.views.layers import Layers

        layer_id = self._create_layer()
        request = self._get_request(layer_id, username=u"__test_user")
        request.method = "POST"
        request.body = '{"type": "FeatureCollection", "features": [{"type": "Feature", "properties": {"name": "foo", "child": "c1é"}, "geometry": {"type": "Point", "coordinates": [5, 45]}}, {"type": "Feature", "properties": {"text": "foo", "child": "c2é"}, "geometry": {"type": "LineString", "coordinates": [[5, 45], [5, 45]]}}]}'  # noqa
        layers = Layers(request)
        response = layers.create()
        self.assertEquals(request.response.status_int, 400)
        self.assertTrue("validation_error" in response)
        self.assertEquals(response["validation_error"], "Too few points in geometry component[5 45]")
开发者ID:,项目名称:,代码行数:12,代码来源:

示例10: test_create_none_area

    def test_create_none_area(self):
        from geojson.feature import FeatureCollection
        from c2cgeoportal.views.layers import Layers

        layer_id = self._create_layer(none_area=True)
        request = self._get_request(layer_id, username=u"__test_user")
        request.method = "POST"
        request.body = '{"type": "FeatureCollection", "features": [{"type": "Feature", "properties": {"name": "foo", "child": "c1é"}, "geometry": {"type": "Point", "coordinates": [5, 45]}}, {"type": "Feature", "properties": {"text": "foo", "child": "c2é"}, "geometry": {"type": "Point", "coordinates": [5, 45]}}]}'  # noqa
        layers = Layers(request)
        collection = layers.create()
        self.assertTrue(isinstance(collection, FeatureCollection))
        self.assertEquals(len(collection.features), 2)
开发者ID:,项目名称:,代码行数:12,代码来源:

示例11: test_read_many

    def test_read_many(self):
        from geojson.feature import FeatureCollection
        from c2cgeoportal.views.layers import Layers

        layer_id = self._create_layer()
        request = self._get_request(layer_id, username=u'__test_user')

        layers = Layers(request)
        collection = layers.read_many()
        self.assertTrue(isinstance(collection, FeatureCollection))
        self.assertEquals(len(collection.features), 1)
        self.assertEquals(collection.features[0].properties['child'], u'c1é')
开发者ID:CDTRH,项目名称:c2cgeoportal,代码行数:12,代码来源:test_layers.py

示例12: test_read_public_none_area

    def test_read_public_none_area(self):
        from geojson.feature import FeatureCollection
        from c2cgeoportal.views.layers import Layers

        layer_id = self._create_layer(public=True, none_area=True)
        request = self._get_request(layer_id)

        layers = Layers(request)
        collection = layers.read_many()
        self.assertTrue(isinstance(collection, FeatureCollection))
        self.assertEquals(len(collection.features), 2)
        self.assertEquals(collection.features[0].properties['child'], u'c1é')
        self.assertEquals(collection.features[1].properties['child'], u'c2é')
开发者ID:CDTRH,项目名称:c2cgeoportal,代码行数:13,代码来源:test_layers.py

示例13: test_update

    def test_update(self):
        from c2cgeoportal.views.layers import Layers

        layer_id = self._create_layer()
        request = self._get_request(layer_id, username=u'__test_user')
        request.matchdict['feature_id'] = 1
        request.method = 'PUT'
        request.body = '{"type": "Feature", "id": 1, "properties": {"name": "foobar", "child": "c2é"}, "geometry": {"type": "Point", "coordinates": [5, 45]}}'  # noqa
        layers = Layers(request)
        feature = layers.update()
        self.assertEquals(feature.id, 1)
        self.assertEquals(feature.name, 'foobar')
        self.assertEquals(feature.child, u'c2é')
开发者ID:kailIII,项目名称:c2cgeoportal,代码行数:13,代码来源:test_layers.py

示例14: test_update_none_area

    def test_update_none_area(self):
        from c2cgeoportal.views.layers import Layers

        layer_id = self._create_layer(none_area=True)
        request = self._get_request(layer_id, username=u"__test_user")
        request.matchdict["feature_id"] = 1
        request.method = "PUT"
        request.body = '{"type": "Feature", "id": 1, "properties": {"name": "foobar", "child": "c2é"}, "geometry": {"type": "Point", "coordinates": [5, 45]}}'  # noqa
        layers = Layers(request)
        feature = layers.update()
        self.assertEquals(feature.id, 1)
        self.assertEquals(feature.name, "foobar")
        self.assertEquals(feature.child, u"c2é")
开发者ID:,项目名称:,代码行数:13,代码来源:

示例15: test_update_validation_fails_simple

    def test_update_validation_fails_simple(self):
        from c2cgeoportal.views.layers import Layers

        layer_id = self._create_layer()
        request = self._get_request(layer_id, username=u"__test_user")
        request.matchdict["feature_id"] = 1
        request.method = "PUT"
        request.body = '{"type": "Feature", "id": 1, "properties": {"name": "foobar", "child": "c2é"}, "geometry": {"type": "LineString", "coordinates": [[5, 45], [6, 45], [5, 45]]}}'  # noqa
        layers = Layers(request)
        response = layers.update()
        self.assertEquals(request.response.status_int, 400)
        self.assertTrue("validation_error" in response)
        self.assertEquals(response["validation_error"], "Not simple")
开发者ID:,项目名称:,代码行数:13,代码来源:


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