def test_response_json(self):
# Create a json response object
json_dict = {'response': 'test'}
json_template = dumps(json_dict)
response = HttpResponse(json_template, content_type='application/json')
response_data = self.middleware._extract_response_data(response)
self.assertIn('json', response_data['type'])
self.assertEqual(200, response_data['status_code'])
self.assertEqual(json_dict, response_data['content'])
评论列表
文章目录