def test_data(self): """extract_post_request() returns request.json_body data.""" # Empty data. request = self.request_factory() context = contextextractors.extract_json_context(request) self.assertEqual(context, {}) # Not empty. request = self.request_factory({'dummy': 'hello world!'}) context = contextextractors.extract_json_context(request) self.assertEqual(context, request.json_body)
def test_copy(self): """extract_post_request() returns copy of request's json_body.""" request = self.request_factory({'dummy': 'hello world!'}) context = contextextractors.extract_json_context(request) self.assertFalse(context is request.json_body) del context['dummy'] self.assertEqual(context, {}) self.assertTrue('dummy' in request.json_body)