예제 #1
0
    def is_email(self):
        """Checks if the data provided is a valid email format."""
        default_message = '{} is not a valid email address'.format(
            self.display_name)

        if self.data and not CommonValidator.is_email(self.data):
            self.validation_error_builder.add_error(self, default_message,
                                                    self.allow_multiple)

        return self
예제 #2
0
    def test_is_email_true_when_email_valid(self):
        result = CommonValidator.is_email(VALID_EMAIL)

        self.assertTrue(result)
예제 #3
0
    def test_is_email_false_when_email_invalid(self):
        result = CommonValidator.is_email(INVALID_EMAIL)

        self.assertFalse(result)