summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mailman/app/tests/test_lifecycle.py15
-rw-r--r--src/mailman/model/tests/test_uid.py6
-rw-r--r--src/mailman/model/tests/test_workflow.py4
-rw-r--r--src/mailman/model/uid.py4
4 files changed, 27 insertions, 2 deletions
diff --git a/src/mailman/app/tests/test_lifecycle.py b/src/mailman/app/tests/test_lifecycle.py
index df2bf5233..5ce8fb887 100644
--- a/src/mailman/app/tests/test_lifecycle.py
+++ b/src/mailman/app/tests/test_lifecycle.py
@@ -28,8 +28,10 @@ import unittest
from mailman.interfaces.address import InvalidEmailAddressError
from mailman.interfaces.domain import BadDomainSpecificationError
+from mailman.interfaces.listmanager import IListManager
from mailman.app.lifecycle import create_list, remove_list
from mailman.testing.layers import ConfigLayer
+from zope.component import getUtility
@@ -55,3 +57,16 @@ class TestLifecycle(unittest.TestCase):
self.addCleanup(shutil.rmtree, mlist.data_path)
self.assertRaises(OSError, remove_list, mlist)
os.chmod(mlist.data_path, 0o777)
+
+ def test_create_no_such_style(self):
+ mlist = create_list('ant@example.com', style_name='bogus')
+ # The MailmanList._preferred_language column isn't set so there's no
+ # valid mapping to an ILanguage. Therefore this call will produce a
+ # KeyError.
+ self.assertRaises(KeyError, getattr, mlist, 'preferred_language')
+
+ def test_remove_list_without_data_path(self):
+ mlist = create_list('ant@example.com')
+ shutil.rmtree(mlist.data_path)
+ remove_list(mlist)
+ self.assertIsNone(getUtility(IListManager).get('ant@example.com'))
diff --git a/src/mailman/model/tests/test_uid.py b/src/mailman/model/tests/test_uid.py
index 8f3b4af70..67fdab71e 100644
--- a/src/mailman/model/tests/test_uid.py
+++ b/src/mailman/model/tests/test_uid.py
@@ -85,3 +85,9 @@ class TestUID(unittest.TestCase):
# And all the users still exist.
non_orphans = set(user.user_id for user in manager.users)
self.assertEqual(uids, non_orphans)
+
+ def test_repr(self):
+ uid = UID(uuid.UUID(int=1))
+ self.assertTrue(repr(uid).startswith(
+ '<UID 00000000-0000-0000-0000-000000000001 at '))
+ self.assertTrue(repr(uid).endswith('>'))
diff --git a/src/mailman/model/tests/test_workflow.py b/src/mailman/model/tests/test_workflow.py
index 88ed506bd..986bcc3bf 100644
--- a/src/mailman/model/tests/test_workflow.py
+++ b/src/mailman/model/tests/test_workflow.py
@@ -146,3 +146,7 @@ class TestWorkflow(unittest.TestCase):
self.assertEqual(state.step, 'three')
state = self._manager.restore('bee', 'nekot')
self.assertEqual(state.step, 'four')
+
+ def test_discard_missing_workflow(self):
+ self._manager.discard('bogus-name', 'bogus-token')
+ self.assertEqual(self._manager.count, 0)
diff --git a/src/mailman/model/uid.py b/src/mailman/model/uid.py
index 40d137ee0..750f092cc 100644
--- a/src/mailman/model/uid.py
+++ b/src/mailman/model/uid.py
@@ -50,12 +50,12 @@ class UID(Model):
@dbconnection
def __init__(self, store, uid):
- super(UID, self).__init__()
+ super().__init__()
self.uid = uid
store.add(self)
def __repr__(self):
- return '<UID {0} at {1}>'.format(self.uid, id(self))
+ return '<UID {} at {}>'.format(self.uid, id(self))
@staticmethod
@dbconnection