def test_parse_request_raises_when_missing_required_method_field(self):
     # Asserts on Falsy
     self.request_w_query_string['method'] = None
     with self.assertRaises(ValidationError):
         parse_data(self.request_w_query_string)
     # Asserts when missing
     del self.request_w_query_string['method']
     with self.assertRaises(ValidationError):
         parse_data(self.request_w_query_string)
 def test_parse_request_raises_when_response_missing_status_field(self):
     del self.request_w_query_string['request']
     # Asserts on Falsy
     self.request_w_query_string['status_code'] = None
     with self.assertRaises(ValidationError):
         parse_data(self.request_w_query_string)
     # Asserts when missing
     del self.request_w_query_string['status_code']
     with self.assertRaises(ValidationError):
         parse_data(self.request_w_query_string)
 def test_parse_request_handles_both_types_of_list_params(self):
     """
     parse_data() handles list param style `x=1&x=2`
     """
     qs = 'list_item=1&list_item=2&list_item=3'
     self.request_w_query_string['query_string'] = qs
     data = parse_data(self.request_w_query_string)
     expected = {'list_item': [1, 2, 3]}
     self.assertEqual(data.request.query_data, expected)
     self.assertIsInstance(data.request.query_data['list_item'], list)
 def test_parse_request_handles_query_string_types(self):
     """
     parse_data() parses types correctly from query string
     """
     data = parse_data(self.request_w_query_string)
     expected = {
         'a_number': 1,
         'list': ['a str', 4],
         'a_string': 'the string',
         'a_bool': True
     }
     self.assertEqual(data.request.query_data, expected)
     self.assertIsInstance(data.request.query_data['list'], list)
     self.assertIsInstance(data.request.query_data['a_number'], int)
 def test_parse_request_raises_when_missing_both_any_of_fields(self):
     del self.request_w_query_string['request']
     del self.request_w_query_string['response']
     with self.assertRaises(ValidationError):
         parse_data(self.request_w_query_string)