def test_json_tz(self): view = SuperView() context_0 = {"date": parse_datetime("2012-02-21 10:28:45").replace(tzinfo=utc)} with override(pytz.timezone("Australia/Sydney")): response = view.render_json(context_0) jdata = json.loads(response.content) self.assertEqual(jdata["date"], "2012-02-21T21:28:45+11:00") with override(pytz.timezone("Europe/Madrid")): response = view.render_json(context_0) jdata = json.loads(response.content) self.assertEqual(jdata["date"], "2012-02-21T11:28:45+01:00")
def test_json_response(self): view = SuperView() data = view.render_json({"foo": 1}) data = json.loads(data.content) self.assertIn("foo", data) self.assertIn("success", data) self.assertTrue(data["success"]) data = view.render_json({"foo": 1}, ok=False) data = json.loads(data.content) self.assertFalse(data["success"])
def test_json_response(self): view = SuperView() data = view.render_json({'foo': 1}) data = json.loads(data.content) self.assertIn('foo', data) self.assertIn('success', data) self.assertTrue(data['success']) data = view.render_json({'foo': 1}, ok=False) data = json.loads(data.content) self.assertFalse(data['success'])
def test_json_tz(self): view = SuperView() context_0 = { 'date': parse_datetime("2012-02-21 10:28:45").replace(tzinfo=utc) } with override(pytz.timezone("Australia/Sydney")): response = view.render_json(context_0) jdata = json.loads(response.content) self.assertEqual(jdata['date'], "2012-02-21T21:28:45+11:00") with override(pytz.timezone("Europe/Madrid")): response = view.render_json(context_0) jdata = json.loads(response.content) self.assertEqual(jdata['date'], "2012-02-21T11:28:45+01:00")