1
0
mirror of https://github.com/django/django.git synced 2025-01-01 14:06:06 +00:00
django/tests/view_tests/tests/test_json.py
2022-02-07 20:37:05 +01:00

21 lines
664 B
Python

import json
from django.test import SimpleTestCase, override_settings
@override_settings(ROOT_URLCONF="view_tests.generic_urls")
class JsonResponseTests(SimpleTestCase):
def test_json_response(self):
response = self.client.get("/json/response/")
self.assertEqual(response.status_code, 200)
self.assertEqual(response.headers["content-type"], "application/json")
self.assertEqual(
json.loads(response.content.decode()),
{
"a": [1, 2, 3],
"foo": {"bar": "baz"},
"timestamp": "2013-05-19T20:00:00",
"value": "3.14",
},
)