Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- === modified file 'lib/lp/code/browser/tests/test_branch.py'
- --- lib/lp/code/browser/tests/test_branch.py 2011-02-25 02:08:52 +0000
- +++ lib/lp/code/browser/tests/test_branch.py 2011-02-25 02:11:50 +0000
- @@ -19,6 +19,7 @@
- from canonical.config import config
- from canonical.database.constants import UTC_NOW
- from canonical.launchpad.helpers import truncate_text
- +from canonical.launchpad.webapp.publisher import canonical_url
- from canonical.launchpad.webapp.servers import LaunchpadTestRequest
- from canonical.testing.layers import (
- DatabaseFunctionalLayer,
- @@ -29,8 +30,6 @@
- find_tag_by_id,
- setupBrowser,
- )
- -from canonical.launchpad.webapp.publisher import canonical_url
- -
- from lp.app.interfaces.headings import IRootContext
- from lp.bugs.interfaces.bugtask import (
- BugTaskStatus,
- @@ -58,7 +57,9 @@
- person_logged_in,
- TestCaseWithFactory,
- )
- +from lp.testing.matchers import BrowsesWithQueryLimit
- from lp.testing.views import create_initialized_view
- +from lp.testing._webservice import QueryCollector
- class TestBranchMirrorHidden(TestCaseWithFactory):
- @@ -361,6 +362,28 @@
- self.assertTrue(
- bug.bugtask.status in UNRESOLVED_BUGTASK_STATUSES)
- + def test_linked_bugs_branch_query_scaling(self):
- + # As we add linked bugs, the query count for a branch index page stays
- + # constant. We use a series branch to make sure we're capturing the
- + # overheads of shown *and* unshown bugs. Series branches only show
- + # open bugs, so adding bug links will add at least one new bug per
- + # call.
- + product = self.factory.makeProduct()
- + branch = self.factory.makeProductBranch(product=product)
- + browses_under_limit = BrowsesWithQueryLimit(54, branch.owner)
- + with person_logged_in(product.owner):
- + product.development_focus.branch = branch
- + # Start with some bugs, otherwise we might see a spurious increase
- + # depending on optimisations in eager loaders.
- + with person_logged_in(branch.owner):
- + self._addBugLinks(branch)
- + self.assertThat(branch, browses_under_limit)
- + with person_logged_in(branch.owner):
- + # Add plenty of bugs.
- + for _ in range(5):
- + self._addBugLinks(branch)
- + self.assertThat(branch, browses_under_limit)
- +
- def _add_revisions(self, branch, nr_revisions=1):
- revisions = []
- for seq in range(1, nr_revisions+1):
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement