summaryrefslogtreecommitdiff
path: root/src/mailman/model/tests/test_bans.py
diff options
context:
space:
mode:
authorAurélien Bompard2016-01-14 16:16:32 +0100
committerAurélien Bompard2016-01-14 16:41:32 +0100
commit08d8cae4f79bdf0a0773efdd2f795411f280cd1e (patch)
treefeedf33bb16d9634cde36a1c288bfac4f927ce72 /src/mailman/model/tests/test_bans.py
parent6f0b236ea33ffe2899e813dc9bcbc58da0cbefee (diff)
downloadmailman-08d8cae4f79bdf0a0773efdd2f795411f280cd1e.tar.gz
mailman-08d8cae4f79bdf0a0773efdd2f795411f280cd1e.tar.zst
mailman-08d8cae4f79bdf0a0773efdd2f795411f280cd1e.zip
Delete bans when their associated list is deleted
Also add indexes on the Ban fields that are filtered on.
Diffstat (limited to 'src/mailman/model/tests/test_bans.py')
-rw-r--r--src/mailman/model/tests/test_bans.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/mailman/model/tests/test_bans.py b/src/mailman/model/tests/test_bans.py
new file mode 100644
index 000000000..a7ff8ed4f
--- /dev/null
+++ b/src/mailman/model/tests/test_bans.py
@@ -0,0 +1,46 @@
+# Copyright (C) 2013-2016 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 <http://www.gnu.org/licenses/>.
+
+"""Test Bans and the ban manager."""
+
+__all__ = [
+ 'TestMailingListBans',
+ ]
+
+
+import unittest
+
+from mailman.app.lifecycle import create_list
+from mailman.interfaces.bans import IBanManager
+from mailman.interfaces.listmanager import IListManager
+from mailman.testing.layers import ConfigLayer
+from zope.component import getUtility
+
+
+
+class TestMailingListBans(unittest.TestCase):
+ layer = ConfigLayer
+
+ def setUp(self):
+ self._mlist = create_list('ant@example.com')
+ self._manager = IBanManager(self._mlist)
+
+ def test_delete_list(self):
+ # All list bans must be deleted when the list is deleted
+ self._manager.ban("anne@example.com")
+ getUtility(IListManager).delete(self._mlist)
+ self.assertEqual(len(list(self._manager)), 0)