def test_one_string(self): request_doc = WPS.Execute( OWS.Identifier('foo'), WPS.DataInputs( WPS.Input(OWS.Identifier('name'), WPS.Data(WPS.LiteralData('foo'))))) assert get_input_from_xml(request_doc).to_dict() == {'name': 'foo'}
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_complex_input(self): the_data = E.TheData("hello world") request_doc = WPS.Execute( OWS.Identifier('foo'), WPS.DataInputs( WPS.Input( OWS.Identifier('name'), WPS.Data(WPS.ComplexData(the_data, mimeType='text/foobar'))))) rv = get_input_from_xml(request_doc) assert rv['name'].mime_type == 'text/foobar' rv_doc = lxml.etree.parse(rv['name']).getroot() assert rv_doc.tag == 'TheData' assert rv_doc.text == "hello world"
def test_two_strings(self): request_doc = WPS.Execute( OWS.Identifier('foo'), WPS.DataInputs( WPS.Input(OWS.Identifier('name'), WPS.Data(WPS.LiteralData('foo'))), WPS.Input(OWS.Identifier('name'), WPS.Data(WPS.LiteralData('bar'))))) rv = get_input_from_xml(request_doc) assert rv.getlist('name') == ['foo', 'bar']
def test_post_two_args(self): request_doc = WPS.DescribeProcess(OWS.Identifier('hello'), OWS.Identifier('ping')) 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')) resp = self.client.post_xml(doc=request_doc) assert [pr.identifier for pr in get_describe_result(resp)] == ['hello']
def test_post_request_zero_args(self): request_doc = WPS.DescribeProcess() resp = self.client.post_xml(doc=request_doc) assert [pr.identifier for pr in get_describe_result(resp)] == []
def test_empty(self): request_doc = WPS.Execute(OWS.Identifier('foo')) assert get_input_from_xml(request_doc) == {}
def test_post_with_no_inputs(self): client = client_for(Service(processes=[create_ultimate_question()])) request_doc = WPS.Execute(OWS.Identifier('ultimate_question')) resp = client.post_xml(doc=request_doc) assert_response_success(resp) assert get_output(resp.xml) == {'outvalue': '42'}
def test_post_request(self): request_doc = WPS.GetCapabilities() resp = self.client.post_xml(doc=request_doc) self.check_capabilities_response(resp)
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