def test_post_two_args(self): request_doc = WPS.DescribeProcess(OWS.Identifier('hello'), OWS.Identifier('ping'), version='1.0.0') resp = self.client.post_xml(doc=request_doc) result = get_describe_result(resp) assert [pr.identifier for pr in result] == ['hello', 'ping']
def test_post_one_arg(self): request_doc = WPS.DescribeProcess( OWS.Identifier('hello'), version='1.0.0' ) resp = self.client.post_xml(doc=request_doc) assert [pr.identifier for pr in get_describe_result(resp)] == ['hello']
def _post_request_parser(self, tagname): """Factory function returing propper parsing function """ wpsrequest = self def parse_post_getcapabilities(doc): """Parse POST GetCapabilities request """ acceptedversions = xpath_ns( doc, '/wps:GetCapabilities/ows:AcceptVersions/ows:Version') acceptedversions = ','.join(map(lambda v: v.text, acceptedversions)) wpsrequest.check_accepted_versions(acceptedversions) def parse_post_describeprocess(doc): """Parse POST DescribeProcess request """ version = doc.attrib.get('version') wpsrequest.check_and_set_version(version) language = doc.attrib.get('language') wpsrequest.check_and_set_language(language) wpsrequest.operation = 'describeprocess' wpsrequest.identifiers = [ identifier_el.text for identifier_el in xpath_ns(doc, './ows:Identifier') ] def parse_post_execute(doc): """Parse POST Execute request """ version = doc.attrib.get('version') wpsrequest.check_and_set_version(version) language = doc.attrib.get('language') wpsrequest.check_and_set_language(language) wpsrequest.operation = 'execute' identifier = xpath_ns(doc, './ows:Identifier') if not identifier: raise MissingParameterValue('Process identifier not set', 'Identifier') wpsrequest.identifier = identifier[0].text wpsrequest.lineage = 'false' wpsrequest.store_execute = 'false' wpsrequest.status = 'false' wpsrequest.inputs = get_inputs_from_xml(doc) wpsrequest.outputs = get_output_from_xml(doc) wpsrequest.raw = False if xpath_ns(doc, '/wps:Execute/wps:ResponseForm/wps:RawDataOutput'): wpsrequest.raw = True # executeResponse XML will not be stored wpsrequest.store_execute = 'false' # check if response document tag has been set then retrieve response_document = xpath_ns( doc, './wps:ResponseForm/wps:ResponseDocument') if len(response_document) > 0: wpsrequest.lineage = response_document[0].attrib.get( 'lineage', 'false') wpsrequest.store_execute = response_document[0].attrib.get( 'storeExecuteResponse', 'false') wpsrequest.status = response_document[0].attrib.get( 'status', 'false') if tagname == WPS.GetCapabilities().tag: self.operation = 'getcapabilities' return parse_post_getcapabilities elif tagname == WPS.DescribeProcess().tag: self.operation = 'describeprocess' return parse_post_describeprocess elif tagname == WPS.Execute().tag: self.operation = 'execute' return parse_post_execute else: raise InvalidParameterValue('Unknown request %r' % tagname, 'request')
def test_post_request_zero_args(self): request_doc = WPS.DescribeProcess() resp = self.client.post_xml(doc=request_doc) assert resp.status_code == 400