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],
     )
示例#3
0
 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'},
     )
示例#4
0
 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,
        )
示例#6
0
    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,
        )