def test_json_content_type_valid_data_2(self): # Known Content-Type, good data request = RequestFactory().post( '/', data='{"key": "value"}', content_type='application/json', ) self.assertEqual( deserialize_request_body(request), {'key': 'value'}, )
def test_json_content_type_valid_data_1(self): # Known Content-Type, good data request = RequestFactory().post( '/', data='[1, 2, 3]', content_type='application/json', ) self.assertEqual( deserialize_request_body(request), [1, 2, 3], )
def test_form_content_type_valid_data(self): data_dic = {'key1': 'value1', 'key2': 'value2'} request = RequestFactory().post( '/', data=urllib.urlencode(data_dic), content_type='application/x-www-form-urlencoded', ) self.assertEqual( deserialize_request_body(request), data_dic, )