Revision 14402edc snf-django-lib/snf_django/utils/testing.py
b/snf-django-lib/snf_django/utils/testing.py | ||
---|---|---|
250 | 250 |
return response |
251 | 251 |
|
252 | 252 |
def assertSuccess(self, response): |
253 |
self.assertTrue(response.status_code in [200, 202, 203, 204]) |
|
253 |
self.assertTrue(response.status_code in [200, 202, 203, 204], |
|
254 |
msg=response.content) |
|
254 | 255 |
|
255 | 256 |
def assertSuccess201(self, response): |
256 |
self.assertEqual(response.status_code, 201) |
|
257 |
self.assertEqual(response.status_code, 201, msg=response.content)
|
|
257 | 258 |
|
258 |
def assertFault(self, response, status_code, name): |
|
259 |
self.assertEqual(response.status_code, status_code) |
|
259 |
def assertFault(self, response, status_code, name, msg=''): |
|
260 |
self.assertEqual(response.status_code, status_code, |
|
261 |
msg=msg) |
|
260 | 262 |
fault = json.loads(response.content) |
261 | 263 |
self.assertEqual(fault.keys(), [name]) |
262 | 264 |
|
263 | 265 |
def assertBadRequest(self, response): |
264 |
self.assertFault(response, 400, 'badRequest') |
|
266 |
self.assertFault(response, 400, 'badRequest', msg=response.content)
|
|
265 | 267 |
|
266 | 268 |
def assertConflict(self, response): |
267 |
self.assertFault(response, 409, 'conflict') |
|
269 |
self.assertFault(response, 409, 'conflict', msg=response.content)
|
|
268 | 270 |
|
269 | 271 |
def assertItemNotFound(self, response): |
270 |
self.assertFault(response, 404, 'itemNotFound') |
|
271 |
|
|
272 |
def assertConflict(self, response): |
|
273 |
self.assertFault(response, 409, "conflict") |
|
272 |
self.assertFault(response, 404, 'itemNotFound', msg=response.content) |
|
274 | 273 |
|
275 | 274 |
def assertMethodNotAllowed(self, response): |
276 |
self.assertFault(response, 405, 'notAllowed') |
|
275 |
self.assertFault(response, 405, 'notAllowed', msg=response.content)
|
|
277 | 276 |
self.assertTrue('Allow' in response) |
278 | 277 |
try: |
279 | 278 |
error = json.loads(response.content) |
Also available in: Unified diff