def setUp(self): from c2cgeoportal.models import DBSession, User, Role, Layer, \ RestrictionArea, Theme, LayerGroup role1 = Role(name=u'__test_role1') user1 = User(username=u'__test_user1', password=u'__test_user1', role=role1) role2 = Role(name=u'__test_role2', extent=WKTSpatialElement( "POLYGON((1 2, 1 4, 3 4, 3 2, 1 2))", srid=21781)) user2 = User(username=u'__test_user2', password=u'__test_user2', role=role2) public_layer = Layer(name=u'__test_public_layer', order=40, public=True) public_layer.isChecked = False private_layer = Layer(name=u'__test_private_layer', order=40, public=False) private_layer.geoTable = 'a_schema.a_geo_table' layer_in_group = Layer(name=u'__test_layer_in_group') layer_group = LayerGroup(name=u'__test_layer_group') layer_group.children = [layer_in_group] layer_wmsgroup = Layer(name=u'test_wmsfeaturesgroup') layer_wmsgroup.isChecked = False theme = Theme(name=u'__test_theme') theme.children = [ public_layer, private_layer, layer_group, layer_wmsgroup ] poly = "POLYGON((-100 0, -100 20, 100 20, 100 0, -100 0))" area = WKTSpatialElement(poly, srid=21781) RestrictionArea(name=u'__test_ra1', description=u'', layers=[private_layer], roles=[role1], area=area) area = WKTSpatialElement(poly, srid=21781) RestrictionArea(name=u'__test_ra2', description=u'', layers=[private_layer], roles=[role2], area=area, readwrite=True) DBSession.add_all([user1, user2, public_layer, private_layer]) transaction.commit()
def setUp(self): from c2cgeoportal.models import User, Role, Layer, RestrictionArea, \ Functionality, DBSession TestPoint.__table__.create(bind=DBSession.bind, checkfirst=True) geom = WKTSpatialElement("MULTIPOINT((-90 -45))", srid=21781) p1 = TestPoint(the_geom=geom, name=u'foo', city=u'Lausanne', country=u'Swiss') geom = WKTSpatialElement("MULTIPOINT((-90 45))", srid=21781) p2 = TestPoint(the_geom=geom, name=u'bar', city=u'Chambéry', country=u'France') geom = WKTSpatialElement("MULTIPOINT((90 45))", srid=21781) p3 = TestPoint(the_geom=geom, name=u'éàè', city="Paris", country=u'France') geom = WKTSpatialElement("MULTIPOINT((90 -45))", srid=21781) p4 = TestPoint(the_geom=geom, name=u'123', city='Londre', country=u'UK') pt1 = Functionality(name=u'print_template', value=u'1 Wohlen A4 portrait') pt2 = Functionality(name=u'print_template', value=u'2 Wohlen A3 landscape') user1 = User(username=u'__test_user1', password=u'__test_user1') role1 = Role(name=u'__test_role1', description=u'__test_role1', functionalities=[pt1, pt2]) user1.role = role1 user1.email = u'Tarenpion' user2 = User(username=u'__test_user2', password=u'__test_user2') role2 = Role(name=u'__test_role2', description=u'__test_role2', functionalities=[pt1, pt2]) user2.role = role2 user2.email = u'Tarenpion' user3 = User(username=u'__test_user3', password=u'__test_user3') role3 = Role(name=u'__test_role3', description=u'__test_role3', functionalities=[pt1, pt2]) user3.role = role3 user3.email = u'Tarenpion' layer2 = Layer(u'testpoint_protected', 400, public=False) layer3 = Layer(u'testpoint_protected_query_with_collect', public=False) area = "POLYGON((-100 30, -100 50, 100 50, 100 30, -100 30))" area = WKTSpatialElement(area, srid=21781) restricted_area1 = RestrictionArea(u'__test_ra1', u'', [layer2, layer3], [role1], area) area = "POLYGON((-100 0, -100 20, 100 20, 100 0, -100 0))" area = WKTSpatialElement(area, srid=21781) restricted_area2 = RestrictionArea(u'__test_ra2', u'', [layer2, layer3], [role2, role3], area) area = "POLYGON((-95 43, -95 47, 95 47, 95 43, -95 43))" area = WKTSpatialElement(area, srid=21781) restricted_area3 = RestrictionArea(u'__test_ra3', u'', [layer3], [role3], area, readwrite=True) DBSession.add_all([ p1, p2, p3, p4, user1, user2, user3, restricted_area1, restricted_area2, restricted_area3 ]) DBSession.flush() self.id_lausanne = p1.id self.id_paris = p3.id transaction.commit()
def setUp(self): self.config = testing.setUp() from c2cgeoportal.models import DBSession, User, Role, Layer, \ RestrictionArea, Theme, LayerGroup role1 = Role(name=u'__test_role1') user1 = User(username=u'__test_user1', password=u'__test_user1', role=role1) role2 = Role(name=u'__test_role2') user2 = User(username=u'__test_user2', password=u'__test_user2', role=role2) public_layer = Layer(name=u'__test_public_layer', order=40, public=True) public_layer.isChecked = False private_layer = Layer(name=u'__test_private_layer', order=40, public=False) private_layer.geoTable = 'a_schema.a_geo_table' layer_in_group = Layer(name=u'__test_layer_in_group') layer_group = LayerGroup(name=u'__test_layer_group') layer_group.children = [layer_in_group] theme = Theme(name=u'__test_theme') theme.children = [public_layer, private_layer, layer_group] poly = "POLYGON((-100 0, -100 20, 100 20, 100 0, -100 0))" area = WKTSpatialElement(poly, srid=21781) ra = RestrictionArea(name=u'__test_ra1', description=u'', layers=[private_layer], roles=[role1], area=area) area = WKTSpatialElement(poly, srid=21781) ra = RestrictionArea(name=u'__test_ra2', description=u'', layers=[private_layer], roles=[role2], area=area, readwrite=True) DBSession.add_all([user1, user2, public_layer, private_layer]) transaction.commit()
def setUp(self): from c2cgeoportal.models import DBSession, Layer, \ Theme, LayerGroup layer = Layer(name=u'__test_layer', public=True) layer_group = LayerGroup(name=u'__test_layer_group') layer_group.children = [layer, layer_group] theme = Theme(name=u'__test_theme') theme.children = [layer, layer_group] DBSession.add_all([layer, layer_group, theme]) transaction.commit()
def setUp(self): from c2cgeoportal.models import DBSession, Layer, Theme layer = Layer(name=u'__test_layer') mobile_only_layer = Layer(name=u'__test_mobile_only_layer') mobile_only_layer.inDesktopViewer = False desktop_only_layer = Layer(name=u'__test_desktop_only_layer') desktop_only_layer.inMobileViewer = False theme = Theme(name=u'__test_theme') theme.children = [layer, mobile_only_layer, desktop_only_layer] theme.inMobileViewer = True mobile_only_theme = Theme(name=u'__test_mobile_only_theme') mobile_only_theme.children = [layer] mobile_only_theme.inDesktopViewer = False mobile_only_theme.inMobileViewer = True desktop_only_theme = Theme(name=u'__test_desktop_only_theme') desktop_only_theme.children = [layer] desktop_only_theme.inMobileViewer = False # the following theme should not appear in the list of themes on desktop # nor on mobile # It should be accessible by explicitely loading it in mobile though mobile_private_theme = Theme(name=u'__test_mobile_private_theme') mobile_private_theme.children = [layer] mobile_private_theme.inDesktopViewer = False mobile_private_theme.inMobileViewer = False DBSession.add_all([ layer, mobile_only_layer, desktop_only_layer, theme, mobile_only_theme, desktop_only_theme, mobile_private_theme ]) transaction.commit()
def test_layer(self): import httplib2 from c2cgeoportal.views.entry import Entry from c2cgeoportal.models import Layer, LayerGroup from c2cgeoportal.lib.wmstparsing import TimeInformation request = self._create_request_obj() request.static_url = lambda name: '/dummy/static/' + name request.route_url = lambda name: '/dummy/route/' + name request.registry.settings['project'] = 'test_layer' entry = Entry(request) self.assertEqual( entry._group(LayerGroup(), [], [], None, TimeInformation()), (None, [], False)) layer = Layer() layer.id = 20 layer.name = 'test internal WMS' layer.metadataURL = "http://example.com/tiwms" layer.isChecked = True layer.layerType = "internal WMS" layer.imageType = "image/png" layer.style = "my-style" layer.kml = "tiwms.kml" layer.legend = True layer.legendRule = "rule" layer.legendImage = "legend:static/tiwms-legend.png" layer.isLegendExpanded = False layer.minResolution = 10 layer.maxResolution = 1000 layer.disclaimer = "Camptocamp" layer.identifierAttributeField = "name" layer.geoTable = "tiwms" layer.public = True self.assertEqual(entry._layer(layer, [], None, TimeInformation( )), ({ 'id': 20, 'name': 'test internal WMS', 'metadataURL': 'http://example.com/tiwms', 'isChecked': True, 'icon': '/dummy/route/mapserverproxy?SERVICE=WMS&VERSION=1.1.1&' 'REQUEST=GetLegendGraphic&LAYER=test internal WMS&FORMAT=image/png&TRANSPARENT=TRUE&RULE=rule', 'type': u'internal WMS', 'imageType': 'image/png', 'style': 'my-style', 'kml': '/dummy/static/test_layer:static/tiwms.kml', 'legend': True, 'legendImage': '/dummy/static/legend:static/tiwms-legend.png', 'isLegendExpanded': False, 'minResolutionHint': 10, 'maxResolutionHint': 1000, 'disclaimer': 'Camptocamp', 'identifierAttribute': 'name', 'editable': True, 'public': True, }, ['The layer test internal WMS is not defined in WMS capabilities'])) layer = Layer() layer.id = 20 layer.name = 'test external WMS' layer.isChecked = False layer.icon = "tewms.png" layer.layerType = "external WMS" layer.url = "http://example.com" layer.imageType = "image/jpeg" layer.isSingleTile = True layer.legend = False layer.isLegendExpanded = False layer.minResolution = 10 layer.maxResolution = 1000 layer.public = True self.assertEqual(entry._layer( layer, [], None, TimeInformation), ({ 'id': 20, 'name': 'test external WMS', 'icon': '/dummy/static/test_layer:static/tewms.png', 'isChecked': False, 'type': u'external WMS', 'url': 'http://example.com', 'imageType': 'image/jpeg', 'isSingleTile': True, 'legend': False, 'isLegendExpanded': False, 'minResolutionHint': 10, 'maxResolutionHint': 1000, 'public': True, }, [])) layer = Layer() layer.id = 20 layer.name = 'test WMTS' layer.isChecked = False layer.layerType = "WMTS" layer.url = "http://example.com/WMTS-Capabilities.xml" layer.style = 'wmts-style' layer.dimensions = '{"DATE": "1012"}' layer.matrixSet = "swissgrid" layer.wmsUrl = 'http://example.com/' layer.wmsLayers = 'test' layer.legend = False layer.isLegendExpanded = False layer.minResolution = 10 layer.maxResolution = 1000 layer.public = True self.assertEqual(entry._layer(layer, [], None, TimeInformation()), ({ 'id': 20, 'name': 'test WMTS', 'isChecked': False, 'type': 'WMTS', 'url': 'http://example.com/WMTS-Capabilities.xml', 'style': 'wmts-style', 'dimensions': { u'DATE': u'1012' }, 'matrixSet': 'swissgrid', 'wmsUrl': 'http://example.com/', 'wmsLayers': 'test', 'legend': False, 'isLegendExpanded': False, 'minResolutionHint': 10, 'maxResolutionHint': 1000, 'public': True, }, [])) layer = Layer() layer.id = 20 layer.name = 'test WMTS' layer.isChecked = False layer.layerType = "WMTS" layer.url = "http://example.com/WMTS-Capabilities.xml" layer.wmsUrl = 'http://example.com/' layer.legend = False layer.isLegendExpanded = False layer.minResolution = 10 layer.maxResolution = 1000 layer.public = True self.assertEqual(entry._layer(layer, [], None, TimeInformation()), ({ 'id': 20, 'name': 'test WMTS', 'isChecked': False, 'type': 'WMTS', 'url': 'http://example.com/WMTS-Capabilities.xml', 'wmsUrl': 'http://example.com/', 'wmsLayers': 'test WMTS', 'legend': False, 'isLegendExpanded': False, 'minResolutionHint': 10, 'maxResolutionHint': 1000, 'public': True, }, [])) layer = Layer() layer.id = 20 layer.name = 'test WMTS' layer.isChecked = False layer.layerType = "WMTS" layer.url = "http://example.com/WMTS-Capabilities.xml" layer.wmsLayers = 'test' layer.legend = False layer.isLegendExpanded = False layer.minResolution = 10 layer.maxResolution = 1000 layer.public = True self.assertEqual(entry._layer(layer, [], None, TimeInformation()), ({ 'id': 20, 'name': 'test WMTS', 'isChecked': False, 'type': 'WMTS', 'url': 'http://example.com/WMTS-Capabilities.xml', 'wmsUrl': '/dummy/route/mapserverproxy', 'wmsLayers': 'test', 'queryLayers': [], 'legend': False, 'isLegendExpanded': False, 'minResolutionHint': 10, 'maxResolutionHint': 1000, 'public': True, }, [])) layer = Layer() layer.id = 20 layer.name = 'test no 2D' layer.isChecked = False layer.layerType = "no 2D" layer.legend = False layer.isLegendExpanded = False layer.metadataURL = 'http://example.com/wmsfeatures.metadata' layer.public = True self.assertEqual(entry._layer( layer, [], None, TimeInformation()), ({ 'id': 20, 'name': u'test no 2D', 'isChecked': False, 'type': u'no 2D', 'legend': False, 'isLegendExpanded': False, 'metadataURL': u'http://example.com/wmsfeatures.metadata', 'public': True, }, [])) curdir = os.path.dirname(os.path.abspath(__file__)) mapfile = os.path.join(curdir, 'c2cgeoportal_test.map') mapfile = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'c2cgeoportal_test.map') params = ( ('map', mapfile), ('SERVICE', 'WMS'), ('VERSION', '1.1.1'), ('REQUEST', 'GetCapabilities'), ) mapserv = "%s?map=%s&" % (mapserv_url, mapfile) url = mapserv + '&'.join(['='.join(p) for p in params]) http = httplib2.Http() h = {'Host': host} resp, xml = http.request(url, method='GET', headers=h) wms = WebMapService(None, xml=xml) wms_layers = list(wms.contents) layer = Layer() layer.id = 20 layer.name = 'test_wmsfeaturesgroup' layer.layerType = "internal WMS" layer.imageType = "image/png" layer.isChecked = False layer.legend = False layer.isLegendExpanded = False layer.public = True self.assertEqual( entry._layer(layer, wms_layers, wms, TimeInformation()), ({ 'id': 20, 'name': u'test_wmsfeaturesgroup', 'type': u'internal WMS', 'isChecked': False, 'legend': False, 'isLegendExpanded': False, 'imageType': u'image/png', 'minResolutionHint': 1.76, 'maxResolutionHint': 8.8200000000000003, 'public': True, 'queryable': 0, 'metadataUrls': [{ 'url': 'http://example.com/wmsfeatures.metadata', 'type': 'TC211', 'format': 'text/plain', }], 'childLayers': [{ 'name': u'test_wmsfeatures', 'minResolutionHint': 1.76, 'maxResolutionHint': 8.8200000000000003, 'queryable': 1, }], }, [])) layer_t1 = Layer() layer_t1.id = 20 layer_t1.name = 'test_wmstime' layer_t1.layerType = "internal WMS" layer_t1.imageType = "image/png" layer_t1.isChecked = False layer_t1.legend = False layer_t1.isLegendExpanded = False layer_t1.public = True layer_t1.timeMode = 'single' time = TimeInformation() entry._layer(layer_t1, wms_layers, wms, time) self.assertEqual( time.to_dict(), { 'resolution': 'year', 'interval': (1, 0, 0, 0), 'maxValue': '2010-01-01T00:00:00Z', 'minValue': '2000-01-01T00:00:00Z', 'mode': 'single', }) layer_t2 = Layer() layer_t2.id = 30 layer_t2.name = 'test_wmstime2' layer_t2.layerType = "internal WMS" layer_t2.imageType = "image/png" layer_t2.isChecked = False layer_t2.legend = False layer_t2.isLegendExpanded = False layer_t2.public = True layer_t2.timeMode = 'single' time = TimeInformation() entry._layer(layer_t2, wms_layers, wms, time) self.assertEqual( time.to_dict(), { 'resolution': 'year', 'interval': (1, 0, 0, 0), 'maxValue': '2020-01-01T00:00:00Z', 'minValue': '2015-01-01T00:00:00Z', 'mode': 'single', }) group = LayerGroup() group.name = 'time' group.children = [layer_t1, layer_t2] time = TimeInformation() entry._group(group, [layer_t1, layer_t2], wms_layers, wms, time) self.assertEqual( time.to_dict(), { 'resolution': 'year', 'interval': (1, 0, 0, 0), 'maxValue': '2020-01-01T00:00:00Z', 'minValue': '2000-01-01T00:00:00Z', 'mode': 'single', }) layer = Layer() layer.id = 20 layer.name = 'test_wmstimegroup' layer.layerType = "internal WMS" layer.imageType = "image/png" layer.isChecked = False layer.legend = False layer.isLegendExpanded = False layer.public = True layer.timeMode = 'single' time = TimeInformation() entry._layer(layer, wms_layers, wms, time) self.assertEqual( time.to_dict(), { 'resolution': 'year', 'interval': (1, 0, 0, 0), 'maxValue': '2020-01-01T00:00:00Z', 'minValue': '2000-01-01T00:00:00Z', 'mode': 'single', }) layer = Layer() layer.id = 20 layer.name = 'test WMTS' layer.isChecked = False layer.layerType = "WMTS" layer.url = "http://example.com/WMTS-Capabilities.xml" layer.wmsLayers = 'test_wmsfeatures' layer.legend = False layer.isLegendExpanded = False layer.public = True self.assertEqual( entry._layer(layer, wms_layers, wms, TimeInformation()), ({ 'id': 20, 'name': 'test WMTS', 'isChecked': False, 'type': 'WMTS', 'url': 'http://example.com/WMTS-Capabilities.xml', 'wmsUrl': '/dummy/route/mapserverproxy', 'wmsLayers': 'test_wmsfeatures', 'queryLayers': [{ 'name': 'test_wmsfeatures', 'minResolutionHint': 1.76, 'maxResolutionHint': 8.8200000000000003 }], 'legend': False, 'isLegendExpanded': False, 'public': True, }, [])) layer = Layer() layer.id = 20 layer.name = 'test WMTS' layer.isChecked = False layer.layerType = "WMTS" layer.url = "http://example.com/WMTS-Capabilities.xml" layer.wmsLayers = 'foo' layer.queryLayers = 'test_wmsfeatures' layer.legend = False layer.isLegendExpanded = False layer.public = True self.assertEqual( entry._layer(layer, wms_layers, wms, TimeInformation()), ({ 'id': 20, 'name': 'test WMTS', 'isChecked': False, 'type': 'WMTS', 'url': 'http://example.com/WMTS-Capabilities.xml', 'wmsUrl': '/dummy/route/mapserverproxy', 'wmsLayers': 'foo', 'queryLayers': [{ 'name': 'test_wmsfeatures', 'minResolutionHint': 1.76, 'maxResolutionHint': 8.8200000000000003 }], 'legend': False, 'isLegendExpanded': False, 'public': True, }, [])) group1 = LayerGroup() group1.name = 'block' group2 = LayerGroup() group2.name = 'node' group2.metadataURL = 'http://example.com/group.metadata' layer = Layer() layer.id = 20 layer.name = 'test layer in group' layer.isChecked = False layer.layerType = "internal WMS" layer.imageType = "image/png" layer.legend = False layer.isLegendExpanded = False layer.public = True group1.children = [group2] group2.children = [layer] self.assertEqual( entry._group(group1, [layer], [], None, TimeInformation()), ({ 'isExpanded': False, 'isInternalWMS': True, 'name': u'block', 'isBaseLayer': False, 'children': [{ 'isExpanded': False, 'isInternalWMS': True, 'name': u'node', 'isBaseLayer': False, 'metadataURL': 'http://example.com/group.metadata', 'children': [{ 'name': u'test layer in group', 'id': 20, 'isChecked': False, 'type': u'internal WMS', 'legend': False, 'isLegendExpanded': False, 'imageType': u'image/png', 'public': True, }] }] }, [ 'The layer test layer in group is not defined in WMS capabilities' ], False)) group1 = LayerGroup() group1.isInternalWMS = True group2 = LayerGroup() group2.isInternalWMS = False group1.children = [group2] _, errors, stop = entry._group(group1, [], [], None, TimeInformation()) self.assertTrue(len(errors) > 0) self.assertFalse(stop) group1 = LayerGroup() group1.isInternalWMS = False group2 = LayerGroup() group2.isInternalWMS = True group1.children = [group2] _, errors, stop = entry._group(group1, [], [], None, TimeInformation()) self.assertTrue(len(errors) > 0) self.assertFalse(stop) group = LayerGroup() group.isInternalWMS = True layer = Layer() layer.layerType = 'internal WMS' group.children = [layer] _, errors, stop = entry._group(group, [layer], [], None, TimeInformation()) self.assertEqual(len(errors), 1) self.assertEqual(errors[0], "The layer is not defined in WMS capabilities") self.assertFalse(stop) group = LayerGroup() group.isInternalWMS = True layer = Layer() layer.layerType = 'external WMS' group.children = [layer] _, errors, stop = entry._group(group, [layer], [], None, TimeInformation()) self.assertTrue(len(errors) > 0) self.assertFalse(stop) group = LayerGroup() group.isInternalWMS = True layer = Layer() layer.layerType = 'WMTS' group.children = [layer] _, errors, stop = entry._group(group, [layer], [], None, TimeInformation()) self.assertTrue(len(errors) > 0) self.assertFalse(stop) group = LayerGroup() group.isInternalWMS = True layer = Layer() layer.layerType = 'no 2D' group.children = [layer] _, errors, stop = entry._group(group, [layer], [], None, TimeInformation()) self.assertTrue(len(errors) > 0) self.assertFalse(stop) group = LayerGroup() group.isInternalWMS = False layer = Layer() layer.layerType = 'internal WMS' group.children = [layer] _, errors, stop = entry._group(group, [layer], [], None, TimeInformation()) self.assertTrue(len(errors) > 0) self.assertFalse(stop) group = LayerGroup() group.isInternalWMS = False layer = Layer() layer.layerType = 'external WMS' group.children = [layer] _, errors, stop = entry._group(group, [layer], [], None, TimeInformation()) self.assertEqual(len(errors), 0) self.assertFalse(stop) group = LayerGroup() group.isInternalWMS = False layer = Layer() layer.layerType = 'WMTS' group.children = [layer] _, errors, stop = entry._group(group, [layer], [], None, TimeInformation()) self.assertEqual(len(errors), 0) self.assertFalse(stop) group = LayerGroup() group.isInternalWMS = False layer = Layer() layer.layerType = 'no 2D' group.children = [layer] _, errors, stop = entry._group(group, [layer], [], None, TimeInformation()) self.assertEqual(len(errors), 0) self.assertFalse(stop)
def test_layer(self): import httplib2 from c2cgeoportal.views.entry import Entry from c2cgeoportal.models import Layer, LayerGroup, Theme request = testing.DummyRequest() request.headers['Host'] = host request.static_url = lambda url: '/dummy/static/' + url request.route_url = lambda url: '/dummy/route/' + url request.registry.settings = { 'project': 'test_layer', } entry = Entry(request) self.assertEqual(entry._group(LayerGroup(), [], [], None), (None, [], False)) layer = Layer() layer.id = 20 layer.name = 'test internal WMS' layer.metadataURL = "http://example.com/tiwms" layer.isChecked = True layer.layerType = "internal WMS" layer.imageType = "image/png" layer.style = "my-style" layer.kml = "tiwms.kml" layer.legend = True layer.legendRule = "rule" layer.legendImage = "legend:static/tiwms-legend.png" layer.minResolution = 10 layer.maxResolution = 1000 layer.disclaimer = "Camptocamp" layer.identifierAttributeField = "name" layer.geoTable = "tiwms" layer.public = True self.assertEqual(entry._layer(layer, [], None), ({ 'id': 20, 'name': 'test internal WMS', 'metadataURL': 'http://example.com/tiwms', 'isChecked': True, 'icon': '/dummy/route/mapserverproxy?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetLegendGraphic&LAYER=test internal WMS&FORMAT=image/png&TRANSPARENT=TRUE&RULE=rule', 'type': u'internal WMS', 'imageType': 'image/png', 'style': 'my-style', 'kml': '/dummy/static/test_layer:static/tiwms.kml', 'legend': True, 'legendImage': '/dummy/static/legend:static/tiwms-legend.png', 'minResolutionHint': 10, 'maxResolutionHint': 1000, 'disclaimer': 'Camptocamp', 'identifierAttribute': 'name', 'editable': True, 'public': True, }, [])) layer = Layer() layer.id = 20 layer.name = 'test external WMS' layer.isChecked = False layer.icon = "tewms.png" layer.layerType = "external WMS" layer.url = "http://example.com" layer.imageType = "image/jpeg" layer.isSingleTile = True layer.legend = False layer.minResolution = 10 layer.maxResolution = 1000 layer.public = True self.assertEqual(entry._layer(layer, [], None), ({ 'id': 20, 'name': 'test external WMS', 'icon': '/dummy/static/test_layer:static/tewms.png', 'isChecked': False, 'type': u'external WMS', 'url': 'http://example.com', 'imageType': 'image/jpeg', 'isSingleTile': True, 'legend': False, 'minResolutionHint': 10, 'maxResolutionHint': 1000, 'public': True, }, [])) layer = Layer() layer.id = 20 layer.name = 'test WMTS' layer.isChecked = False layer.layerType = "WMTS" layer.url = "http://example.com/WMTS-Capabilities.xml" layer.style = 'wmts-style' layer.dimensions = '{"DATE": "1012"}' layer.matrixSet = "swissgrid" layer.wmsUrl = 'http://example.com/' layer.wmsLayers = 'test' layer.legend = False layer.minResolution = 10 layer.maxResolution = 1000 layer.public = True self.assertEqual(entry._layer(layer, [], None), ({ 'id': 20, 'name': 'test WMTS', 'isChecked': False, 'type': 'WMTS', 'url': 'http://example.com/WMTS-Capabilities.xml', 'style': 'wmts-style', 'dimensions': {u'DATE': u'1012'}, 'matrixSet': 'swissgrid', 'wmsUrl': 'http://example.com/', 'wmsLayers': 'test', 'legend': False, 'minResolutionHint': 10, 'maxResolutionHint': 1000, 'public': True, }, [])) layer = Layer() layer.id = 20 layer.name = 'test WMTS' layer.isChecked = False layer.layerType = "WMTS" layer.url = "http://example.com/WMTS-Capabilities.xml" layer.wmsUrl = 'http://example.com/' layer.legend = False layer.minResolution = 10 layer.maxResolution = 1000 layer.public = True self.assertEqual(entry._layer(layer, [], None), ({ 'id': 20, 'name': 'test WMTS', 'isChecked': False, 'type': 'WMTS', 'url': 'http://example.com/WMTS-Capabilities.xml', 'wmsUrl': 'http://example.com/', 'wmsLayers': 'test WMTS', 'legend': False, 'minResolutionHint': 10, 'maxResolutionHint': 1000, 'public': True, }, [])) layer = Layer() layer.id = 20 layer.name = 'test WMTS' layer.isChecked = False layer.layerType = "WMTS" layer.url = "http://example.com/WMTS-Capabilities.xml" layer.wmsLayers = 'test' layer.legend = False layer.minResolution = 10 layer.maxResolution = 1000 layer.public = True self.assertEqual(entry._layer(layer, [], None), ({ 'id': 20, 'name': 'test WMTS', 'isChecked': False, 'type': 'WMTS', 'url': 'http://example.com/WMTS-Capabilities.xml', 'wmsUrl': '/dummy/route/mapserverproxy', 'wmsLayers': 'test', 'queryLayers': [], 'legend': False, 'minResolutionHint': 10, 'maxResolutionHint': 1000, 'public': True, }, [])) layer = Layer() layer.id = 20 layer.name = 'test no 2D' layer.isChecked = False layer.layerType = "no 2D" layer.legend = False layer.metadataURL = 'http://example.com/wmsfeatures.metadata' layer.public = True self.assertEqual(entry._layer(layer, [], None), ({ 'id': 20, 'name': u'test no 2D', 'isChecked': False, 'type': u'no 2D', 'legend': False, 'metadataURL': u'http://example.com/wmsfeatures.metadata', 'public': True, }, [])) curdir = os.path.dirname(os.path.abspath(__file__)) mapfile = os.path.join(curdir, 'c2cgeoportal_test.map') mapfile = os.path.join( os.path.dirname(os.path.abspath(__file__)), 'c2cgeoportal_test.map' ) params = ( ('map', mapfile), ('SERVICE', 'WMS'), ('VERSION', '1.1.1'), ('REQUEST', 'GetCapabilities'), ) mapserv = "%s?map=%s&" % (mapserv_url, mapfile) url = mapserv + '&'.join(['='.join(p) for p in params]) http = httplib2.Http() h = {'Host': host} resp, xml =http.request(url, method='GET', headers=h) wms = WebMapService(None, xml=xml) wms_layers = list(wms.contents) layer = Layer() layer.id = 20 layer.name = 'test_wmsfeaturesgroup' layer.layerType = "internal WMS" layer.imageType = "image/png" layer.isChecked = False layer.legend = False layer.public = True self.assertEqual(entry._layer(layer, wms_layers, wms), ({ 'id': 20, 'name': u'test_wmsfeaturesgroup', 'type': u'internal WMS', 'isChecked': False, 'legend': False, 'imageType': u'image/png', 'minResolutionHint': 1.76, 'maxResolutionHint': 8.8200000000000003, 'public': True, 'queryable': 0, 'metadataUrls': [{ 'url': 'http://example.com/wmsfeatures.metadata', 'type': 'TC211', 'format': 'text/plain', }], 'childLayers': [{ 'name': u'test_wmsfeatures', 'minResolutionHint': 1.76, 'maxResolutionHint': 8.8200000000000003, 'queryable': 1, }], }, [])) layer = Layer() layer.id = 20 layer.name = 'test WMTS' layer.isChecked = False layer.layerType = "WMTS" layer.url = "http://example.com/WMTS-Capabilities.xml" layer.wmsLayers = 'test_wmsfeatures' layer.legend = False layer.public = True self.assertEqual(entry._layer(layer, wms_layers, wms), ({ 'id': 20, 'name': 'test WMTS', 'isChecked': False, 'type': 'WMTS', 'url': 'http://example.com/WMTS-Capabilities.xml', 'wmsUrl': '/dummy/route/mapserverproxy', 'wmsLayers': 'test_wmsfeatures', 'queryLayers': [{ 'name': 'test_wmsfeatures', 'minResolutionHint': 1.76, 'maxResolutionHint': 8.8200000000000003 }], 'legend': False, 'public': True, }, [])) layer = Layer() layer.id = 20 layer.name = 'test WMTS' layer.isChecked = False layer.layerType = "WMTS" layer.url = "http://example.com/WMTS-Capabilities.xml" layer.wmsLayers = 'foo' layer.queryLayers = 'test_wmsfeatures' layer.legend = False layer.public = True self.assertEqual(entry._layer(layer, wms_layers, wms), ({ 'id': 20, 'name': 'test WMTS', 'isChecked': False, 'type': 'WMTS', 'url': 'http://example.com/WMTS-Capabilities.xml', 'wmsUrl': '/dummy/route/mapserverproxy', 'wmsLayers': 'foo', 'queryLayers': [{ 'name': 'test_wmsfeatures', 'minResolutionHint': 1.76, 'maxResolutionHint': 8.8200000000000003 }], 'legend': False, 'public': True, }, [])) group1 = LayerGroup() group1.name = 'block' group2 = LayerGroup() group2.name = 'node' group2.metadataURL = 'http://example.com/group.metadata' layer = Layer() layer.id = 20 layer.name = 'test layer in group' layer.isChecked = False layer.layerType = "internal WMS" layer.imageType = "image/png" layer.legend = False layer.public = True group1.children = [group2] group2.children = [layer] self.assertEqual(entry._group(group1, [layer], [], None), ({ 'isExpanded': False, 'isInternalWMS': True, 'name': u'block', 'isBaseLayer': False, 'children': [{ 'isExpanded': False, 'isInternalWMS': True, 'name': u'node', 'isBaseLayer': False, 'metadataURL': 'http://example.com/group.metadata', 'children': [{ 'name': u'test layer in group', 'id': 20, 'isChecked': False, 'type': u'internal WMS', 'legend': False, 'imageType': u'image/png', 'public': True, }] }] }, [], False)) group1 = LayerGroup() group1.isInternalWMS = True group2 = LayerGroup() group2.isInternalWMS = False group1.children = [group2] _, errors, stop = entry._group(group1, [], [], None) self.assertTrue(len(errors) > 0) self.assertFalse(stop) group1 = LayerGroup() group1.isInternalWMS = False group2 = LayerGroup() group2.isInternalWMS = True group1.children = [group2] _, errors, stop = entry._group(group1, [], [], None) self.assertTrue(len(errors) > 0) self.assertFalse(stop) group = LayerGroup() group.isInternalWMS = True layer = Layer() layer.layerType = 'internal WMS' group.children = [layer] _, errors, stop = entry._group(group, [layer], [], None) self.assertEqual(len(errors), 0) self.assertFalse(stop) group = LayerGroup() group.isInternalWMS = True layer = Layer() layer.layerType = 'external WMS' group.children = [layer] _, errors, stop = entry._group(group, [layer], [], None) self.assertTrue(len(errors) > 0) self.assertFalse(stop) group = LayerGroup() group.isInternalWMS = True layer = Layer() layer.layerType = 'WMTS' group.children = [layer] _, errors, stop = entry._group(group, [layer], [], None) self.assertTrue(len(errors) > 0) self.assertFalse(stop) group = LayerGroup() group.isInternalWMS = True layer = Layer() layer.layerType = 'no 2D' group.children = [layer] _, errors, stop = entry._group(group, [layer], [], None) self.assertTrue(len(errors) > 0) self.assertFalse(stop) group = LayerGroup() group.isInternalWMS = False layer = Layer() layer.layerType = 'internal WMS' group.children = [layer] _, errors, stop = entry._group(group, [layer], [], None) self.assertTrue(len(errors) > 0) self.assertFalse(stop) group = LayerGroup() group.isInternalWMS = False layer = Layer() layer.layerType = 'external WMS' group.children = [layer] _, errors, stop = entry._group(group, [layer], [], None) self.assertEqual(len(errors), 0) self.assertFalse(stop) group = LayerGroup() group.isInternalWMS = False layer = Layer() layer.layerType = 'WMTS' group.children = [layer] _, errors, stop = entry._group(group, [layer], [], None) self.assertEqual(len(errors), 0) self.assertFalse(stop) group = LayerGroup() group.isInternalWMS = False layer = Layer() layer.layerType = 'no 2D' group.children = [layer] _, errors, stop = entry._group(group, [layer], [], None) self.assertEqual(len(errors), 0) self.assertFalse(stop)
def _create_layer(self, public=False, none_area=False, attr_list=False, exclude_properties=False): """ This function is central for this test class. It creates a layer with two features, and associates a restriction area to it. """ import transaction import sqlahelper from sqlalchemy import func from sqlalchemy import Column, Table, types, ForeignKey from sqlalchemy.ext.declarative import declarative_base from geoalchemy import (GeometryDDL, GeometryExtensionColumn, Point, WKTSpatialElement) from c2cgeoportal.models import DBSession, Layer, RestrictionArea self.__class__._table_index = self.__class__._table_index + 1 id = self.__class__._table_index engine = sqlahelper.get_engine() if not self.metadata: self.metadata = declarative_base(bind=engine).metadata tablename = "table_%d" % id table = Table('%s_child' % tablename, self.metadata, Column('id', types.Integer, primary_key=True), Column('name', types.Unicode), schema='public' ) table.create() ins = table.insert().values(name=u'c1é') c1_id = engine.connect().execute(ins).inserted_primary_key[0] ins = table.insert().values(name=u'c2é') c2_id = engine.connect().execute(ins).inserted_primary_key[0] table = Table( tablename, self.metadata, Column('id', types.Integer, primary_key=True), Column('child_id', types.Integer, ForeignKey('public.%s_child.id' % tablename)), Column('name', types.Unicode), GeometryExtensionColumn('geom', Point(srid=21781)), schema='public' ) GeometryDDL(table) table.create() ins = table.insert().values( child_id=c1_id, name='foo', geom=func.ST_GeomFromText('POINT(5 45)', 21781) ) engine.connect().execute(ins).inserted_primary_key[0] ins = table.insert().values( child_id=c2_id, name='bar', geom=func.ST_GeomFromText('POINT(6 46)', 21781) ) engine.connect().execute(ins).inserted_primary_key[0] if attr_list: ins = table.insert().values( child_id=c2_id, name='aaa,bbb,foo', geom=func.ST_GeomFromText('POINT(6 46)', 21781) ) engine.connect().execute(ins).inserted_primary_key[0] layer = Layer() layer.id = id layer.geoTable = tablename layer.public = public if exclude_properties: layer.excludeProperties = 'name' DBSession.add(layer) if not public: ra = RestrictionArea() ra.name = u'__test_ra' ra.layers = [layer] ra.roles = [self.role] ra.readwrite = True if not none_area: poly = 'POLYGON((4 44, 4 46, 6 46, 6 44, 4 44))' ra.area = WKTSpatialElement(poly, srid=21781) DBSession.add(ra) self.layer_ids.append(self.__class__._table_index) transaction.commit() return id
def _create_layer(self, public=False, none_area=False, attr_list=False, exclude_properties=False): """ This function is central for this test class. It creates a layer with two features, and associates a restriction area to it. """ import transaction import sqlahelper from sqlalchemy import func from sqlalchemy import Column, Table, types, ForeignKey from sqlalchemy.ext.declarative import declarative_base from geoalchemy import (GeometryDDL, GeometryExtensionColumn, Point, WKTSpatialElement) from c2cgeoportal.models import DBSession, Layer, RestrictionArea self.__class__._table_index = self.__class__._table_index + 1 id = self.__class__._table_index engine = sqlahelper.get_engine() if not self.metadata: self.metadata = declarative_base(bind=engine).metadata tablename = "table_%d" % id table = Table('%s_child' % tablename, self.metadata, Column('id', types.Integer, primary_key=True), Column('name', types.Unicode), schema='public') table.create() ins = table.insert().values(name=u'c1é') c1_id = engine.connect().execute(ins).inserted_primary_key[0] ins = table.insert().values(name=u'c2é') c2_id = engine.connect().execute(ins).inserted_primary_key[0] table = Table(tablename, self.metadata, Column('id', types.Integer, primary_key=True), Column('child_id', types.Integer, ForeignKey('public.%s_child.id' % tablename)), Column('name', types.Unicode), GeometryExtensionColumn('geom', Point(srid=21781)), schema='public') GeometryDDL(table) table.create() ins = table.insert().values(child_id=c1_id, name='foo', geom=func.ST_GeomFromText( 'POINT(5 45)', 21781)) engine.connect().execute(ins).inserted_primary_key[0] ins = table.insert().values(child_id=c2_id, name='bar', geom=func.ST_GeomFromText( 'POINT(6 46)', 21781)) engine.connect().execute(ins).inserted_primary_key[0] if attr_list: ins = table.insert().values(child_id=c2_id, name='aaa,bbb,foo', geom=func.ST_GeomFromText( 'POINT(6 46)', 21781)) engine.connect().execute(ins).inserted_primary_key[0] layer = Layer() layer.id = id layer.geoTable = tablename layer.public = public if exclude_properties: layer.excludeProperties = 'name' DBSession.add(layer) if not public: ra = RestrictionArea() ra.name = u'__test_ra' ra.layers = [layer] ra.roles = [self.role] ra.readwrite = True if not none_area: poly = 'POLYGON((4 44, 4 46, 6 46, 6 44, 4 44))' ra.area = WKTSpatialElement(poly, srid=21781) DBSession.add(ra) self.layer_ids.append(self.__class__._table_index) transaction.commit() return id
def test_layer(self): import httplib2 from c2cgeoportal.views.entry import Entry from c2cgeoportal.models import Layer, LayerGroup, Theme request = testing.DummyRequest() request.headers["Host"] = host request.static_url = lambda url: "/dummy/static/" + url request.route_url = lambda url: "/dummy/route/" + url request.registry.settings = {"project": "test_layer"} entry = Entry(request) self.assertEqual(entry._group(LayerGroup(), [], [], None), (None, [], False)) layer = Layer() layer.id = 20 layer.name = "test internal WMS" layer.metadataURL = "http://example.com/tiwms" layer.isChecked = True layer.layerType = "internal WMS" layer.imageType = "image/png" layer.style = "my-style" layer.kml = "tiwms.kml" layer.legend = True layer.legendRule = "rule" layer.legendImage = "legend:static/tiwms-legend.png" layer.minResolution = 10 layer.maxResolution = 1000 layer.disclaimer = "Camptocamp" layer.identifierAttributeField = "name" layer.geoTable = "tiwms" layer.public = True self.assertEqual( entry._layer(layer, [], None), ( { "id": 20, "name": "test internal WMS", "metadataURL": "http://example.com/tiwms", "isChecked": True, "icon": "/dummy/route/mapserverproxy?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetLegendGraphic&LAYER=test internal WMS&FORMAT=image/png&TRANSPARENT=TRUE&RULE=rule", "type": u"internal WMS", "imageType": "image/png", "style": "my-style", "kml": "/dummy/static/test_layer:static/tiwms.kml", "legend": True, "legendImage": "/dummy/static/legend:static/tiwms-legend.png", "minResolutionHint": 10, "maxResolutionHint": 1000, "disclaimer": "Camptocamp", "identifierAttribute": "name", "editable": True, "public": True, }, [], ), ) layer = Layer() layer.id = 20 layer.name = "test external WMS" layer.isChecked = False layer.icon = "tewms.png" layer.layerType = "external WMS" layer.url = "http://example.com" layer.imageType = "image/jpeg" layer.isSingleTile = True layer.legend = False layer.minResolution = 10 layer.maxResolution = 1000 layer.public = True self.assertEqual( entry._layer(layer, [], None), ( { "id": 20, "name": "test external WMS", "icon": "/dummy/static/test_layer:static/tewms.png", "isChecked": False, "type": u"external WMS", "url": "http://example.com", "imageType": "image/jpeg", "isSingleTile": True, "legend": False, "minResolutionHint": 10, "maxResolutionHint": 1000, "public": True, }, [], ), ) layer = Layer() layer.id = 20 layer.name = "test WMTS" layer.isChecked = False layer.layerType = "WMTS" layer.url = "http://example.com/WMTS-Capabilities.xml" layer.style = "wmts-style" layer.dimensions = '{"DATE": "1012"}' layer.matrixSet = "swissgrid" layer.wmsUrl = "http://example.com/" layer.wmsLayers = "test" layer.legend = False layer.minResolution = 10 layer.maxResolution = 1000 layer.public = True self.assertEqual( entry._layer(layer, [], None), ( { "id": 20, "name": "test WMTS", "isChecked": False, "type": "WMTS", "url": "http://example.com/WMTS-Capabilities.xml", "style": "wmts-style", "dimensions": {u"DATE": u"1012"}, "matrixSet": "swissgrid", "wmsUrl": "http://example.com/", "wmsLayers": "test", "legend": False, "minResolutionHint": 10, "maxResolutionHint": 1000, "public": True, }, [], ), ) layer = Layer() layer.id = 20 layer.name = "test WMTS" layer.isChecked = False layer.layerType = "WMTS" layer.url = "http://example.com/WMTS-Capabilities.xml" layer.wmsUrl = "http://example.com/" layer.legend = False layer.minResolution = 10 layer.maxResolution = 1000 layer.public = True self.assertEqual( entry._layer(layer, [], None), ( { "id": 20, "name": "test WMTS", "isChecked": False, "type": "WMTS", "url": "http://example.com/WMTS-Capabilities.xml", "wmsUrl": "http://example.com/", "wmsLayers": "test WMTS", "legend": False, "minResolutionHint": 10, "maxResolutionHint": 1000, "public": True, }, [], ), ) layer = Layer() layer.id = 20 layer.name = "test WMTS" layer.isChecked = False layer.layerType = "WMTS" layer.url = "http://example.com/WMTS-Capabilities.xml" layer.wmsLayers = "test" layer.legend = False layer.minResolution = 10 layer.maxResolution = 1000 layer.public = True self.assertEqual( entry._layer(layer, [], None), ( { "id": 20, "name": "test WMTS", "isChecked": False, "type": "WMTS", "url": "http://example.com/WMTS-Capabilities.xml", "wmsUrl": "/dummy/route/mapserverproxy", "wmsLayers": "test", "legend": False, "minResolutionHint": 10, "maxResolutionHint": 1000, "public": True, }, [], ), ) layer = Layer() layer.id = 20 layer.name = "test no 2D" layer.isChecked = False layer.layerType = "no 2D" layer.legend = False layer.metadataURL = "http://example.com/wmsfeatures.metadata" layer.public = True self.assertEqual( entry._layer(layer, [], None), ( { "id": 20, "name": u"test no 2D", "isChecked": False, "type": u"no 2D", "legend": False, "metadataURL": u"http://example.com/wmsfeatures.metadata", "public": True, }, [], ), ) curdir = os.path.dirname(os.path.abspath(__file__)) mapfile = os.path.join(curdir, "c2cgeoportal_test.map") mapfile = os.path.join(os.path.dirname(os.path.abspath(__file__)), "c2cgeoportal_test.map") params = (("map", mapfile), ("SERVICE", "WMS"), ("VERSION", "1.1.1"), ("REQUEST", "GetCapabilities")) mapserv = "%s?map=%s&" % (mapserv_url, mapfile) url = mapserv + "&".join(["=".join(p) for p in params]) http = httplib2.Http() h = {"Host": host} resp, xml = http.request(url, method="GET", headers=h) wms = WebMapService(None, xml=xml) wms_layers = list(wms.contents) layer = Layer() layer.id = 20 layer.name = "test_wmsfeaturesgroup" layer.layerType = "internal WMS" layer.imageType = "image/png" layer.isChecked = False layer.legend = False layer.public = True self.assertEqual( entry._layer(layer, wms_layers, wms), ( { "id": 20, "name": u"test_wmsfeaturesgroup", "type": u"internal WMS", "isChecked": False, "legend": False, "imageType": u"image/png", "minResolutionHint": 1.76, "maxResolutionHint": 8.8200000000000003, "public": True, "queryable": 0, "metadataUrls": [ {"url": "http://example.com/wmsfeatures.metadata", "type": "TC211", "format": "text/plain"} ], "childLayers": [ { "name": u"test_wmsfeatures", "minResolutionHint": 1.76, "maxResolutionHint": 8.8200000000000003, "queryable": 1, } ], }, [], ), ) group1 = LayerGroup() group1.name = "block" group2 = LayerGroup() group2.name = "node" group2.metadataURL = "http://example.com/group.metadata" layer = Layer() layer.id = 20 layer.name = "test layer in group" layer.isChecked = False layer.layerType = "internal WMS" layer.imageType = "image/png" layer.legend = False layer.public = True group1.children = [group2] group2.children = [layer] self.assertEqual( entry._group(group1, [layer], [], None), ( { "isExpanded": False, "isInternalWMS": True, "name": u"block", "isBaseLayer": False, "children": [ { "isExpanded": False, "isInternalWMS": True, "name": u"node", "isBaseLayer": False, "metadataURL": "http://example.com/group.metadata", "children": [ { "name": u"test layer in group", "id": 20, "isChecked": False, "type": u"internal WMS", "legend": False, "imageType": u"image/png", "public": True, } ], } ], }, [], False, ), ) group1 = LayerGroup() group1.isInternalWMS = True group2 = LayerGroup() group2.isInternalWMS = False group1.children = [group2] _, errors, stop = entry._group(group1, [], [], None) self.assertTrue(len(errors) > 0) self.assertFalse(stop) group1 = LayerGroup() group1.isInternalWMS = False group2 = LayerGroup() group2.isInternalWMS = True group1.children = [group2] _, errors, stop = entry._group(group1, [], [], None) self.assertTrue(len(errors) > 0) self.assertFalse(stop) group = LayerGroup() group.isInternalWMS = True layer = Layer() layer.layerType = "internal WMS" group.children = [layer] _, errors, stop = entry._group(group, [layer], [], None) self.assertEqual(len(errors), 0) self.assertFalse(stop) group = LayerGroup() group.isInternalWMS = True layer = Layer() layer.layerType = "external WMS" group.children = [layer] _, errors, stop = entry._group(group, [layer], [], None) self.assertTrue(len(errors) > 0) self.assertFalse(stop) group = LayerGroup() group.isInternalWMS = True layer = Layer() layer.layerType = "WMTS" group.children = [layer] _, errors, stop = entry._group(group, [layer], [], None) self.assertTrue(len(errors) > 0) self.assertFalse(stop) group = LayerGroup() group.isInternalWMS = True layer = Layer() layer.layerType = "no 2D" group.children = [layer] _, errors, stop = entry._group(group, [layer], [], None) self.assertTrue(len(errors) > 0) self.assertFalse(stop) group = LayerGroup() group.isInternalWMS = False layer = Layer() layer.layerType = "internal WMS" group.children = [layer] _, errors, stop = entry._group(group, [layer], [], None) self.assertTrue(len(errors) > 0) self.assertFalse(stop) group = LayerGroup() group.isInternalWMS = False layer = Layer() layer.layerType = "external WMS" group.children = [layer] _, errors, stop = entry._group(group, [layer], [], None) self.assertEqual(len(errors), 0) self.assertFalse(stop) group = LayerGroup() group.isInternalWMS = False layer = Layer() layer.layerType = "WMTS" group.children = [layer] _, errors, stop = entry._group(group, [layer], [], None) self.assertEqual(len(errors), 0) self.assertFalse(stop) group = LayerGroup() group.isInternalWMS = False layer = Layer() layer.layerType = "no 2D" group.children = [layer] _, errors, stop = entry._group(group, [layer], [], None) self.assertEqual(len(errors), 0) self.assertFalse(stop)