Created
August 4, 2011 13:29
-
-
Save andreafrancia/1125144 to your computer and use it in GitHub Desktop.
Bug encoding PyWPS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from nose.tools import assert_equals, assert_true | |
import sys | |
sys.path.append("./pywps-svn") | |
import pywps | |
def test_no_problems_passing_normal_chars(): | |
wps = pywps.Pywps(pywps.METHOD_GET) | |
wps.parseRequest( | |
'service=WPS&version=1.0.0&' | |
'request=Execute&identifier=stub&' | |
'DataInputs=string=%s' % 'abcdefg' | |
) | |
response = wps.performRequest( | |
processes=[ProcessExpectingAString('stub', 'abcdefg')]) | |
def test_it_raises_an_exception_with_at_symbol_as_expected(): | |
wps = pywps.Pywps(pywps.METHOD_GET) | |
try: | |
wps.parseRequest( | |
'service=WPS&version=1.0.0&' | |
'request=Execute&identifier=stub&' | |
'DataInputs=string=%s' % '@' | |
) | |
except ValueError, e: | |
assert_equals('need more than 1 value to unpack', str(e)) | |
def test_it_raises_an_exception_also_when_the_at_is_encoded(): | |
wps = pywps.Pywps(pywps.METHOD_GET) | |
try: | |
wps.parseRequest( | |
'service=WPS&version=1.0.0&' | |
'request=Execute&identifier=stub&' | |
'DataInputs=string=%s' % '%40' | |
) | |
except ValueError, e: | |
assert_equals('need more than 1 value to unpack', str(e)) | |
from pywps.Process import WPSProcess | |
class ProcessExpectingAString(WPSProcess): | |
def __init__(self,name,expectation): | |
WPSProcess.__init__(self, name) | |
self.expectation=expectation | |
self.addLiteralInput(identifier = "string", title = "", | |
type=type("string")) | |
def execute(self): | |
assert_equals(self.expectation, self.getInputValue('string')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment