launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #04556
[Merge] lp:~gmb/launchpad/bug-655239 into lp:launchpad
Graham Binns has proposed merging lp:~gmb/launchpad/bug-655239 into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #655239 in Launchpad itself: "Trying to delete a BugWatch which has BugWatchActivity records OOPSes"
https://bugs.launchpad.net/launchpad/+bug/655239
For more details, see:
https://code.launchpad.net/~gmb/launchpad/bug-655239/+merge/71073
This branch fixes bug 655239 by adding a line to BugWatch.destroySelf() to remove all BugWatchActivity entries for that BugWatch.
I've also added a test to ensure that all Activity items for the watch are removed (and implicitly that BugWatch.destroySelf() no longer OOPSes).
--
https://code.launchpad.net/~gmb/launchpad/bug-655239/+merge/71073
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~gmb/launchpad/bug-655239 into lp:launchpad.
=== modified file 'database/schema/security.cfg'
--- database/schema/security.cfg 2011-08-09 05:38:37 +0000
+++ database/schema/security.cfg 2011-08-10 16:06:29 +0000
@@ -1119,6 +1119,7 @@
public.bugtracker = SELECT, INSERT, UPDATE, DELETE
public.bugtrackeralias = SELECT, INSERT, UPDATE, DELETE
public.bugwatch = SELECT, INSERT, UPDATE, DELETE
+public.bugwatchactivity = SELECT, INSERT, UPDATE, DELETE
public.builder = SELECT, INSERT, UPDATE
public.buildfarmjob = SELECT, INSERT, UPDATE
public.buildpackagejob = SELECT, INSERT, UPDATE, DELETE
=== modified file 'lib/lp/bugs/model/bugwatch.py'
--- lib/lp/bugs/model/bugwatch.py 2011-05-28 04:09:11 +0000
+++ lib/lp/bugs/model/bugwatch.py 2011-08-10 16:06:29 +0000
@@ -233,6 +233,8 @@
not self.getImportedBugMessages().is_empty()):
raise BugWatchDeletionError(
"Can't delete bug watches linked to tasks or comments.")
+ # Remove any BugWatchActivity entries for this bug watch.
+ self.activity.remove()
# XXX 2010-09-29 gmb bug=647103
# We flush the store to make sure that errors bubble up and
# are caught by the OOPS machinery.
=== modified file 'lib/lp/bugs/tests/test_bugwatch.py'
--- lib/lp/bugs/tests/test_bugwatch.py 2011-05-27 21:12:25 +0000
+++ lib/lp/bugs/tests/test_bugwatch.py 2011-08-10 16:06:29 +0000
@@ -9,6 +9,7 @@
datetime,
timedelta,
)
+from storm.store import Store
import unittest
from urlparse import urlunsplit
@@ -475,6 +476,20 @@
bug.default_bugtask.bugwatch = bug_watch
self.assertRaises(BugWatchDeletionError, bug_watch.destroySelf)
+ def test_deleting_bugwatch_deletes_bugwatchactivity(self):
+ # Deleting a bug watch will also delete all its
+ # BugWatchActivity entries.
+ bug_watch = self.factory.makeBugWatch()
+ for i in range(5):
+ bug_watch.addActivity(message="Activity %s" % i)
+ store = Store.of(bug_watch)
+ watch_activity_query = (
+ "SELECT id FROM BugWatchActivity WHERE bug_watch = %s" %
+ bug_watch.id)
+ self.assertNotEqual(0, store.execute(watch_activity_query).rowcount)
+ bug_watch.destroySelf()
+ self.assertEqual(0, store.execute(watch_activity_query).rowcount)
+
class TestBugWatchSet(TestCaseWithFactory):
"""Tests for the bugwatch updating system."""