本文整理汇总了Python中pywps.tests.client_for函数的典型用法代码示例。如果您正苦于以下问题:Python client_for函数的具体用法?Python client_for怎么用?Python client_for使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了client_for函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_bbox
def test_bbox(self):
if not PY2:
self.skipTest('OWSlib not python 3 compatible')
client = client_for(Service(processes=[create_bbox_process()]))
request_doc = WPS.Execute(
OWS.Identifier('my_bbox_process'),
WPS.DataInputs(
WPS.Input(
OWS.Identifier('mybbox'),
WPS.Data(WPS.BoundingBoxData(
OWS.LowerCorner('15 50'),
OWS.UpperCorner('16 51'),
))
)
),
version='1.0.0'
)
resp = client.post_xml(doc=request_doc)
assert_response_success(resp)
[output] = xpath_ns(resp.xml, '/wps:ExecuteResponse'
'/wps:ProcessOutputs/wps:Output')
self.assertEqual('outbbox', xpath_ns(
output,
'./ows:Identifier')[0].text)
self.assertEqual('15 50', xpath_ns(
output,
'./wps:Data/ows:BoundingBox/ows:LowerCorner')[0].text)
示例2: compare_io
def compare_io(self, name, fn, fmt):
"""Start the dummy process, post the request and check the response matches the input data."""
# Note that `WPSRequest` calls `get_inputs_from_xml` which converts base64 input to bytes
# See `_get_rawvalue_value`
client = client_for(Service(processes=[create_fmt_process(name, fn, fmt)]))
data = get_data(fn, fmt.encoding)
wps = WPSExecution()
doc = wps.buildRequest('test-fmt',
inputs=[('complex', ComplexDataInput(data, mimeType=fmt.mime_type,
encoding=fmt.encoding))],
mode='sync')
resp = client.post_xml(doc=doc)
assert_response_success(resp)
wps.parseResponse(resp.xml)
out = wps.processOutputs[0].data[0]
if 'gml' in fmt.mime_type:
xml_orig = etree.tostring(etree.fromstring(data.encode('utf-8'))).decode('utf-8')
xml_out = etree.tostring(etree.fromstring(out.decode('utf-8'))).decode('utf-8')
# Not equal because the output includes additional namespaces compared to the origin.
# self.assertEqual(xml_out, xml_orig)
else:
self.assertEqual(out.strip(), data.strip())
示例3: test_wps_hello
def test_wps_hello():
client = client_for(Service(processes=[SayHello()]))
datainputs = "name=LovelySugarBird"
resp = client.get(
"?service=WPS&request=Execute&version=1.0.0&identifier=hello&datainputs={}".format(
datainputs))
assert_response_success(resp)
assert get_output(resp.xml) == {'output': "Hello LovelySugarBird"}
示例4: test_bad_service_type_with_get
def test_bad_service_type_with_get(self):
client = client_for(Service())
resp = client.get('?service=foo')
exception = resp.xpath('/ows:ExceptionReport'
'/ows:Exception')
assert resp.status_code == 400
assert exception[0].attrib['exceptionCode'] == 'InvalidParameterValue'
示例5: test_post_with_no_inputs
def test_post_with_no_inputs(self):
client = client_for(Service(processes=[create_ultimate_question()]))
request_doc = WPS.Execute(
OWS.Identifier('ultimate_question'),
version='1.0.0'
)
resp = client.post_xml(doc=request_doc)
assert_response_success(resp)
assert get_output(resp.xml) == {'outvalue': '42'}
示例6: test_epsg_based_location
def test_epsg_based_location(self):
"""Test whether the EPSG of a mapset corresponds the specified one."""
my_process = grass_epsg_based_location()
client = client_for(Service(processes=[my_process]))
request_doc = WPS.Execute(
OWS.Identifier('my_epsg_based_location'),
version='1.0.0'
)
resp = client.post_xml(doc=request_doc)
assert_response_success(resp)
示例7: setUp
def setUp(self):
def hello(request):
pass
def ping(request):
pass
processes = [
Process(hello, 'hello', 'Process Hello', metadata=[
Metadata('hello metadata', 'http://example.org/hello',
role='http://www.opengis.net/spec/wps/2.0/def/process/description/documentation')]),
Process(ping, 'ping', 'Process Ping', metadata=[Metadata('ping metadata', 'http://example.org/ping')]),
]
self.client = client_for(Service(processes=processes))
示例8: test_wcs
def test_wcs(self):
try:
sys.path.append("/usr/lib/grass64/etc/python/")
import grass.script as grass
except:
self.skipTest("GRASS lib not found")
client = client_for(Service(processes=[create_sum_one()]))
request_doc = WPS.Execute(
OWS.Identifier("sum_one"),
WPS.DataInputs(WPS.Input(OWS.Identifier("input"), WPS.Reference(href=wcsResource, mimeType="image/tiff"))),
WPS.ProcessOutputs(WPS.Output(OWS.Identifier("output"))),
version="1.0.0",
)
resp = client.post_xml(doc=request_doc)
assert_response_success(resp)
示例9: test_post_with_string_input
def test_post_with_string_input(self):
client = client_for(Service(processes=[create_greeter()]))
request_doc = WPS.Execute(
OWS.Identifier('greeter'),
WPS.DataInputs(
WPS.Input(
OWS.Identifier('name'),
WPS.Data(WPS.LiteralData('foo'))
)
),
version='1.0.0'
)
resp = client.post_xml(doc=request_doc)
assert_response_success(resp)
assert get_output(resp.xml) == {'message': "Hello foo!"}
示例10: test_output_response_dataType
def test_output_response_dataType(self):
client = client_for(Service(processes=[create_greeter()]))
request_doc = WPS.Execute(
OWS.Identifier('greeter'),
WPS.DataInputs(
WPS.Input(
OWS.Identifier('name'),
WPS.Data(WPS.LiteralData('foo'))
)
),
version='1.0.0'
)
resp = client.post_xml(doc=request_doc)
el = next(resp.xml.iter('{http://www.opengis.net/wps/1.0.0}LiteralData'))
assert el.attrib['dataType'] == 'string'
示例11: test_assync
def test_assync(self):
client = client_for(Service(processes=[create_sleep()]))
request_doc = WPS.Execute(
OWS.Identifier('sleep'),
WPS.DataInputs(
WPS.Input(
OWS.Identifier('seconds'),
WPS.Data(
WPS.LiteralData(
"120"
)
)
)
),
version="1.0.0"
)
resp = client.post_xml(doc=request_doc)
assert_response_accepted(resp)
示例12: test_file_based_location
def test_file_based_location(self):
"""Test whether the datum of a mapset corresponds the file one."""
my_process = grass_file_based_location()
client = client_for(Service(processes=[my_process]))
href = 'http://demo.mapserver.org/cgi-bin/wfs?service=WFS&' \
'version=1.1.0&request=GetFeature&typename=continents&' \
'maxfeatures=1'
request_doc = WPS.Execute(
OWS.Identifier('my_file_based_location'),
WPS.DataInputs(
WPS.Input(
OWS.Identifier('input1'),
WPS.Reference(
{'{http://www.w3.org/1999/xlink}href': href}))),
version='1.0.0')
resp = client.post_xml(doc=request_doc)
assert_response_success(resp)
示例13: test_wfs
def test_wfs(self):
client = client_for(Service(processes=[create_feature()]))
request_doc = WPS.Execute(
OWS.Identifier('feature'),
WPS.DataInputs(
WPS.Input(
OWS.Identifier('input'),
WPS.Reference(
{'{http://www.w3.org/1999/xlink}href': wfsResource},
mimeType=FORMATS.GML.mime_type,
encoding='',
schema=''))),
WPS.ProcessOutputs(
WPS.Output(
OWS.Identifier('output'))),
version='1.0.0'
)
resp = client.post_xml(doc=request_doc)
assert_response_success(resp)
示例14: test_wps_subset_bbox
def test_wps_subset_bbox():
client = client_for(Service(processes=[SubsetBboxProcess()], cfgfiles=CFG_FILE))
datainputs = "[email protected]:href={fn};" \
"lat0={lat0};" \
"lon0={lon0};" \
"lat1={lat1};" \
"lon1={lon1};" \
.format(fn=TESTDATA['cmip5_tasmax_2006_nc'], lat0=2., lon0=3., lat1=4., lon1=5.)
resp = client.get(
"?service=WPS&request=Execute&version=1.0.0&identifier=subset_bbox&datainputs={}".format(
datainputs))
print(resp.get_data())
assert_response_success(resp)
out = get_output(resp.xml)
ds = nc.Dataset(out['output'][7:])
check_bnds(ds['lat_bnds'], 2, 4)
check_bnds(ds['lon_bnds'], 3, 5)
assert 'metalink' in out
示例15: test_bad_request_type_with_post
def test_bad_request_type_with_post(self):
client = client_for(Service())
request_doc = WPS.Foo()
resp = client.post_xml('', doc=request_doc)
assert resp.status_code == 400