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/Output') self.assertEqual('outbbox', xpath_ns(output, './ows:Identifier')[0].text) self.assertEqual('15 50', xpath_ns(output, './ows:BoundingBox/ows:LowerCorner')[0].text)
def describe_process(self, process): client = client_for(Service(processes=[process])) resp = client.get( '?service=wps&Request=DescribeProcess&identifier=%s' % process.identifier) [result] = get_describe_result(resp) return result
def setUp(self): db.create_all() def hello(request): pass def ping(request): pass processes = [Process(hello, 'hello', 'Process Hello'), Process(ping, 'ping', 'Process Ping')] self.client = client_for(Service(processes=processes))
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'}
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/Output') self.assertEqual('outbbox', xpath_ns(output, './ows:Identifier')[0].text) self.assertEqual( '15 50', xpath_ns(output, './ows:BoundingBox/ows:LowerCorner')[0].text)
def setUp(self): def pr1(): pass def pr2(): pass db.create_all() self.client = client_for(Service(processes=[Process(pr1, 'pr1', 'Process 1'), Process(pr2, 'pr2', 'Process 2')]))
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'), 120))) resp = client.post_xml(doc=request_doc) assert_response_accepted(resp)
def test_get_with_no_inputs(self): client = client_for(Service(processes=[create_ultimate_question()])) resp = client.get( '?service=wps&version=1.0.0&Request=Execute&identifier=ultimate_question' ) assert_response_success(resp) assert get_output(resp.xml) == {'outvalue': '42'}
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'
def setUp(self): def hello(request): pass def ping(request): pass processes = [Process(hello, "hello", "Process Hello"), Process(ping, "ping", "Process Ping")] self.client = client_for(Service(processes=processes))
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'}
def setUp(self): def pr1(): pass def pr2(): pass self.client = client_for( Service(processes=[Process(pr1), Process(pr2)]))
def setUp(self): def hello(request): pass def ping(request): pass processes = [Process(hello), Process(ping)] self.client = client_for(Service(processes=processes))
def test_wps_plot_name_simple_custom_egypt(custom_egypt_outputs): run_id = custom_egypt_outputs.split('/')[-1] client = client_for(Service(processes=[PlotNAME()])) datainputs = f'filelocation={run_id}' resp = client.get(service='wps', request='execute', version='1.0.0', identifier='plot_name', datainputs=datainputs) assert_response_success(resp)
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!"}
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)
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'))))) resp = client.post_xml(doc=request_doc) assert_response_success(resp) assert get_output(resp.xml) == {'message': "Hello foo!"}
def test_wps_plot_name_allsum_cape_verde(cape_verde_outputs): run_id = cape_verde_outputs.split('/')[-1] time_summary = 'all' client = client_for(Service(processes=[PlotNAME()])) datainputs = f'filelocation={run_id};summarise={time_summary}' resp = client.get(service='wps', request='execute', version='1.0.0', identifier='plot_name', datainputs=datainputs) assert_response_success(resp)
def test_wps_plot_name_noplotcreated_cape_verde(cape_verde_outputs): run_id = cape_verde_outputs.split('/')[-1] timestamp = get_invalid_date('cape_verde') client = client_for(Service(processes=[PlotNAME()])) datainputs = f'filelocation={run_id};timestamp={timestamp}' resp = client.get(service='wps', request='execute', version='1.0.0', identifier='plot_name', datainputs=datainputs) assert_response_success(resp)
def setUp(self): def hello(request): pass def ping(request): pass processes = [ Process(hello, 'hello', 'Process Hello'), Process(ping, 'ping', 'Process Ping') ] self.client = client_for(Service(processes=processes))
def setUp(self): def pr1(): pass def pr2(): pass self.client = client_for( Service(processes=[ Process(pr1, 'pr1', 'Process 1'), Process(pr2, 'pr2', 'Process 2') ]))
def test_wcs(self): 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/img'))), WPS.ProcessOutputs( WPS.Output( OWS.Identifier('output')))) resp = client.post_xml(doc=request_doc) assert_response_success(resp)
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')) ) ) ) resp = client.post_xml(doc=request_doc) assert_response_success(resp) assert get_output(resp.xml) == {'message': "Hello foo!"}
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/img"))), WPS.ProcessOutputs(WPS.Output(OWS.Identifier("output"))), version="1.0.0", ) resp = client.post_xml(doc=request_doc) assert_response_success(resp)
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/img'))), WPS.ProcessOutputs(WPS.Output(OWS.Identifier('output'))), version='1.0.0') resp = client.post_xml(doc=request_doc) assert_response_success(resp)
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='text/xml'))), WPS.ProcessOutputs( WPS.Output( OWS.Identifier('output'))), version='1.0.0' ) resp = client.post_xml(doc=request_doc) assert_response_success(resp)
def bt_tower_outputs(): client = client_for(Service(processes=[RunNAMEPreset()])) datainputs = ('title={title};' 'runBackwards={runBackwards};' 'time={time};' 'elevationOut={elevationOut};' 'resolution={resolution};' 'startdate={startdate};' 'enddate={enddate}').format(**bt_tower_inputs) resp = client.get(service='wps', request='execute', version='1.0.0', identifier='run_name_preset', datainputs=datainputs) yield get_outputs_path(resp.xml)
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)
def test_wps_run_name_preset_inputs_success(inputs): client = client_for(Service(processes=[RunNAMEPreset()])) datainputs = ('title={title};' 'runBackwards={runBackwards};' 'time={time};' 'elevationOut={elevationOut};' 'resolution={resolution};' 'startdate={startdate};' 'enddate={enddate}').format(**inputs) resp = client.get(service='wps', request='execute', version='1.0.0', identifier='run_name_preset', datainputs=datainputs) assert_response_success(resp)
def test_wps_subset_countries(): client = client_for( Service(processes=[SubsetcountryProcess()], cfgfiles=CFG_FILE)) datainputs = datainputs_fmt.format( TESTDATA['cmip5_tasmax_2006_nc'], 'CAN', "True") resp = client.get( service='wps', request='execute', version='1.0.0', identifier='subset_countries', datainputs=datainputs) assert_response_success(resp) # Check output file size is smaller than input. out = get_output(resp.xml) assert 'output' in out.keys()
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/Output") self.assertEqual("outbbox", xpath_ns(output, "./ows:Identifier")[0].text) self.assertEqual("15 50", xpath_ns(output, "./ows:BoundingBox/ows:LowerCorner")[0].text)
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)
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) from lxml import etree assert_response_success(resp)
def custom_egypt_outputs(): client = client_for(Service(processes=[RunNAME()])) datainputs = ('title={title};' 'longitude={longitude};' 'latitude={latitude};' 'runBackwards={runBackwards};' 'time={time};' 'elevationOut={elevationOut};' 'resolution={resolution};' 'startdate={startdate};' 'enddate={enddate};' 'min_lon={min_lon};' 'max_lon={max_lon};' 'min_lat={min_lat};' 'max_lat={max_lat};' 'timestamp={timestamp}').format(**custom_egypt_inputs) resp = client.get(service='wps', request='execute', version='1.0.0', identifier='run_name', datainputs=datainputs) yield get_outputs_path(resp.xml)
def test_bad_request_type_with_get(self): client = client_for(Service()) resp = client.get('?Request=foo') assert resp.status_code == 400
def test_missing_process_error(self): client = client_for(Service(processes=[create_ultimate_question()])) resp = client.get('?Request=Execute&identifier=foo') assert resp.status_code == 400
def test_get_with_no_inputs(self): client = client_for(Service(processes=[create_ultimate_question()])) resp = client.get("?service=wps&version=1.0.0&Request=Execute&identifier=ultimate_question") assert_response_success(resp) assert get_output(resp.xml) == {"outvalue": "42"}
def test_bad_http_verb(self): client = client_for(Service()) resp = client.put('') assert resp.status_code == 405 # method not allowed
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
def setUp(self): def pr1(): pass def pr2(): pass self.client = client_for(Service(processes=[Process(pr1), Process(pr2)]))
def test_get_with_no_inputs(self): client = client_for(Service(processes=[create_ultimate_question()])) resp = client.get('?Request=Execute&identifier=ultimate_question') assert_response_success(resp) assert get_output(resp.xml) == {'outvalue': '42'}
def describe_process(self, process): client = client_for(Service(processes=[process])) resp = client.get("?service=wps&version=1.0.0&Request=DescribeProcess&identifier=%s" % process.identifier) [result] = get_describe_result(resp) return result
def setUp(self): self.client = client_for(Service(processes=[]))