-
Notifications
You must be signed in to change notification settings - Fork 10
/
common.py
39 lines (28 loc) · 1.15 KB
/
common.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import os
from pywps import get_ElementMakerForVersion
from pywps.app.basic import get_xpath_ns
from pywps.tests import WpsClient, WpsTestResponse
TESTS_HOME = os.path.abspath(os.path.dirname(__file__))
VERSION = "1.0.0"
WPS, OWS = get_ElementMakerForVersion(VERSION)
xpath_ns = get_xpath_ns(VERSION)
def resource_file(filepath):
return os.path.join(TESTS_HOME, 'testdata', filepath)
class WpsTestClient(WpsClient):
def get(self, *args, **kwargs):
query = "?"
for key, value in kwargs.items():
query += "{0}={1}&".format(key, value)
return super(WpsTestClient, self).get(query)
def client_for(service):
return WpsTestClient(service, WpsTestResponse)
def get_output(doc):
"""Copied from pywps/tests/test_execute.py.
TODO: make this helper method public in pywps."""
output = {}
for output_el in xpath_ns(doc, '/wps:ExecuteResponse'
'/wps:ProcessOutputs/wps:Output'):
[identifier_el] = xpath_ns(output_el, './ows:Identifier')
[value_el] = xpath_ns(output_el, './wps:Data/wps:LiteralData')
output[identifier_el.text] = value_el.text
return output