mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-05 00:09:32 -04:00
Add alternative reference json files for getlegendgraphic tests
This commit is contained in:
parent
3dea6deced
commit
c2f8e7fb66
@ -62,32 +62,49 @@ class TestQgsServerWMSTestBase(QgsServerTestBase):
|
||||
def wms_request_compare(self, request, extra=None, reference_file=None, project='test_project.qgs', version='1.3.0', ignoreExtent=False, normalizeJson=False, raw=False):
|
||||
response_header, response_body, query_string = self.wms_request(request, extra, project, version)
|
||||
response = response_header + response_body
|
||||
reference_path = os.path.join(self.testdata_path, (request.lower() if not reference_file else reference_file) + '.txt')
|
||||
self.store_reference(reference_path, response)
|
||||
f = open(reference_path, 'rb')
|
||||
expected = f.read()
|
||||
|
||||
def _n(r):
|
||||
lines = r.split(b'\n')
|
||||
b = lines[2:]
|
||||
h = lines[:2]
|
||||
if not isinstance(reference_file, (list, tuple)):
|
||||
reference_files = [reference_file]
|
||||
else:
|
||||
reference_files = reference_file
|
||||
|
||||
last_exception = None
|
||||
found_match = False
|
||||
for reference_file in reference_files:
|
||||
reference_path = os.path.join(self.testdata_path, (request.lower() if not reference_file else reference_file) + '.txt')
|
||||
self.store_reference(reference_path, response)
|
||||
f = open(reference_path, 'rb')
|
||||
expected = f.read()
|
||||
|
||||
def _n(r):
|
||||
lines = r.split(b'\n')
|
||||
b = lines[2:]
|
||||
h = lines[:2]
|
||||
try:
|
||||
return b'\n'.join(h) + json.dumps(json.loads(b'\n'.join(b))).encode('utf8')
|
||||
except:
|
||||
return r
|
||||
|
||||
response = _n(response)
|
||||
expected = _n(expected)
|
||||
|
||||
f.close()
|
||||
response = re.sub(RE_STRIP_UNCHECKABLE, b'*****', response)
|
||||
expected = re.sub(RE_STRIP_UNCHECKABLE, b'*****', expected)
|
||||
if ignoreExtent:
|
||||
response = re.sub(RE_STRIP_EXTENTS, b'*****', response)
|
||||
expected = re.sub(RE_STRIP_EXTENTS, b'*****', expected)
|
||||
|
||||
msg = "request %s failed.\nQuery: %s\nExpected file: %s\nResponse:\n%s" % (query_string, request, reference_path, response.decode('utf-8'))
|
||||
|
||||
try:
|
||||
return b'\n'.join(h) + json.dumps(json.loads(b'\n'.join(b))).encode('utf8')
|
||||
except:
|
||||
return r
|
||||
self.assertXMLEqual(response, expected, msg=msg, raw=raw)
|
||||
found_match = True
|
||||
except AssertionError as e:
|
||||
last_exception = e
|
||||
|
||||
response = _n(response)
|
||||
expected = _n(expected)
|
||||
|
||||
f.close()
|
||||
response = re.sub(RE_STRIP_UNCHECKABLE, b'*****', response)
|
||||
expected = re.sub(RE_STRIP_UNCHECKABLE, b'*****', expected)
|
||||
if ignoreExtent:
|
||||
response = re.sub(RE_STRIP_EXTENTS, b'*****', response)
|
||||
expected = re.sub(RE_STRIP_EXTENTS, b'*****', expected)
|
||||
|
||||
msg = "request %s failed.\nQuery: %s\nExpected file: %s\nResponse:\n%s" % (query_string, request, reference_path, response.decode('utf-8'))
|
||||
self.assertXMLEqual(response, expected, msg=msg, raw=raw)
|
||||
if not found_match:
|
||||
raise last_exception
|
||||
|
||||
|
||||
class TestQgsServerWMS(TestQgsServerWMSTestBase):
|
||||
|
@ -1007,19 +1007,19 @@ class TestQgsServerWMSGetLegendGraphic(TestQgsServerWMSTestBase):
|
||||
self.wms_request_compare("GetLegendGraphic",
|
||||
"&LAYERS=testlayer%20%C3%A8%C3%A9"
|
||||
"&FORMAT=application/json",
|
||||
"wms_getlegendgraphic_json")
|
||||
["wms_getlegendgraphic_json", "wms_getlegendgraphic_json2"])
|
||||
|
||||
def test_wms_GetLegendGraphic_JSON_multiple_layers(self):
|
||||
self.wms_request_compare("GetLegendGraphic",
|
||||
"&LAYERS=testlayer%20%C3%A8%C3%A9,testlayer3"
|
||||
"&FORMAT=application/json",
|
||||
"wms_getlegendgraphic_json_multiple_layers")
|
||||
["wms_getlegendgraphic_json_multiple_layers", "wms_getlegendgraphic_json_multiple_layers2"])
|
||||
|
||||
def test_wms_GetLegendGraphic_JSON_multiple_symbol(self):
|
||||
self.wms_request_compare("GetLegendGraphic",
|
||||
"&LAYERS=cdb_lines"
|
||||
"&FORMAT=application/json",
|
||||
"wms_getlegendgraphic_json_multiple_symbol",
|
||||
["wms_getlegendgraphic_json_multiple_symbol", "wms_getlegendgraphic_json_multiple_symbol2"],
|
||||
'test_project_wms_grouped_layers.qgs')
|
||||
|
||||
def testJsonSymbolMaxMinScale(self):
|
||||
|
@ -4,7 +4,7 @@ Content-Type: application/json
|
||||
{
|
||||
"nodes":[
|
||||
{
|
||||
"icon":"iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAP0lEQVQ4jWNgGAV0A4wE5P8Tqx6fQf/TljijCMyK2YtTDy6DMAwhZBgTHheRBIaOQYzQsCAakBr9xOgZBbQGAKb+C8EdAkkoAAAAAElFTkSuQmCC",
|
||||
"icon":"iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAAP0lEQVQ4jWNgGAV0A4wE5P8Tqx6fQf/TljijCMyK2YtTDy6DMAwhZBgTHheRBIaOQYzQsCAakBr9xOgZBbQGAKb+C8EdAkkoAAAAAElFTkSuQmCC",
|
||||
"title":"A test vector layer",
|
||||
"type":"layer"
|
||||
}
|
||||
|
13
tests/testdata/qgis_server/wms_getlegendgraphic_json2.txt
vendored
Normal file
13
tests/testdata/qgis_server/wms_getlegendgraphic_json2.txt
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
*****
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"nodes":[
|
||||
{
|
||||
"icon":"iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAP0lEQVQ4jWNgGAV0A4wE5P8Tqx6fQf/TljijCMyK2YtTDy6DMAwhZBgTHheRBIaOQYzQsCAakBr9xOgZBbQGAKb+C8EdAkkoAAAAAElFTkSuQmCC",
|
||||
"title":"A test vector layer",
|
||||
"type":"layer"
|
||||
}
|
||||
],
|
||||
"title":""
|
||||
}
|
@ -4,12 +4,12 @@ Content-Type: application/json
|
||||
{
|
||||
"nodes":[
|
||||
{
|
||||
"icon":"iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAU0lEQVQ4jWNgGAV0A4z4JJWVlf8j8+/evYtTPQs+Q474qaKI2Wxi+I/LMKyC2AxBGHYbq8uYcLmIVDBEDLp79y6jzabbJBlEUvTDLCHJhlFAfQAA+w0alQ045JsAAAAASUVORK5CYII=",
|
||||
"icon":"iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAAU0lEQVQ4jWNgGAV0A4z4JJWVlf8j8+/evYtTPQs+Q474qaKI2Wxi+I/LMKyC2AxBGHYbq8uYcLmIVDBEDLp79y6jzabbJBlEUvTDLCHJhlFAfQAA+w0alQ045JsAAAAASUVORK5CYII=",
|
||||
"title":"testlayer3",
|
||||
"type":"layer"
|
||||
},
|
||||
{
|
||||
"icon":"iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAP0lEQVQ4jWNgGAV0A4wE5P8Tqx6fQf/TljijCMyK2YtTDy6DMAwhZBgTHheRBIaOQYzQsCAakBr9xOgZBbQGAKb+C8EdAkkoAAAAAElFTkSuQmCC",
|
||||
"icon":"iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAAP0lEQVQ4jWNgGAV0A4wE5P8Tqx6fQf/TljijCMyK2YtTDy6DMAwhZBgTHheRBIaOQYzQsCAakBr9xOgZBbQGAKb+C8EdAkkoAAAAAElFTkSuQmCC",
|
||||
"title":"A test vector layer",
|
||||
"type":"layer"
|
||||
}
|
||||
|
18
tests/testdata/qgis_server/wms_getlegendgraphic_json_multiple_layers2.txt
vendored
Normal file
18
tests/testdata/qgis_server/wms_getlegendgraphic_json_multiple_layers2.txt
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
*****
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"nodes":[
|
||||
{
|
||||
"icon":"iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAU0lEQVQ4jWNgGAV0A4z4JJWVlf8j8+/evYtTPQs+Q474qaKI2Wxi+I/LMKyC2AxBGHYbq8uYcLmIVDBEDLp79y6jzabbJBlEUvTDLCHJhlFAfQAA+w0alQ045JsAAAAASUVORK5CYII=",
|
||||
"title":"testlayer3",
|
||||
"type":"layer"
|
||||
},
|
||||
{
|
||||
"icon":"iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAP0lEQVQ4jWNgGAV0A4wE5P8Tqx6fQf/TljijCMyK2YtTDy6DMAwhZBgTHheRBIaOQYzQsCAakBr9xOgZBbQGAKb+C8EdAkkoAAAAAElFTkSuQmCC",
|
||||
"title":"A test vector layer",
|
||||
"type":"layer"
|
||||
}
|
||||
],
|
||||
"title":""
|
||||
}
|
@ -6,11 +6,11 @@ Content-Type: application/json
|
||||
{
|
||||
"symbols": [
|
||||
{
|
||||
"icon": "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAKUlEQVQ4jWP0c/v/n4ESQIkBfm7//zNRZDsDA8OoAaMGjBoAAYyUZmcAMb0KZdjI3VIAAAAASUVORK5CYII=",
|
||||
"icon": "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAAKUlEQVQ4jWP0c/v/n4ESQIkBfm7//zNRZDsDA8OoAaMGjBoAAYyUZmcAMb0KZdjI3VIAAAAASUVORK5CYII=",
|
||||
"title": "Ortsteil"
|
||||
},
|
||||
{
|
||||
"icon": "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAKklEQVQ4jWOcOeX/fwZKACUGzJzy/z8TRbYzMDCMGjBqwKgBEMBIaXYGACyFDMn+2JVEAAAAAElFTkSuQmCC",
|
||||
"icon": "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAAKklEQVQ4jWOcOeX/fwZKACUGzJzy/z8TRbYzMDCMGjBqwKgBEMBIaXYGACyFDMn+2JVEAAAAAElFTkSuQmCC",
|
||||
"title": "Stadtteil"
|
||||
}
|
||||
],
|
||||
|
22
tests/testdata/qgis_server/wms_getlegendgraphic_json_multiple_symbol2.txt
vendored
Normal file
22
tests/testdata/qgis_server/wms_getlegendgraphic_json_multiple_symbol2.txt
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
*****
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"nodes": [
|
||||
{
|
||||
"symbols": [
|
||||
{
|
||||
"icon": "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAKUlEQVQ4jWP0c/v/n4ESQIkBfm7//zNRZDsDA8OoAaMGjBoAAYyUZmcAMb0KZdjI3VIAAAAASUVORK5CYII=",
|
||||
"title": "Ortsteil"
|
||||
},
|
||||
{
|
||||
"icon": "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAKklEQVQ4jWOcOeX/fwZKACUGzJzy/z8TRbYzMDCMGjBqwKgBEMBIaXYGACyFDMn+2JVEAAAAAElFTkSuQmCC",
|
||||
"title": "Stadtteil"
|
||||
}
|
||||
],
|
||||
"title": "cdb_lines",
|
||||
"type": "layer"
|
||||
}
|
||||
],
|
||||
"title": ""
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user