0001-views-improve-jsonchema-validation-error-message-383.patch
passerelle/views.py | ||
---|---|---|
363 | 363 |
try: |
364 | 364 |
validate(data, json_schema) |
365 | 365 |
except ValidationError as e: |
366 |
raise APIError(e.message, http_status=400) |
|
366 |
error_msg = e.message |
|
367 |
if e.path: |
|
368 |
error_msg = '%s: %s' % ('/'.join(map(str, e.path)), error_msg) |
|
369 |
raise APIError(error_msg, http_status=400) |
|
367 | 370 |
d['post_data'] = data |
368 | 371 | |
369 | 372 |
return d |
tests/test_atal.py | ||
---|---|---|
189 | 189 |
'data': None, |
190 | 190 |
'err': 1, |
191 | 191 |
'err_class': 'passerelle.utils.jsonresponse.APIError', |
192 |
'err_desc': "'content' is a required property" |
|
192 |
'err_desc': "file: 'content' is a required property"
|
|
193 | 193 |
} |
194 | 194 | |
195 | 195 |
# no file |
tests/test_cmis.py | ||
---|---|---|
103 | 103 |
expect_errors=True) |
104 | 104 |
assert response.status_code == 400 |
105 | 105 |
assert response.json['err'] == 1 |
106 |
assert response.json['err_desc'] == "1 is not of type 'string'" |
|
106 |
assert response.json['err_desc'] == "file/filename: 1 is not of type 'string'"
|
|
107 | 107 | |
108 | 108 |
response = app.post_json( |
109 | 109 |
'/cmis/slug-cmis/uploadfile', |
... | ... | |
114 | 114 |
expect_errors=True) |
115 | 115 |
assert response.status_code == 400 |
116 | 116 |
assert response.json['err'] == 1 |
117 |
assert response.json['err_desc'] == "1 is not of type 'string'" |
|
117 |
assert response.json['err_desc'] == "filename: 1 is not of type 'string'"
|
|
118 | 118 | |
119 | 119 | |
120 | 120 |
def test_uploadfile_error_if_non_valid_file_name(app, setup): |
... | ... | |
160 | 160 |
expect_errors=True) |
161 | 161 |
assert response.status_code == 400 |
162 | 162 |
assert response.json['err'] == 1 |
163 |
assert response.json['err_desc'] == "1 is not of type 'string'" |
|
163 |
assert response.json['err_desc'] == "path: 1 is not of type 'string'"
|
|
164 | 164 | |
165 | 165 | |
166 | 166 |
def test_uploadfile_error_if_no_regular_path(app, setup): |
... | ... | |
183 | 183 |
expect_errors=True) |
184 | 184 |
assert response.status_code == 400 |
185 | 185 |
assert response.json['err'] == 1 |
186 |
assert response.json['err_desc'] == "'content' is a required property" |
|
186 |
assert response.json['err_desc'] == "file: 'content' is a required property"
|
|
187 | 187 | |
188 | 188 | |
189 | 189 |
def test_uploadfile_error_if_non_string_file_content(app, setup): |
... | ... | |
194 | 194 |
expect_errors=True) |
195 | 195 |
assert response.status_code == 400 |
196 | 196 |
assert response.json['err'] == 1 |
197 |
assert response.json['err_desc'] == "1 is not of type 'string'" |
|
197 |
assert response.json['err_desc'] == "file/content: 1 is not of type 'string'"
|
|
198 | 198 | |
199 | 199 | |
200 | 200 |
def test_uploadfile_error_if_no_proper_base64_encoding(app, setup): |
tests/test_generic_endpoint.py | ||
---|---|---|
380 | 380 |
with patch_init, patch_object: |
381 | 381 |
resp = app.post_json(url_foo, params=payload, status=400) |
382 | 382 |
assert resp.json['err'] == 1 |
383 |
assert resp.json['err_desc'] == "None is not of type %s" % repr(u'integer') |
|
383 |
assert resp.json['err_desc'] == "foo/1/id: None is not of type %s" % repr(u'integer')
|
|
384 | 384 |
with patch_init, patch_object: |
385 | 385 |
resp = app.post_json(url_bar, params=payload) |
386 | 386 |
assert resp.json['err'] == 0 |
387 |
- |