← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~gmb/launchpad/bug-974608 into lp:launchpad

 

Graham Binns has proposed merging lp:~gmb/launchpad/bug-974608 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #974608 in Launchpad itself: "bugtask-find-similar.txt fails intemittently on paralleltest runs"
  https://bugs.launchpad.net/launchpad/+bug/974608

For more details, see:
https://code.launchpad.net/~gmb/launchpad/bug-974608/+merge/101975

This branch removes all the sampledata dependencies bugtask-find-similar.txt. Sampledata appears to be causing us some problems with parallel testing, and we shouldn't be using it anyway, so I removed it from this test. I was very tempted to turn it into a bunch of unit tests, but that's a problem for another day. 
-- 
https://code.launchpad.net/~gmb/launchpad/bug-974608/+merge/101975
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~gmb/launchpad/bug-974608 into lp:launchpad.
=== modified file 'lib/lp/bugs/doc/bugtask-find-similar.txt'
--- lib/lp/bugs/doc/bugtask-find-similar.txt	2012-04-04 05:46:26 +0000
+++ lib/lp/bugs/doc/bugtask-find-similar.txt	2012-04-13 21:10:24 +0000
@@ -15,11 +15,10 @@
     >>> from lp.bugs.interfaces.bugtask import IBugTaskSet
     >>> from lp.registry.interfaces.person import IPersonSet
     >>> from lp.registry.interfaces.product import IProductSet
-    >>> firefox = getUtility(IProductSet).getByName('firefox')
-    >>> sample_person = getUtility(IPersonSet).getByEmail(
-    ...     'test@xxxxxxxxxxxxx')
+    >>> test_product = factory.makeProduct()
+    >>> test_person = factory.makePerson()
     >>> similar_bugs = getUtility(IBugTaskSet).findSimilar(
-    ...     sample_person, '', product=firefox)
+    ...     test_person, '', product=test_product)
     >>> similar_bugs.count()
     0
 
@@ -28,51 +27,72 @@
 
 
     >>> similar_bugs = getUtility(IBugTaskSet).findSimilar(
-    ...     sample_person, 'nosimilarbugs', product=firefox)
+    ...     test_person, 'nosimilarbugs', product=test_product)
     >>> similar_bugs.count()
     0
 
 Now, let's enter a real bug summary, which doesn't match any other
 exactly. We can see that it still manages to find a bug.
 
+    >>> test_bug = factory.makeBug(
+    ...     product=test_product, title="SVG doesn't work")
+
     >>> similar_bugs = getUtility(IBugTaskSet).findSimilar(
-    ...     sample_person, "Can't display SVG", product=firefox)
+    ...     test_person, "Can't display SVG", product=test_product)
     >>> for bugtask in similar_bugs:
     ...     print bugtask.bug.title
-    Firefox does not support SVG
-
-
-Above we specified that only bugs against Firefox should be searched. If
-we specify Evolution, no bugs will be returned, since no similar bugs
-are found there.
-
-    >>> evolution = getUtility(IProductSet).getByName('evolution')
+    SVG doesn't work
+
+
+Above we specified that only bugs against test_product should be
+searched. If we specify a different product, no bugs will be returned,
+since no similar bugs are found there.
+
+    >>> another_product = factory.makeProduct()
     >>> similar_bugs = getUtility(IBugTaskSet).findSimilar(
-    ...     sample_person, "Can't display SVG", product=evolution)
+    ...     test_person, "Can't display SVG", product=another_product)
     >>> similar_bugs.count()
     0
 
 We can also search for distribution bugs:
 
+    >>> test_distroseries = factory.makeDistroSeries()
+    >>> test_distro = test_distroseries.distribution
+    >>> test_package = factory.makeSourcePackage(
+    ...     distroseries=test_distroseries)
+    >>> distro_bug_1 = factory.makeBug(
+    ...     distribution=test_distro,
+    ...     series=test_distroseries,
+    ...     sourcepackagename=test_package.sourcepackagename,
+    ...     title="Nothing to do with cheese or sandwiches")
+    >>> distro_bug_2 = factory.makeBug(
+    ...     distribution=test_distro,
+    ...     series=test_distroseries,
+    ...     sourcepackagename=test_package.sourcepackagename,
+    ...     title="A bug about sandwiches")
+    >>> distro_bug_2 = factory.makeBug(
+    ...     distribution=test_distro,
+    ...     series=test_distroseries,
+    ...     sourcepackagename=test_package.sourcepackagename,
+    ...     title="This cheese sandwich should show up")
 
-    >>> from lp.registry.interfaces.distribution import IDistributionSet
-    >>> ubuntu = getUtility(IDistributionSet).getByName('ubuntu')
     >>> similar_bugs = getUtility(IBugTaskSet).findSimilar(
-    ...     sample_person, "Thunderbird SVG",
-    ...     distribution=ubuntu)
+    ...     test_person, "sandwiches",
+    ...     distribution=test_distro)
     >>> for bugtask in similar_bugs:
     ...     print bugtask.bug.title
