Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 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:29:04 +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,6 +57,7 @@
  22. person_logged_in,
  23. TestCaseWithFactory,
  24. )
  25. +from lp.testing.matchers import BrowsesWithQueryLimit
  26. from lp.testing.views import create_initialized_view
  27.  
  28.  
  29. @@ -361,6 +361,28 @@
  30. self.assertTrue(
  31. bug.bugtask.status in UNRESOLVED_BUGTASK_STATUSES)
  32.  
  33. + def test_linked_bugs_branch_query_scaling(self):
  34. + # As we add linked bugs, the query count for a branch index page stays
  35. + # constant. We use a series branch to make sure we're capturing the
  36. + # overheads of shown *and* unshown bugs. Series branches only show
  37. + # open bugs, so adding bug links will add at least one new bug per
  38. + # call.
  39. + product = self.factory.makeProduct()
  40. + branch = self.factory.makeProductBranch(product=product)
  41. + browses_under_limit = BrowsesWithQueryLimit(54, branch.owner)
  42. + with person_logged_in(product.owner):
  43. + product.development_focus.branch = branch
  44. + # Start with some bugs, otherwise we might see a spurious increase
  45. + # depending on optimisations in eager loaders.
  46. + with person_logged_in(branch.owner):
  47. + self._addBugLinks(branch)
  48. + self.assertThat(branch, browses_under_limit)
  49. + with person_logged_in(branch.owner):
  50. + # Add plenty of bugs.
  51. + for _ in range(5):
  52. + self._addBugLinks(branch)
  53. + self.assertThat(branch, browses_under_limit)
  54. +
  55. def _add_revisions(self, branch, nr_revisions=1):
  56. revisions = []
  57. for seq in range(1, nr_revisions+1):
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement