Skip to content

Commit 91da95e

Browse files
authored
Merge pull request #330 from bird-house/issue-329-fix-test-suite-part2
Fix #329: fix test-suite ... pep8 ... test failures
2 parents 34b06f4 + 958bde8 commit 91da95e

File tree

6 files changed

+23
-11
lines changed

6 files changed

+23
-11
lines changed

pywps/app/WPSRequest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ def _get_rawvalue_value(data, encoding=None):
631631
elif encoding == 'base64':
632632
return base64.b64decode(data)
633633
return base64.b64decode(data)
634-
except:
634+
except Exception:
635635
return data
636636

637637

pywps/inout/literaltypes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def convert_boolean(inpt):
199199
val = False
200200
else:
201201
val = True
202-
except:
202+
except Exception:
203203
val = True
204204
return val
205205

pywps/inout/outputs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def _execute_xml_data(self):
238238
try:
239239
data_doc = etree.parse(self.file)
240240
complex_doc.append(data_doc.getroot())
241-
except:
241+
except Exception:
242242

243243
if isinstance(self.data, six.string_types):
244244
complex_doc.text = self.data

pywps/tests.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,14 @@ def assert_response_success(resp):
114114
assert len(success) == 1
115115

116116

117+
def assert_process_exception(resp, code=None):
118+
assert resp.status_code == 400
119+
assert resp.headers['Content-Type'] == 'text/xml'
120+
elem = resp.xpath('/ows:ExceptionReport'
121+
'/ows:Exception')
122+
assert elem[0].attrib['exceptionCode'] == code
123+
124+
117125
def assert_pywps_version(resp):
118126
# get first child of root element
119127
root_firstchild = resp.xpath('/*')[0].getprevious()

tests/test_describe.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from pywps.exceptions import MissingParameterValue
2020

2121
from pywps.tests import assert_pywps_version, client_for
22+
from pywps.tests import assert_process_exception
2223

2324
ProcessDescription = namedtuple('ProcessDescription', ['identifier', 'inputs', 'metadata'])
2425

@@ -90,14 +91,15 @@ def test_get_request_all_args(self):
9091
assert 'hello metadata' in [item for sublist in metadata for item in sublist]
9192

9293
def test_get_request_zero_args(self):
93-
with self.assertRaises(MissingParameterValue) as e:
94-
resp = self.client.get('?Request=DescribeProcess&version=1.0.0&service=wps')
95-
assert resp.status_code == 400 # bad request, identifier is missing
94+
# with self.assertRaises(MissingParameterValue) as e:
95+
resp = self.client.get('?Request=DescribeProcess&version=1.0.0&service=wps')
96+
# bad request, identifier is missing
97+
assert_process_exception(resp, code='MissingParameterValue')
9698

9799
def test_get_request_nonexisting_process_args(self):
98-
with self.assertRaises(InvalidParameterValue) as e:
99-
resp = self.client.get('?Request=DescribeProcess&version=1.0.0&service=wps&identifier=NONEXISTINGPROCESS')
100-
assert resp.status_code == 400
100+
resp = self.client.get('?Request=DescribeProcess&version=1.0.0&service=wps&identifier=NONEXISTINGPROCESS')
101+
# bad request, identifier does not exist
102+
assert_process_exception(resp, code='InvalidParameterValue')
101103

102104
def test_post_request_zero_args(self):
103105
request_doc = WPS.DescribeProcess()

tests/test_wpsrequest.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ def test_json_in(self):
2929
'operation': 'getcapabilities',
3030
'version': '1.0.0',
3131
'language': 'eng',
32-
'identifiers': 'ahoj',
32+
'identifier': 'ahoj',
33+
'identifiers': 'ahoj', # TODO: why identifierS?
3334
'store_execute': True,
3435
'status': True,
3536
'lineage': True,
@@ -68,7 +69,8 @@ def test_json_inout_datetime(self):
6869
'operation': 'getcapabilities',
6970
'version': '1.0.0',
7071
'language': 'eng',
71-
'identifiers': 'moinmoin',
72+
'identifier': 'moinmoin',
73+
'identifiers': 'moinmoin', # TODO: why identifierS?
7274
'store_execute': True,
7375
'status': True,
7476
'lineage': True,

0 commit comments

Comments
 (0)