From e9ae557470c117435c02d6f4d502536bf0bfaab5 Mon Sep 17 00:00:00 2001 From: Abhilash Raj Date: Fri, 31 Jul 2015 12:47:43 +0530 Subject: Fix #115 --- src/mailman/model/listmanager.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mailman/model/listmanager.py b/src/mailman/model/listmanager.py index 8fc739543..b92ab2fc1 100644 --- a/src/mailman/model/listmanager.py +++ b/src/mailman/model/listmanager.py @@ -27,7 +27,9 @@ from mailman.interfaces.address import InvalidEmailAddressError from mailman.interfaces.listmanager import ( IListManager, ListAlreadyExistsError, ListCreatedEvent, ListCreatingEvent, ListDeletedEvent, ListDeletingEvent) -from mailman.model.mailinglist import IAcceptableAliasSet, MailingList +from mailman.model.autorespond import AutoResponseRecord +from mailman.model.mailinglist import ( + IAcceptableAliasSet, MailingList, ListArchiver) from mailman.model.mime import ContentFilter from mailman.utilities.datetime import now from zope.event import notify @@ -77,6 +79,8 @@ class ListManager: # First delete information associated with the mailing list. IAcceptableAliasSet(mlist).clear() store.query(ContentFilter).filter_by(mailing_list=mlist).delete() + store.query(ListArchiver).filter_by(mailing_list=mlist).delete() + store.query(AutoResponseRecord).filter_by(mailing_list=mlist).delete() store.delete(mlist) notify(ListDeletedEvent(fqdn_listname)) -- cgit v1.2.3-70-g09d2 From 7af71bc6965a461e4def050a3ac05874890edaab Mon Sep 17 00:00:00 2001 From: Abhilash Raj Date: Fri, 31 Jul 2015 19:53:08 +0530 Subject: Add tests for #115 --- src/mailman/model/tests/test_listmanager.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/mailman/model/tests/test_listmanager.py b/src/mailman/model/tests/test_listmanager.py index f74bf54d7..f608dbdc5 100644 --- a/src/mailman/model/tests/test_listmanager.py +++ b/src/mailman/model/tests/test_listmanager.py @@ -29,10 +29,12 @@ import unittest from mailman.app.lifecycle import create_list from mailman.app.moderator import hold_message from mailman.config import config +from mailman.database.transaction import transaction from mailman.interfaces.address import InvalidEmailAddressError from mailman.interfaces.listmanager import ( IListManager, ListAlreadyExistsError, ListCreatedEvent, ListCreatingEvent, ListDeletedEvent, ListDeletingEvent) +from mailman.interfaces.mailinglist import IListArchiverSet from mailman.interfaces.messages import IMessageStore from mailman.interfaces.requests import IListRequests from mailman.interfaces.subscriptions import ISubscriptionService @@ -86,6 +88,13 @@ class TestListManager(unittest.TestCase): sorted(getUtility(IListManager).list_ids), ['ant.example.com', 'bee.example.com', 'cat.example.com']) + def test_delete_lists_with_data_in_listarchiver(self): + mlist = create_list('ant@example.com') + with transaction(): + aset = getUtility(IListArchiverSet)(mlist) + list_manager = getUtility(IListManager) + list_manager.delete(mlist) + self.assertIsNone(list_manager.get('ant@example.com')) class TestListLifecycleEvents(unittest.TestCase): -- cgit v1.2.3-70-g09d2 From ae121d3f91d97638dffbec915f4ad1cfd8808286 Mon Sep 17 00:00:00 2001 From: Abhilash Raj Date: Fri, 31 Jul 2015 20:09:00 +0530 Subject: Fix zope lookup error in the previous commit --- src/mailman/model/tests/test_listmanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mailman/model/tests/test_listmanager.py b/src/mailman/model/tests/test_listmanager.py index f608dbdc5..f8290b634 100644 --- a/src/mailman/model/tests/test_listmanager.py +++ b/src/mailman/model/tests/test_listmanager.py @@ -91,7 +91,7 @@ class TestListManager(unittest.TestCase): def test_delete_lists_with_data_in_listarchiver(self): mlist = create_list('ant@example.com') with transaction(): - aset = getUtility(IListArchiverSet)(mlist) + aset = IListArchiverSet(mlist) list_manager = getUtility(IListManager) list_manager.delete(mlist) self.assertIsNone(list_manager.get('ant@example.com')) -- cgit v1.2.3-70-g09d2 From a4bf5b02b5d02a6ae107c4152c166c3191689057 Mon Sep 17 00:00:00 2001 From: Abhilash Raj Date: Mon, 3 Aug 2015 18:39:47 +0530 Subject: Add tests for autoresponserecord --- src/mailman/model/listmanager.py | 2 +- src/mailman/model/tests/test_listmanager.py | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mailman/model/listmanager.py b/src/mailman/model/listmanager.py index b92ab2fc1..b3e5be69a 100644 --- a/src/mailman/model/listmanager.py +++ b/src/mailman/model/listmanager.py @@ -29,7 +29,7 @@ from mailman.interfaces.listmanager import ( ListDeletedEvent, ListDeletingEvent) from mailman.model.autorespond import AutoResponseRecord from mailman.model.mailinglist import ( - IAcceptableAliasSet, MailingList, ListArchiver) + IAcceptableAliasSet, ListArchiver, MailingList) from mailman.model.mime import ContentFilter from mailman.utilities.datetime import now from zope.event import notify diff --git a/src/mailman/model/tests/test_listmanager.py b/src/mailman/model/tests/test_listmanager.py index f8290b634..0b68002e0 100644 --- a/src/mailman/model/tests/test_listmanager.py +++ b/src/mailman/model/tests/test_listmanager.py @@ -30,6 +30,7 @@ from mailman.app.lifecycle import create_list from mailman.app.moderator import hold_message from mailman.config import config from mailman.database.transaction import transaction +from mailman.interfaces.autorespond import IAutoResponseSet, Response from mailman.interfaces.address import InvalidEmailAddressError from mailman.interfaces.listmanager import ( IListManager, ListAlreadyExistsError, ListCreatedEvent, ListCreatingEvent, @@ -90,12 +91,21 @@ class TestListManager(unittest.TestCase): def test_delete_lists_with_data_in_listarchiver(self): mlist = create_list('ant@example.com') - with transaction(): - aset = IListArchiverSet(mlist) + aset = IListArchiverSet(mlist) list_manager = getUtility(IListManager) list_manager.delete(mlist) self.assertIsNone(list_manager.get('ant@example.com')) + def test_delete_lists_with_data_in_autoresponserecord(self): + list_manager = getUtility(IListManager) + user_manager = getUtility(IUserManager) + mlist = create_list('ant@example.com') + addr = user_manager.create_address('aperson@example.com') + autoresset = IAutoResponseSet(mlist) + autoresset.response_sent(addr, Response.hold) + list_manager.delete(mlist) + self.assertIsNone(list_manager.get('ant@example.com')) + class TestListLifecycleEvents(unittest.TestCase): layer = ConfigLayer -- cgit v1.2.3-70-g09d2 From ed6088c24936c799a2581ad14e4ace20e6be5e2c Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Tue, 4 Aug 2015 22:24:50 -0400 Subject: Clean up maxking's branch a little bit. * Sort the .delete()'s * Remove an unused import. * Renamed and documented some tests. * Support tox's new passenv setting. --- src/mailman/model/listmanager.py | 2 +- src/mailman/model/tests/test_listmanager.py | 20 +++++++++++++------- tox.ini | 2 ++ 3 files changed, 16 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/mailman/model/listmanager.py b/src/mailman/model/listmanager.py index b3e5be69a..7e69064c9 100644 --- a/src/mailman/model/listmanager.py +++ b/src/mailman/model/listmanager.py @@ -78,9 +78,9 @@ class ListManager: notify(ListDeletingEvent(mlist)) # First delete information associated with the mailing list. IAcceptableAliasSet(mlist).clear() + store.query(AutoResponseRecord).filter_by(mailing_list=mlist).delete() store.query(ContentFilter).filter_by(mailing_list=mlist).delete() store.query(ListArchiver).filter_by(mailing_list=mlist).delete() - store.query(AutoResponseRecord).filter_by(mailing_list=mlist).delete() store.delete(mlist) notify(ListDeletedEvent(fqdn_listname)) diff --git a/src/mailman/model/tests/test_listmanager.py b/src/mailman/model/tests/test_listmanager.py index 0b68002e0..c8fe39186 100644 --- a/src/mailman/model/tests/test_listmanager.py +++ b/src/mailman/model/tests/test_listmanager.py @@ -29,7 +29,6 @@ import unittest from mailman.app.lifecycle import create_list from mailman.app.moderator import hold_message from mailman.config import config -from mailman.database.transaction import transaction from mailman.interfaces.autorespond import IAutoResponseSet, Response from mailman.interfaces.address import InvalidEmailAddressError from mailman.interfaces.listmanager import ( @@ -89,23 +88,30 @@ class TestListManager(unittest.TestCase): sorted(getUtility(IListManager).list_ids), ['ant.example.com', 'bee.example.com', 'cat.example.com']) - def test_delete_lists_with_data_in_listarchiver(self): + def test_delete_list_with_list_archiver_set(self): + # Ensure that mailing lists with archiver sets can be deleted. In + # issue #115, this fails under PostgreSQL, but not SQLite. mlist = create_list('ant@example.com') - aset = IListArchiverSet(mlist) + # We don't keep a reference to this archiver set just because it makes + # pyflakes unhappy. It doesn't change the outcome. + IListArchiverSet(mlist) list_manager = getUtility(IListManager) list_manager.delete(mlist) self.assertIsNone(list_manager.get('ant@example.com')) - def test_delete_lists_with_data_in_autoresponserecord(self): + def test_delete_list_with_autoresponse_record(self): + # Ensure that mailing lists with auto-response sets can be deleted. In + # issue #115, this fails under PostgreSQL, but not SQLite. list_manager = getUtility(IListManager) user_manager = getUtility(IUserManager) mlist = create_list('ant@example.com') - addr = user_manager.create_address('aperson@example.com') - autoresset = IAutoResponseSet(mlist) - autoresset.response_sent(addr, Response.hold) + address = user_manager.create_address('aperson@example.com') + autoresponse_set = IAutoResponseSet(mlist) + autoresponse_set.response_sent(address, Response.hold) list_manager.delete(mlist) self.assertIsNone(list_manager.get('ant@example.com')) + class TestListLifecycleEvents(unittest.TestCase): layer = ConfigLayer diff --git a/tox.ini b/tox.ini index ac35f1fb9..d0c6e294b 100644 --- a/tox.ini +++ b/tox.ini @@ -6,6 +6,8 @@ recreate = True commands = python -m nose2 -v #sitepackages = True usedevelop = True +passenv= + MAILMAN_* # This environment requires you to set up PostgreSQL and create a .cfg file # somewhere outside of the source tree. -- cgit v1.2.3-70-g09d2 From 9855a380b17124627623093771d3fa4bb83749c2 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Tue, 4 Aug 2015 22:27:33 -0400 Subject: Add NEWS. --- src/mailman/docs/NEWS.rst | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/mailman/docs/NEWS.rst b/src/mailman/docs/NEWS.rst index b813e5b65..c7b88b298 100644 --- a/src/mailman/docs/NEWS.rst +++ b/src/mailman/docs/NEWS.rst @@ -24,6 +24,8 @@ Bugs variable `[mailman]html_to_plain_text_command` in the `mailman.cfg` file defines the command to use. It defaults to `lynx`. (Closes: #109) * Confirmation messages should not be `Precedence: bulk`. (Closes #75) + * Fix constraint violations on mailing list deletes affecting PostgreSQL. + Given by Abhilash Raj. (Closes #115) Configuration ------------- -- cgit v1.2.3-70-g09d2