-    Firefox does not support SVG
-    Thunderbird crashes
+    Nothing to do with cheese or sandwiches
+    A bug about sandwiches
+    This cheese sandwich should show up
 
 As well as limiting it to a specific source package:
 
-
-    >>> ubuntu_thunderbird = ubuntu.getSourcePackage('thunderbird')
+    >>> another_package = factory.makeSourcePackage(
+    ...     distroseries=test_distroseries)
     >>> similar_bugs = getUtility(IBugTaskSet).findSimilar(
-    ...     sample_person, "Can't display SVG",
-    ...     distribution=ubuntu,
-    ...     sourcepackagename=ubuntu_thunderbird.sourcepackagename)
+    ...     test_person, "Any cheese sandwiches?",
+    ...     distribution=test_distro,
+    ...     sourcepackagename=another_package.sourcepackagename)
     >>> similar_bugs.count()
     0
 
@@ -81,39 +101,34 @@
 ------------
 
 Only bugs that the user has access to view will be searched. If we set
-the Firefox bug to private, and repeat the search as a user who isn't
-allowed to view it, only the Thunderbird bug will be returned this time.
+one of our distro bugs to private, and repeat the search as a user who
+isn't allowed to view it, only the public bugs will show up.
 
     >>> from lp.bugs.interfaces.bug import IBugSet
     >>> login('test@xxxxxxxxxxxxx')
-    >>> firefox_svg_bug = getUtility(IBugSet).get(1)
-    >>> firefox_svg_bug.setPrivate(True, getUtility(ILaunchBag).user)
+    >>> distro_bug_1.setPrivate(True, distro_bug_1.owner)
     True
 
-    >>> from lp.services.webapp.authorization import check_permission
-    >>> login('no-priv@xxxxxxxxxxxxx')
-    >>> check_permission('launchpad.View', firefox_svg_bug)
-    False
-    >>> no_priv = getUtility(ILaunchBag).user
+    >>> another_user = factory.makePerson()
     >>> similar_bugs = getUtility(IBugTaskSet).findSimilar(
-    ...     no_priv, "Thunderbird SVG",
-    ...     distribution=ubuntu)
+    ...     another_user, "sandwiches",
+    ...     distribution=test_distro)
     >>> for bugtask in similar_bugs:
     ...     print bugtask.bug.title
-    Thunderbird crashes
+    A bug about sandwiches
+    This cheese sandwich should show up
 
-    >>> login('test@xxxxxxxxxxxxx')
-    >>> firefox_svg_bug.setPrivate(False, getUtility(ILaunchBag).user)
+    >>> distro_bug_1.setPrivate(False, distro_bug_1.owner)
     True
 
 Ordering of search results
 --------------------------
 
 Since the search uses OR to match bugs against the entered phrase, many
-bugs will be returned by a search. Since we usually want to display on
-a few number of bugs to the user, it's important that the results are
-ordered in a way that the bugs matching the phrase best are first in the
-list.
+bugs will be returned by a search. Since we usually want to display only
+a few potential duplicates to the user, it's important that the results
+are ordered in a way that the bugs matching the phrase best are first in
+the list.
 
 When searching for similar bugs, the results are ordered by ranking the
 results of the fulltext search on the Bug table, so bugs that have a
@@ -123,20 +138,20 @@
 has been narrowed - see bug 612384.
 
     >>> similar_bugs = getUtility(IBugTaskSet).findSimilar(
-    ...     sample_person, "Another test bug for Thunderbird",
-    ...     distribution=ubuntu)
+    ...     test_person, "cheese sandwiches show",
+    ...     distribution=test_distro)
     >>> for bugtask in similar_bugs:
     ...     print bugtask.bug.title
-    another test bug
-    >>> #Thunderbird crashes
+    This cheese sandwich should show up
 
     >>> similar_bugs = getUtility(IBugTaskSet).findSimilar(
-    ...     sample_person, "Another Thunderbird crash",
-    ...     distribution=ubuntu)
+    ...     test_person, "Nothing sandwich",
+    ...     distribution=test_distro)
     >>> for bugtask in similar_bugs:
     ...     print bugtask.bug.title
-    Thunderbird crashes
-    >>> #another test bug
+    Nothing to do with cheese or sandwiches
+    A bug about sandwiches
+    This cheese sandwich should show up
 
 
 Not returning the same bug
@@ -147,13 +162,14 @@
 
     >>> orig_bug = factory.makeBug(
     ...     title="So you walk into this restaurant",
-    ...     owner=firefox.owner, product=firefox)
+    ...     owner=test_product.owner, product=test_product)
 
     >>> dupe_bug = factory.makeBug(
     ...     title="So you walk into this restaurant",
-    ...     owner=firefox.owner, product=firefox)
+    ...     owner=test_product.owner, product=test_product)
     >>> dupe_bug.markAsDuplicate(orig_bug)
 
-    >>> similar_bugs = orig_bug.default_bugtask.findSimilarBugs(firefox.owner)
+    >>> similar_bugs = orig_bug.default_bugtask.findSimilarBugs(
+    ...     test_product.owner)
     >>> orig_bug in similar_bugs
     False