1
0
mirror of https://github.com/django/django.git synced 2024-12-28 20:16:19 +00:00
django/tests/view_tests/tests/test_json.py
Lukasz Balcerzak 0242134d32 Fixed #17942 -- Added a JsonResponse class to more easily create JSON encoded responses.
Thanks leahculver for the suggestion and Erik Romijn,
Simon Charette, and Marc Tamlyn for the reviews.
2014-02-14 18:25:19 -05:00

23 lines
620 B
Python

# encoding: utf8
from __future__ import unicode_literals
import json
from django.test import TestCase
class JsonResponseTests(TestCase):
urls = 'view_tests.generic_urls'
def test_json_response(self):
response = self.client.get('/json/response/')
self.assertEqual(response.status_code, 200)
self.assertEqual(
response['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',
})