[Pywps-commits] r1181 - trunk/tests

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Aug 1 12:16:32 CEST 2011


Author: jesus
Date: 2011-08-01 12:16:31 +0200 (Mon, 01 Aug 2011)
New Revision: 1181

Modified:
   trunk/tests/perform_requests.py
Log:
getCapabilities and describeProcess for POST; describeProcess=all

Modified: trunk/tests/perform_requests.py
===================================================================
--- trunk/tests/perform_requests.py	2011-08-01 09:18:01 UTC (rev 1180)
+++ trunk/tests/perform_requests.py	2011-08-01 10:16:31 UTC (rev 1181)
@@ -2,7 +2,8 @@
 import sys
 
 pywpsPath = os.path.abspath(os.path.join(os.path.split(os.path.abspath(__file__))[0],".."))
-sys.path.append(pywpsPath)
+#sys.path.append(pywpsPath)
+sys.path.insert(0,pywpsPath)
 import pywps
 import pywps.Process
 import unittest
@@ -25,6 +26,7 @@
     inputs = None
     getcapabilitiesrequest = "service=wps&request=getcapabilities"
     getdescribeprocessrequest = "service=wps&request=describeprocess&version=1.0.0&identifier=dummyprocess"
+    getdescribeprocessrequestall = "service=wps&request=describeprocess&version=1.0.0&identifier=all"
     getexecuterequest = "service=wps&request=execute&version=1.0.0&identifier=dummyprocess&datainputs=[input1=20;input2=10]"
     #wfsurl = "http://www2.dmsolutions.ca/cgi-bin/mswfs_gmap?version=1.0.0&request=getfeature&service=wfs&typename=park"
     wfsurl = "http://rsg.pml.ac.uk/geoserver2/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=rsg:areas_pw&maxFeatures=1"
@@ -58,45 +60,92 @@
     def testT01PerformGetCapabilities(self):
         """Test if GetCapabilities request returns Capabilities document"""
         self._setFromEnv()
-        mypywps = pywps.Pywps(pywps.METHOD_GET)
-        inputs = mypywps.parseRequest(self.getcapabilitiesrequest)
-        mypywps.performRequest(inputs)
-        xmldom = minidom.parseString(mypywps.response)
+        getpywps = pywps.Pywps(pywps.METHOD_GET)
+        postpywps = pywps.Pywps(pywps.METHOD_POST)
+        
+        getCapabilitiesRequestFile = open(os.path.join(pywpsPath,"tests","requests","wps_getcapabilities_request.xml"))
+        postinputs = postpywps.parseRequest(getCapabilitiesRequestFile)
+        postpywps.performRequest(postinputs)
+        xmldom = minidom.parseString(postpywps.response)
         self.assertEquals(xmldom.firstChild.nodeName, "wps:Capabilities")
+        
+        inputs = getpywps.parseRequest(self.getcapabilitiesrequest)
+        getpywps.performRequest(inputs)
+        xmldom = minidom.parseString(getpywps.response)
+        self.assertEquals(xmldom.firstChild.nodeName, "wps:Capabilities")
 
 
+
     def testT02ProcessesLengthGetCapabilities(self):
         """Test, if any processes are listed in the Capabilities document
         """
         self._setFromEnv()
-        mypywps = pywps.Pywps(pywps.METHOD_GET)
-        inputs = mypywps.parseRequest(self.getcapabilitiesrequest)
-        mypywps.performRequest(inputs)
-        xmldom = minidom.parseString(mypywps.response)
+        getpywps = pywps.Pywps(pywps.METHOD_GET)
+        inputs = getpywps.parseRequest(self.getcapabilitiesrequest)
+        getpywps.performRequest(inputs)
+        xmldom = minidom.parseString(getpywps.response)
         self.assertTrue(len(xmldom.getElementsByTagNameNS(self.wpsns,"Process"))>0)
+        
+        postpywps = pywps.Pywps(pywps.METHOD_POST)
+        getCapabilitiesRequestFile = open(os.path.join(pywpsPath,"tests","requests","wps_getcapabilities_request.xml"))
+        postinputs = postpywps.parseRequest(getCapabilitiesRequestFile)
+        postpywps.performRequest(postinputs)
+        xmldom = minidom.parseString(postpywps.response)
+        self.assertTrue(len(xmldom.getElementsByTagNameNS(self.wpsns,"Process"))>0)
+        
     
 
     def testT03PerformDescribeProcess(self):
         """Test if DescribeProcess request returns ProcessDescription document"""
         self._setFromEnv()
