def test_get_legendgraphic_no_legend_111(self): self.common_lg_req_111.params['layer'] = 'wms_no_legend' resp = self.app.get(self.common_lg_req_111) eq_(resp.content_type, 'application/vnd.ogc.se_xml') xml = resp.lxml assert 'wms_no_legend has no legend graphic' in xml.xpath('//ServiceException/text()')[0] assert validate_with_dtd(xml, 'wms/1.1.1/exception_1_1_1.dtd')
def test_get_legendgraphic_invalid_sld_version_111(self): req = str(self.common_lg_req_111).replace('sld_version=1.1.0', 'sld_version=1.0.0') resp = self.app.get(req) eq_(resp.content_type, 'application/vnd.ogc.se_xml') xml = resp.lxml assert 'invalid sld_version' in xml.xpath('//ServiceException/text()')[0] assert validate_with_dtd(xml, 'wms/1.1.1/exception_1_1_1.dtd')
def test_capabilities(self): req = str(self.common_cap_req) + '&tiled=true' resp = self.app.get(req) xml = resp.lxml assert validate_with_dtd(xml, dtd_name='wmsc/1.1.1/WMS_MS_Capabilities.dtd') eq_(len(xml.xpath('//TileSet')), 9)
def test_capabilities(self): req = str(self.common_cap_req) + '&tiled=true' resp = self.app.get(req) xml = resp.lxml assert validate_with_dtd(xml, dtd_name='wmsc/1.1.1/WMS_MS_Capabilities.dtd') srs = set([e.text for e in xml.xpath('//TileSet/SRS')]) eq_(srs, set(['EPSG:4326', 'EPSG:900913'])) eq_(len(xml.xpath('//TileSet')), 11)
def test_get_legendgraphic_no_legend_111(self, app): self.common_lg_req_111.params["layer"] = "wms_no_legend" resp = app.get(self.common_lg_req_111) assert resp.content_type == "application/vnd.ogc.se_xml" xml = resp.lxml assert ("wms_no_legend has no legend graphic" in xml.xpath("//ServiceException/text()")[0]) assert validate_with_dtd(xml, "wms/1.1.1/exception_1_1_1.dtd")
def test_capabilities(self, app): req = str(self.common_cap_req) + "&tiled=true" resp = app.get(req) xml = resp.lxml assert validate_with_dtd(xml, dtd_name="wmsc/1.1.1/WMS_MS_Capabilities.dtd") srs = set([e.text for e in xml.xpath("//TileSet/SRS")]) assert srs == set(["EPSG:4326", "EPSG:900913"]) assert len(xml.xpath("//TileSet")) == 11
def test_get_legendgraphic_invalid_sld_version_111(self, app): req = str(self.common_lg_req_111).replace("sld_version=1.1.0", "sld_version=1.0.0") resp = app.get(req) assert resp.content_type == "application/vnd.ogc.se_xml" xml = resp.lxml assert "invalid sld_version" in xml.xpath( "//ServiceException/text()")[0] assert validate_with_dtd(xml, "wms/1.1.1/exception_1_1_1.dtd")
def test_get_legendgraphic_missing_params_111(self, app): req = (str(self.common_lg_req_111).replace("sld_version", "invalid").replace( "format", "invalid")) resp = app.get(req) assert resp.content_type == "application/vnd.ogc.se_xml" xml = resp.lxml assert "missing parameters" in xml.xpath( "//ServiceException/text()")[0] assert validate_with_dtd(xml, "wms/1.1.1/exception_1_1_1.dtd")
def test_wms_capabilities(self): req = WMS111CapabilitiesRequest(url='/service?').copy_with_request_params(self.common_req) resp = self.app.get(req) eq_(resp.content_type, 'application/vnd.ogc.wms_xml') xml = resp.lxml eq_(xml.xpath('//GetMap//OnlineResource/@xlink:href', namespaces=dict(xlink="http://www.w3.org/1999/xlink"))[0], 'http://localhost/service?') layer_names = set(xml.xpath('//Layer/Layer/Name/text()')) expected_names = set(['direct', 'wms_cache', 'tms_cache']) eq_(layer_names, expected_names) assert validate_with_dtd(xml, dtd_name='wms/1.1.1/WMS_MS_Capabilities.dtd')
def test_wms_capabilities(self, app): req = WMS111CapabilitiesRequest( url="/service?").copy_with_request_params(self.common_req) resp = app.get(req) assert resp.content_type == "application/vnd.ogc.wms_xml" xml = resp.lxml assert (xml.xpath( "//GetMap//OnlineResource/@xlink:href", namespaces=dict(xlink="http://www.w3.org/1999/xlink"), )[0] == "http://localhost/service?") layer_names = set(xml.xpath("//Layer/Layer/Name/text()")) expected_names = set(["direct", "wms_cache", "tms_cache"]) assert layer_names == expected_names assert validate_with_dtd(xml, dtd_name="wms/1.1.1/WMS_MS_Capabilities.dtd")
def test_render(self): req = self.mock(WMSMapRequest) req_ex = RequestError("the exception message", request=req) ex_handler = WMS110ExceptionHandler() self.expect(req.exception_handler).result(ex_handler) self.replay() response = req_ex.render() assert response.content_type == "application/vnd.ogc.se_xml" expected_resp = """ <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE ServiceExceptionReport SYSTEM "http://schemas.opengis.net/wms/1.1.0/exception_1_1_0.dtd"> <ServiceExceptionReport version="1.1.0"> <ServiceException>the exception message</ServiceException> </ServiceExceptionReport> """ assert expected_resp.strip() == response.data assert validate_with_dtd(response.data, "wms/1.1.0/exception_1_1_0.dtd")
def test_render(self): req = self.mock(WMSMapRequest) req_ex = RequestError('the exception message', request=req) ex_handler = WMS110ExceptionHandler() self.expect(req.exception_handler).result(ex_handler) self.replay() response = req_ex.render() assert response.content_type == 'application/vnd.ogc.se_xml' expected_resp = b""" <?xml version="1.0"?> <!DOCTYPE ServiceExceptionReport SYSTEM "http://schemas.opengis.net/wms/1.1.0/exception_1_1_0.dtd"> <ServiceExceptionReport version="1.1.0"> <ServiceException>the exception message</ServiceException> </ServiceExceptionReport> """ assert expected_resp.strip() == response.data assert validate_with_dtd(response.data, 'wms/1.1.0/exception_1_1_0.dtd')