def test_update_error_dict(self): error = NestedValidationError("error") self.assertDictEqual({ "some": "other error", "__all__": [error] }, error.update_error_dict({"some": "other error"})) other = ValidationError("other error") error2 = NestedValidationError({"some": error}) self.assertDictEqual({"some": [other, error]}, error2.update_error_dict({"some": [other]}))
def test_string_message(self): error = NestedValidationError("error") self.assertEqual(error.message, "error") self.assertIsNone(error.params) self.assertIsInstance(error.error_list, list) self.assertEqual(len(error.error_list), 1) self.assertEqual(error.error_list, [error]) error_dict = error.update_error_dict({"some": "other error"}) self.assertDictEqual({ "some": "other error", "__all__": [error] }, error_dict)
def test_dict_message(self): error = NestedValidationError({"some": "error"}) self.assertIsInstance(error.error_dict, dict) self.assertIn("some", error.error_dict) errors = error.error_dict["some"] self.assertIsInstance(errors, list) other = [ValidationError("other error")] error_dict = error.update_error_dict({"some": other}) self.assertDictEqual({"some": [other[0], errors[0]]}, error_dict) error = errors[0] self.assertEqual(error.message, "error") self.assertIsNone(error.params) self.assertIsInstance(error.error_list, list) self.assertEqual(len(error.error_list), 1) self.assertEqual(error.error_list, [error])