← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~stevenk/launchpad/fix-bugtask-incomplete-migrator into lp:launchpad

 

Steve Kowalik has proposed merging lp:~stevenk/launchpad/fix-bugtask-incomplete-migrator into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #871038 in Launchpad itself: "BugTaskIncompleteMigrator blows up on bugs that were filed Incomplete"
  https://bugs.launchpad.net/launchpad/+bug/871038

For more details, see:
https://code.launchpad.net/~stevenk/launchpad/fix-bugtask-incomplete-migrator/+merge/78794

Fix BugTaskIncompleteMigrator to deal with BugTasks that do not have date_incomplete set -- that means they were filed as Incomplete.

I have also fixed up some lint that I noticed.
-- 
https://code.launchpad.net/~stevenk/launchpad/fix-bugtask-incomplete-migrator/+merge/78794
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/fix-bugtask-incomplete-migrator into lp:launchpad.
=== modified file 'lib/lp/scripts/garbo.py'
--- lib/lp/scripts/garbo.py	2011-10-05 18:24:09 +0000
+++ lib/lp/scripts/garbo.py	2011-10-10 03:40:29 +0000
@@ -840,9 +840,14 @@
         transaction.begin()
         tasks = list(self.query[:chunk_size])
         for (task, bug) in tasks:
-            if (bug.date_last_message is None or
+            if not task.date_incomplete:
+                # Filed as Incomplete.
+                task._status = (
+                    BugTaskStatusSearch.INCOMPLETE_WITHOUT_RESPONSE)
+            elif (bug.date_last_message is None or
                 task.date_incomplete > bug.date_last_message):
-                task._status = BugTaskStatusSearch.INCOMPLETE_WITHOUT_RESPONSE
+                task._status = (
+                    BugTaskStatusSearch.INCOMPLETE_WITHOUT_RESPONSE)
             else:
                 task._status = BugTaskStatusSearch.INCOMPLETE_WITH_RESPONSE
         self.log.debug("Updated status on %d tasks" % len(tasks))

=== modified file 'lib/lp/scripts/tests/test_garbo.py'
--- lib/lp/scripts/tests/test_garbo.py	2011-10-05 18:24:09 +0000
+++ lib/lp/scripts/tests/test_garbo.py	2011-10-10 03:40:29 +0000
@@ -889,13 +889,28 @@
             store.find(BugTask.id,
                 BugTask.id == with_response.id,
                 BugTask._status ==
-                       BugTaskStatusSearch.INCOMPLETE_WITH_RESPONSE).count())
+                    BugTaskStatusSearch.INCOMPLETE_WITH_RESPONSE).count())
         self.assertEqual(
             1,
             store.find(BugTask.id,
                 BugTask.id == without_response.id,
                 BugTask._status ==
-                     BugTaskStatusSearch.INCOMPLETE_WITHOUT_RESPONSE).count())
+                    BugTaskStatusSearch.INCOMPLETE_WITHOUT_RESPONSE).count())
+
+    def test_BugTaskIncompleteMigrator_filed_as_incomplete(self):
+        # BugTaskIncompleteMigrator also deals with bugs that have never
+        # transitioned to Incomplete.
+        LaunchpadZopelessLayer.switchDbUser('testadmin')
+        bug = self.factory.makeBug(status=BugTaskStatus.INCOMPLETE)
+        without_response = bug.bugtasks[0]
+        transaction.commit()
+        self.runHourly()
+        self.assertEqual(
+            1,
+            IMasterStore(BugTask).find(BugTask.id,
+                BugTask.id == without_response.id,
+                BugTask._status ==
+                    BugTaskStatusSearch.INCOMPLETE_WITHOUT_RESPONSE).count())
 
     def test_BranchJobPruner(self):
         # Garbo should remove jobs completed over 30 days ago.