def test_add_messages_error(self): """ Test that calling `add_messages` with something that is not a `Validation` instances throw an error. """ validation = Validation("id") with assert_raises(TypeError): validation.add_messages("foo")
def test_add_messages_error(self): """ Test that calling `add_messages` with something that is not a `Validation` instances throw an error. """ validation = Validation("id") with assert_raises(TypeError): validation.add_messages("foo")
def test_add_messages(self): """ Test the behavior of adding the messages from another `Validation` object to this instance. """ validation_1 = Validation("id") validation_1.add(ValidationMessage(ValidationMessage.ERROR, "Error message")) validation_2 = Validation("id") validation_2.add(ValidationMessage(ValidationMessage.WARNING, "Warning message")) validation_1.add_messages(validation_2) self.assertEqual(2, len(validation_1.messages)) self.assertEqual(ValidationMessage.ERROR, validation_1.messages[0].type) self.assertEqual("Error message", validation_1.messages[0].text) self.assertEqual(ValidationMessage.WARNING, validation_1.messages[1].type) self.assertEqual("Warning message", validation_1.messages[1].text)
def test_add_messages(self): """ Test the behavior of adding the messages from another `Validation` object to this instance. """ validation_1 = Validation("id") validation_1.add(ValidationMessage(ValidationMessage.ERROR, "Error message")) validation_2 = Validation("id") validation_2.add(ValidationMessage(ValidationMessage.WARNING, "Warning message")) validation_1.add_messages(validation_2) self.assertEqual(2, len(validation_1.messages)) self.assertEqual(ValidationMessage.ERROR, validation_1.messages[0].type) self.assertEqual("Error message", validation_1.messages[0].text) self.assertEqual(ValidationMessage.WARNING, validation_1.messages[1].type) self.assertEqual("Warning message", validation_1.messages[1].text)