~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/scripts/tests/test_garbo.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-10-06 01:24:37 UTC
  • mfrom: (14039.1.12 bug-759467)
  • Revision ID: launchpad@pqm.canonical.com-20111006012437-x4xn9cohnyp5ztlx
[r=gmb][bug=759467] [r=gmb][bug=759467] Store
 INCOMPLETE_WITH_RESPONSE and INCOMPLETE_WITHOUT_RESPONSE for BugTask status
 to make queries more efficient.

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
    ZopelessDatabaseLayer,
67
67
    )
68
68
from lp.answers.model.answercontact import AnswerContact
 
69
from lp.bugs.interfaces.bugtask import (
 
70
    BugTaskStatus,
 
71
    BugTaskStatusSearch,
 
72
    )
69
73
from lp.bugs.model.bugnotification import (
70
74
    BugNotification,
71
75
    BugNotificationRecipient,
72
76
    )
 
77
from lp.bugs.model.bugtask import BugTask
73
78
from lp.code.bzr import (
74
79
    BranchFormat,
75
80
    RepositoryFormat,
858
863
        self._test_AnswerContactPruner(
859
864
            AccountStatus.SUSPENDED, ONE_DAY_AGO, expected_count=1)
860
865
 
 
866
    def test_BugTaskIncompleteMigrator(self):
 
867
        # BugTasks with status INCOMPLETE should be either
 
868
        # INCOMPLETE_WITHOUT_RESPONSE or INCOMPLETE_WITH_RESPONSE.
 
869
        # Create a bug with two tasks set to INCOMPLETE and a comment between
 
870
        # them.
 
871
        LaunchpadZopelessLayer.switchDbUser('testadmin')
 
872
        store = IMasterStore(BugTask)
 
873
        bug = self.factory.makeBug()
 
874
        with_response = bug.bugtasks[0]
 
875
        with_response.transitionToStatus(BugTaskStatus.INCOMPLETE, bug.owner)
 
876
        removeSecurityProxy(with_response)._status = BugTaskStatus.INCOMPLETE
 
877
        transaction.commit()
 
878
        self.factory.makeBugComment(bug=bug)
 
879
        transaction.commit()
 
880
        without_response = self.factory.makeBugTask(bug=bug)
 
881
        without_response.transitionToStatus(
 
882
            BugTaskStatus.INCOMPLETE, bug.owner)
 
883
        removeSecurityProxy(without_response)._status = (
 
884
            BugTaskStatus.INCOMPLETE)
 
885
        transaction.commit()
 
886
        self.runHourly()
 
887
        self.assertEqual(
 
888
            1,
 
889
            store.find(BugTask.id,
 
890
                BugTask.id == with_response.id,
 
891
                BugTask._status ==
 
892
                       BugTaskStatusSearch.INCOMPLETE_WITH_RESPONSE).count())
 
893
        self.assertEqual(
 
894
            1,
 
895
            store.find(BugTask.id,
 
896
                BugTask.id == without_response.id,
 
897
                BugTask._status ==
 
898
                     BugTaskStatusSearch.INCOMPLETE_WITHOUT_RESPONSE).count())
 
899
 
861
900
    def test_BranchJobPruner(self):
862
901
        # Garbo should remove jobs completed over 30 days ago.
863
902
        LaunchpadZopelessLayer.switchDbUser('testadmin')