def test_posted_data_is_postprocessed_recursively(self):
     data = {"records": [{"name": colander.null}]}
     schema_mock = mock.Mock()
     schema_mock.deserialize.return_value = data
     validators.validator(self.request, schema_mock)
     self.assertIsNone(self.request.data_clean["records"][0].get("name"))
 def test_adds_body_error_if_json_invalid(self):
     self.request.body = b'{wrong,"format"}'
     validators.validator(self.request, mock.Mock())
     self.assertEqual("body", self.request.errors[0]["location"])
Beispiel #3
0
 def test_posted_data_is_postprocessed_recursively(self):
     data = {"records": [{"name": colander.null}]}
     schema_mock = mock.Mock()
     schema_mock.deserialize.return_value = data
     validators.validator(self.request, schema_mock)
     self.assertIsNone(self.request.data_clean['records'][0].get('name'))
 def test_adds_body_error_if_json_invalid(self):
     request = DummyRequest()
     request.body = b'{wrong,"format"}'
     request.errors = Errors()
     validator(request, mock.Mock())
     self.assertEqual('body', request.errors[0]['location'])
Beispiel #5
0
 def test_adds_body_error_if_json_invalid(self):
     self.request.body = b'{wrong,"format"}'
     validators.validator(self.request, mock.Mock())
     self.assertEqual('body', self.request.errors[0]['location'])