# Copyright (C) 2012-2015 by the Free Software Foundation, Inc.
#
# This file is part of GNU Mailman.
#
# GNU Mailman is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# GNU Mailman. If not, see .
"""Test email address registration."""
__all__ = [
'TestEmailValidation',
'TestRegistration',
]
import unittest
from mailman.app.lifecycle import create_list
from mailman.interfaces.address import InvalidEmailAddressError
from mailman.interfaces.pending import IPendings
from mailman.interfaces.registrar import ConfirmationNeededEvent, IRegistrar
from mailman.testing.helpers import event_subscribers
from mailman.testing.layers import ConfigLayer
from zope.component import getUtility
class TestEmailValidation(unittest.TestCase):
"""Test basic email validation."""
layer = ConfigLayer
def setUp(self):
self.registrar = getUtility(IRegistrar)
self.mlist = create_list('alpha@example.com')
def test_empty_string_is_invalid(self):
self.assertRaises(InvalidEmailAddressError,
self.registrar.register, self.mlist,
'')
def test_no_spaces_allowed(self):
self.assertRaises(InvalidEmailAddressError,
self.registrar.register, self.mlist,
'some name@example.com')
def test_no_angle_brackets(self):
self.assertRaises(InvalidEmailAddressError,
self.registrar.register, self.mlist,
'