~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/code/model/tests/test_branchcollection.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-09-02 01:59:36 UTC
  • mfrom: (13827.1.3 bug724025)
  • Revision ID: launchpad@pqm.canonical.com-20110902015936-3faztvdzym6qtyje
[r=jtv][bug=724025] implement some low-hanging optimizations when a
        bug has many branches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
from datetime import datetime
9
9
 
10
10
import pytz
 
11
from storm.store import EmptyResultSet
11
12
from zope.component import getUtility
12
13
from zope.security.proxy import removeSecurityProxy
13
14
 
742
743
        proposals = self.all_branches.getMergeProposals()
743
744
        self.assertEqual([], list(proposals))
744
745
 
 
746
    def test_empty_branches_shortcut(self):
 
747
        # If you explicitly pass an empty collection of branches,
 
748
        # the method shortcuts and gives you an empty result set.  In this
 
749
        # way, for_branches=None (the default) has a very different behavior
 
750
        # than for_branches=[]: the first is no restriction, while the second
 
751
        # excludes everything.
 
752
        mp = self.factory.makeBranchMergeProposal()
 
753
        proposals = self.all_branches.getMergeProposals(for_branches=[])
 
754
        self.assertEqual([], list(proposals))
 
755
        self.assertIsInstance(proposals, EmptyResultSet)
 
756
 
 
757
    def test_empty_revisions_shortcut(self):
 
758
        # If you explicitly pass an empty collection of revision numbers,
 
759
        # the method shortcuts and gives you an empty result set.  In this
 
760
        # way, merged_revnos=None (the default) has a very different behavior
 
761
        # than merged_revnos=[]: the first is no restriction, while the second
 
762
        # excludes everything.
 
763
        mp = self.factory.makeBranchMergeProposal()
 
764
        proposals = self.all_branches.getMergeProposals(merged_revnos=[])
 
765
        self.assertEqual([], list(proposals))
 
766
        self.assertIsInstance(proposals, EmptyResultSet)
 
767
 
745
768
    def test_some_branch_merge_proposals(self):
746
769
        mp = self.factory.makeBranchMergeProposal()
747
770
        proposals = self.all_branches.getMergeProposals()