Merge lp:~maxiberta/launchpad/app-stories-dedup-sitesearch-doctests into lp:launchpad

Proposed by Maximiliano Bertacchini
Status: Merged
Merged at revision: 18625
Proposed branch: lp:~maxiberta/launchpad/app-stories-dedup-sitesearch-doctests
Merge into: lp:launchpad
Diff against target: 128 lines (+51/-7)
3 files modified
lib/lp/app/tests/test_doc.py (+44/-1)
lib/lp/services/testing/__init__.py (+4/-3)
lib/lp/testing/pages.py (+3/-3)
To merge this branch: bzr merge lp:~maxiberta/launchpad/app-stories-dedup-sitesearch-doctests
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+343244@code.launchpad.net

Commit message

Run lp.app.stories.launchpad_search.site-search.txt on all search backends.

Description of the change

Run lp.app.stories.launchpad_search.site-search.txt on all search backends (was lp.app.stories.launchpad_root.site-search.txt).

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'lib/lp/app/stories/launchpad-search'
2=== renamed file 'lib/lp/app/stories/launchpad-root/site-search.txt' => 'lib/lp/app/stories/launchpad-search/site-search.txt'
3=== modified file 'lib/lp/app/tests/test_doc.py'
4--- lib/lp/app/tests/test_doc.py 2011-12-30 09:16:36 +0000
5+++ lib/lp/app/tests/test_doc.py 2018-04-25 15:28:22 +0000
6@@ -1,4 +1,4 @@
7-# Copyright 2010 Canonical Ltd. This software is licensed under the
8+# Copyright 2010-2018 Canonical Ltd. This software is licensed under the
9 # GNU Affero General Public License version 3 (see the file LICENSE).
10
11 """
12@@ -7,8 +7,13 @@
13
14 import os
15
16+from lp.services.features.testing import FeatureFixture
17 from lp.services.testing import build_test_suite
18 from lp.testing.layers import LaunchpadFunctionalLayer
19+from lp.testing.pages import (
20+ PageTestSuite,
21+ setUpGlobs,
22+ )
23 from lp.testing.systemdocs import (
24 LayeredDocFileSuite,
25 setUp,
26@@ -17,6 +22,29 @@
27
28
29 here = os.path.dirname(os.path.realpath(__file__))
30+bing_flag = FeatureFixture({'sitesearch.engine.name': 'bing'})
31+google_flag = FeatureFixture({'sitesearch.engine.name': 'google'})
32+
33+
34+def setUp_bing(test):
35+ setUpGlobs(test)
36+ bing_flag.setUp()
37+
38+
39+def setUp_google(test):
40+ setUpGlobs(test)
41+ google_flag.setUp()
42+
43+
44+def tearDown_bing(test):
45+ bing_flag.cleanUp()
46+ tearDown(test)
47+
48+
49+def tearDown_google(test):
50+ google_flag.cleanUp()
51+ tearDown(test)
52+
53
54 special = {
55 'tales.txt': LayeredDocFileSuite(
56@@ -27,6 +55,21 @@
57 'menus.txt': LayeredDocFileSuite(
58 '../doc/menus.txt', layer=None,
59 ),
60+ 'stories/launchpad-search(Bing)': PageTestSuite(
61+ '../stories/launchpad-search/',
62+ id_extensions=['site-search.txt(Bing)'],
63+ setUp=setUp_bing, tearDown=tearDown_bing,
64+ ),
65+ 'stories/launchpad-search(Google)': PageTestSuite(
66+ '../stories/launchpad-search/',
67+ id_extensions=['site-search.txt(Google)'],
68+ setUp=setUp_google, tearDown=tearDown_google,
69+ ),
70+ # Run these doctests again with the default search engine.
71+ '../stories/launchpad-search': PageTestSuite(
72+ '../stories/launchpad-search/',
73+ setUp=setUpGlobs, tearDown=tearDown,
74+ ),
75 }
76
77
78
79=== modified file 'lib/lp/services/testing/__init__.py'
80--- lib/lp/services/testing/__init__.py 2011-12-30 07:08:24 +0000
81+++ lib/lp/services/testing/__init__.py 2018-04-25 15:28:22 +0000
82@@ -1,4 +1,4 @@
83-# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
84+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
85 # GNU Affero General Public License version 3 (see the file LICENSE).
86
87 """
88@@ -98,11 +98,12 @@
89 if not os.path.isdir(full_story_dir):
90 continue
91 story_path = os.path.join(stories_dir, story_dir)
92+ if story_path in special_tests:
93+ continue
94 suite.addTest(PageTestSuite(story_path, package))
95
96 # Add the special doctests.
97- for key in sorted(special_tests):
98- special_suite = special_tests[key]
99+ for key, special_suite in sorted(special_tests.items()):
100 suite.addTest(special_suite)
101
102 tests_path = os.path.join(os.path.pardir, 'doc')
103
104=== modified file 'lib/lp/testing/pages.py'
105--- lib/lp/testing/pages.py 2017-10-21 18:14:14 +0000
106+++ lib/lp/testing/pages.py 2018-04-25 15:28:22 +0000
107@@ -1,4 +1,4 @@
108-# Copyright 2009-2016 Canonical Ltd. This software is licensed under the
109+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
110 # GNU Affero General Public License version 3 (see the file LICENSE).
111
112 """Testing infrastructure for page tests."""
113@@ -845,7 +845,7 @@
114 # but does follow the convention of the other doctest related *Suite()
115 # functions.
116
117-def PageTestSuite(storydir, package=None, setUp=setUpGlobs):
118+def PageTestSuite(storydir, package=None, setUp=setUpGlobs, **kw):
119 """Create a suite of page tests for files found in storydir.
120
121 :param storydir: the directory containing the page tests.
122@@ -873,5 +873,5 @@
123 suite.addTest(LayeredDocFileSuite(
124 paths=paths,
125 package=package, checker=checker, stdout_logging=False,
126- layer=PageTestLayer, setUp=setUp))
127+ layer=PageTestLayer, setUp=setUp, **kw))
128 return suite