本文整理汇总了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'
}]
})
示例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)
示例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"))
示例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)
示例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)
示例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é"])
示例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))
示例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__)
示例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]")
示例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)
示例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é')
示例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é')
示例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é')
示例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é")
示例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")