← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~stevenk/launchpad/use-transitionToStatus-createManyTasks into lp:launchpad

 

Steve Kowalik has proposed merging lp:~stevenk/launchpad/use-transitionToStatus-createManyTasks into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1023592 in Launchpad itself: "opening a new bug with a status of In Progress does not set date_in_progress"
  https://bugs.launchpad.net/launchpad/+bug/1023592

For more details, see:
https://code.launchpad.net/~stevenk/launchpad/use-transitionToStatus-createManyTasks/+merge/191554

Create new tasks in IBugTask.createManyTasks() as BugTaskStatus.NEW and then transitionToStatus(status) so that attributes on IBugTask, such as date_triaged or date_inprogress are set when filing new bugs.
-- 
https://code.launchpad.net/~stevenk/launchpad/use-transitionToStatus-createManyTasks/+merge/191554
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/use-transitionToStatus-createManyTasks into lp:launchpad.
=== modified file 'lib/lp/bugs/model/bugtask.py'
--- lib/lp/bugs/model/bugtask.py	2013-10-01 00:57:56 +0000
+++ lib/lp/bugs/model/bugtask.py	2013-10-17 04:01:32 +0000
@@ -1587,7 +1587,7 @@
         values = [
             (bug, owner, key['product'], key['productseries'],
              key['distribution'], key['distroseries'],
-             key['sourcepackagename'], status, importance, assignee,
+             key['sourcepackagename'], BugTaskStatus.NEW, importance, assignee,
              milestone)
             for key in target_keys]
         tasks = create(
@@ -1600,6 +1600,8 @@
         del get_property_cache(bug).bugtasks
         for bugtask in tasks:
             bugtask.updateTargetNameCache()
+            # Transistion to the correct status.
+            bugtask.transitionToStatus(status, bugtask.owner)
             if bugtask.conjoined_slave:
                 bugtask._syncFromConjoinedSlave()
         removeSecurityProxy(bug)._reconcileAccess()

=== modified file 'lib/lp/bugs/tests/test_bug.py'
--- lib/lp/bugs/tests/test_bug.py	2012-10-08 01:02:13 +0000
+++ lib/lp/bugs/tests/test_bug.py	2013-10-17 04:01:32 +0000
@@ -245,12 +245,13 @@
 
     def test_CreateBugParams_accepts_status(self):
         # The status of the initial bug task can be set using
-        # CreateBugParams
+        # CreateBugParams.
         owner = self.factory.makePerson()
         target = self.factory.makeProduct(owner=owner)
         bug = self.createBug(
             owner=owner, target=target, status=BugTaskStatus.TRIAGED)
         self.assertEqual(BugTaskStatus.TRIAGED, bug.default_bugtask.status)
+        self.assertIsNot(None, bug.default_bugtask.date_triaged)
 
     def test_CreateBugParams_rejects_not_allowed_importance_changes(self):
         # createBug() will reject any importance value passed by users


Follow ups