Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. === modified file 'lib/lp/code/browser/tests/test_branch.py'
  2. --- lib/lp/code/browser/tests/test_branch.py 2011-02-25 02:08:52 +0000
  3. +++ lib/lp/code/browser/tests/test_branch.py 2011-02-25 02:11:50 +0000
  4. @@ -19,6 +19,7 @@
  5. from canonical.config import config
  6. from canonical.database.constants import UTC_NOW
  7. from canonical.launchpad.helpers import truncate_text
  8. +from canonical.launchpad.webapp.publisher import canonical_url
  9. from canonical.launchpad.webapp.servers import LaunchpadTestRequest
  10. from canonical.testing.layers import (
  11. DatabaseFunctionalLayer,
  12. @@ -29,8 +30,6 @@
  13. find_tag_by_id,
  14. setupBrowser,
  15. )
  16. -from canonical.launchpad.webapp.publisher import canonical_url
  17. -
  18. from lp.app.interfaces.headings import IRootContext
  19. from lp.bugs.interfaces.bugtask import (
  20. BugTaskStatus,
  21. @@ -58,7 +57,9 @@
  22. person_logged_in,
  23. TestCaseWithFactory,
  24. )
  25. +from lp.testing.matchers import BrowsesWithQueryLimit
  26. from lp.testing.views import create_initialized_view
  27. +from lp.testing._webservice import QueryCollector
  28.  
  29.  
  30. class TestBranchMirrorHidden(TestCaseWithFactory):
  31. @@ -361,6 +362,28 @@
  32. self.assertTrue(
  33. bug.bugtask.status in UNRESOLVED_BUGTASK_STATUSES)
  34.  
  35. + def test_linked_bugs_branch_query_scaling(self):
  36. + # As we add linked bugs, the query count for a branch index page stays
  37. + # constant. We use a series branch to make sure we're capturing the
  38. + # overheads of shown *and* unshown bugs. Series branches only show
  39. + # open bugs, so adding bug links will add at least one new bug per
  40. + # call.
  41. + product = self.factory.makeProduct()
  42. + branch = self.factory.makeProductBranch(product=product)
  43. + browses_under_limit = BrowsesWithQueryLimit(54, branch.owner)
  44. + with person_logged_in(product.owner):
  45. + product.development_focus.branch = branch
  46. + # Start with some bugs, otherwise we might see a spurious increase
  47. + # depending on optimisations in eager loaders.
  48. + with person_logged_in(branch.owner):
  49. + self._addBugLinks(branch)
  50. + self.assertThat(branch, browses_under_limit)
  51. + with person_logged_in(branch.owner):
  52. + # Add plenty of bugs.
  53. + for _ in range(5):
  54. + self._addBugLinks(branch)
  55. + self.assertThat(branch, browses_under_limit)
  56. +
  57. def _add_revisions(self, branch, nr_revisions=1):
  58. revisions = []
  59. for seq in range(1, nr_revisions+1):
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement