Exemplo n.º 1
0
def format_success_response_check(instance: TestCase, res: HttpResponse):
  body = json.loads(res.content)

  instance.assertLess(res.status_code, 300)
  instance.assertLess(body.get('status'), 300)
  instance.assertIsNotNone(body.get('message'))
  instance.assertIsNotNone(body.get('data'))
  instance.assertIsInstance(body.get('data'), dict)
Exemplo n.º 2
0
def format_failed_response_check(instance: TestCase, res: HttpResponse):
  body = json.loads(res.content)
  failed_codes: [int] = [400, 401, 403, 404]

  instance.assertIn(res.status_code, failed_codes)
  instance.assertIsNotNone(body.get('detail'))