old_contents: import unittest
  import lxml.etree
  from pywps.app import Service, Process, WPSResponse, WPS, OWS, NAMESPACES
  from tests.common import client_for
  
  
  def create_ultimate_question():
      return Process(identifier='ultimate_question',
                     handler=lambda request: WPSResponse({'outvalue': '42'}))
  
  
  def get_output(doc):
      xpath_ns = lambda el, path: el.xpath(path, namespaces=NAMESPACES)
      output = {}
      for output_el in xpath_ns(doc, '/wps:ExecuteResponse/wps:ProcessOutputs'):
          [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
  
  
  def assert_response_success(resp):
      assert resp.status_code == 200
      assert resp.headers['Content-Type'] == 'text/xml'
      success = resp.xpath_text('/wps:ExecuteResponse'
                                '/wps:Status'
                                '/wps:ProcessSucceeded')
      assert success == "great success"
  
  
  class ExecuteTest(unittest.TestCase):
  
      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('?Request=Execute&identifier=ultimate_question')
          assert_response_success(resp)
          assert get_output(resp.xml) == {'outvalue': '42'}
  
      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 load_tests():
      loader = unittest.TestLoader()
      suite_list = [
          loader.loadTestsFromTestCase(ExecuteTest),
      ]
      return unittest.TestSuite(suite_list)
  
new_contents: import unittest
  import lxml.etree
  from pywps.app import Service, Process, WPSResponse, WPS, OWS, NAMESPACES
  from tests.common import client_for
  
  
  def create_ultimate_question():
      return Process(identifier='ultimate_question',
                     handler=lambda request: WPSResponse({'outvalue': '42'}))
  
  
  def get_output(doc):
      xpath_ns = lambda el, path: el.xpath(path, namespaces=NAMESPACES)
      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
  
  
  def assert_response_success(resp):
      assert resp.status_code == 200
      assert resp.headers['Content-Type'] == 'text/xml'
      success = resp.xpath_text('/wps:ExecuteResponse'
                                '/wps:Status'
                                '/wps:ProcessSucceeded')
      assert success == "great success"
  
  
  class ExecuteTest(unittest.TestCase):
  
      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('?Request=Execute&identifier=ultimate_question')
          assert_response_success(resp)
          assert get_output(resp.xml) == {'outvalue': '42'}
  
      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 load_tests():
      loader = unittest.TestLoader()
      suite_list = [
          loader.loadTestsFromTestCase(ExecuteTest),
      ]
      return unittest.TestSuite(suite_list)
  
subject: fix xpaths in parser of outputs