-        mypywps = pywps.Pywps(pywps.METHOD_GET)
-        mypywps.parseRequest(self.getdescribeprocessrequest)
-        mypywps.performRequest()
-        xmldom = minidom.parseString(mypywps.response)
+        getpywps = pywps.Pywps(pywps.METHOD_GET)
+        getpywps.parseRequest(self.getdescribeprocessrequest)
+        getpywps.performRequest()
+        xmldom = minidom.parseString(getpywps.response)
         self.assertEquals(xmldom.firstChild.nodeName, "wps:ProcessDescriptions")
-    
+        
+        postpywps = pywps.Pywps(pywps.METHOD_POST)
+        describeRequestFile = open(os.path.join(pywpsPath,"tests","requests","wps_describeprocess_request_dummyprocess.xml"))
+        postinputs = postpywps.parseRequest(describeRequestFile)
+        postpywps.performRequest(postinputs)
+        xmldom = minidom.parseString(postpywps.response)
+        self.assertEquals(xmldom.firstChild.nodeName, "wps:ProcessDescriptions")
 
     def testT04ProcessesLengthDescribeProcess(self):
         """Test, if any processes are listed in the DescribeProcess document
         """
         self._setFromEnv()
-        mypywps = pywps.Pywps(pywps.METHOD_GET)
-        mypywps.parseRequest(self.getdescribeprocessrequest)
-        mypywps.performRequest()
-        xmldom = minidom.parseString(mypywps.response)
+        getpywps = pywps.Pywps(pywps.METHOD_GET)
+        getpywps.parseRequest(self.getdescribeprocessrequest)
+        getpywps.performRequest()
+        xmldom = minidom.parseString(getpywps.response)
         self.assertTrue(len(xmldom.getElementsByTagName("ProcessDescription"))>0)
         self.assertEquals(len(xmldom.getElementsByTagName("ProcessDescription")),
-                len(mypywps.inputs["identifier"]))
+                len(getpywps.inputs["identifier"]))
+       
+        getpywps = pywps.Pywps(pywps.METHOD_GET)
+        getpywps.parseRequest(self.getdescribeprocessrequestall)
+        getpywps.performRequest()
+        xmldom = minidom.parseString(getpywps.response)
+        self.assertEquals(len(xmldom.getElementsByTagName("ProcessDescription")),len(getpywps.request.processes))
+        
+        postpywps = pywps.Pywps(pywps.METHOD_POST)
+        describeRequestFile = open(os.path.join(pywpsPath,"tests","requests","wps_describeprocess_request_dummyprocess.xml"))
+        postinputs = postpywps.parseRequest(describeRequestFile)
+        postpywps.performRequest(postinputs)
+        xmldom = minidom.parseString(postpywps.response)
+        self.assertTrue(len(xmldom.getElementsByTagName("ProcessDescription"))>0)
+        self.assertEquals(len(xmldom.getElementsByTagName("ProcessDescription")),
+                len(postpywps.inputs["identifier"]))
+        
+        postpywps = pywps.Pywps(pywps.METHOD_POST)
+        describeRequestFile = open(os.path.join(pywpsPath,"tests","requests","wps_describeprocess_request_all.xml"))
+        postinputs = postpywps.parseRequest(describeRequestFile)
+        postpywps.performRequest(postinputs)
+        xmldom = minidom.parseString(postpywps.response)
+        self.assertEquals(len(xmldom.getElementsByTagName("ProcessDescription")),len(postpywps.request.processes))
+        
+        
 
     ######################################################################################)
     def testT05ParseExecute(self):
@@ -360,7 +409,7 @@
         self.assertTrue(len(dataInputsDom)>0)
         
         inputDom=dataInputsDom[0].getElementsByTagNameNS(self.wpsns,"Input")
-        print postxmldom.toxml()         
+        #print postxmldom.toxml()         
         #Check lineage size (number elements)
         self.assertEquals(len(inputDom),6)
         



More information about the Pywps-commits mailing list