~launchpad-pqm/launchpad/devel

6857.1.3 by Graham Binns
Driveby cleanup on bugtask-search-pages.txt.
1
= Distribution Search page =
3255.1.2 by Diogo Matsubara
Fix https://launchpad.net/products/malone/+bug/34046 (Default search shouldn't include Fix Releasedbugs)
2
3553.3.44 by Brad Bollenbach
Fix the upstream status filter widget to 1. Ensure a radio button is selected by default, 2. Clarify the wording of each option, 3. Correct one filter option to work as intended for the known use cases
3
In the 'Bugs' facet of a distribution we can find a list of bugs
4
reported in that distribution and simple and advanced search forms.
3255.1.2 by Diogo Matsubara
Fix https://launchpad.net/products/malone/+bug/34046 (Default search shouldn't include Fix Releasedbugs)
5
11716.1.6 by Curtis Hovey
Converted glob imports in doctests to import for the true module.
6
    >>> from canonical.launchpad.webapp.interfaces import IOpenLaunchBag
7
    >>> from lp.registry.interfaces.distribution import IDistributionSet
3216.2.9 by James Henstridge
test updates
8
    >>> launchbag = getUtility(IOpenLaunchBag)
3255.1.2 by Diogo Matsubara
Fix https://launchpad.net/products/malone/+bug/34046 (Default search shouldn't include Fix Releasedbugs)
9
    >>> debian = getUtility(IDistributionSet).getByName('debian')
10
3216.2.9 by James Henstridge
test updates
11
A helper function to make it easier to construct a view.  The function
12
also adds the context object to the launchbag, which approximates what
13
happens during traversal.
3255.1.2 by Diogo Matsubara
Fix https://launchpad.net/products/malone/+bug/34046 (Default search shouldn't include Fix Releasedbugs)
14
6130.2.1 by Maris Fogels
Changed all occurrances of getView and queryView to their MultiAdapter counterparts.
15
    >>> from zope.component import getMultiAdapter
3255.1.2 by Diogo Matsubara
Fix https://launchpad.net/products/malone/+bug/34046 (Default search shouldn't include Fix Releasedbugs)
16
    >>> from canonical.launchpad.webapp.servers import LaunchpadTestRequest
17
    >>> def create_view(context, name, form=None):
3216.2.9 by James Henstridge
test updates
18
    ...     launchbag.clear()
19
    ...     launchbag.add(context)
6130.2.1 by Maris Fogels
Changed all occurrances of getView and queryView to their MultiAdapter counterparts.
20
    ...     view = getMultiAdapter(
21
    ...         (context, LaunchpadTestRequest(form=form)), name=name)
3255.1.2 by Diogo Matsubara
Fix https://launchpad.net/products/malone/+bug/34046 (Default search shouldn't include Fix Releasedbugs)
22
    ...     view.initialize()
23
    ...     return view
24
25
The simple search form returns only open bugtasks.
26
27
    >>> form_values = {
28
    ...     'search': 'Search',
29
    ...     'field.searchtext': '',
3270.3.13 by Matthew Paul Thomas
Makes all except one pagetest pass. Fixes the remaining bug listing forms.
30
    ...     'field.orderby': '-importance'}
3255.1.2 by Diogo Matsubara
Fix https://launchpad.net/products/malone/+bug/34046 (Default search shouldn't include Fix Releasedbugs)
31
32
    >>> distro_search_listingview = create_view(
33
    ...     debian, "+bugs", form_values)
34
35
    >>> open_bugtasks = list(distro_search_listingview.search().batch)
3270.4.2 by Bjorn Tillenius
fix test failures in bugtask-search-pages.txt
36
    >>> [(bugtask.bug.id, bugtask.status.name, bugtask.importance.name)
37
    ...  for bugtask in open_bugtasks]
4318.3.3 by Gavin Panella
First round of status renames throughout the tree.
38
    [(3, 'NEW', 'UNKNOWN'),
3270.3.47 by Matthew Paul Thomas
Changes Minor to Low, Major to High, and restores the Priority column to the database.
39
     (1, 'CONFIRMED', 'LOW'),
40
     (2, 'CONFIRMED', 'LOW')]
3255.1.2 by Diogo Matsubara
Fix https://launchpad.net/products/malone/+bug/34046 (Default search shouldn't include Fix Releasedbugs)
41
42
And the advanced form allows us to query for specific bug statuses.
43
44
    >>> form_values = {
45
    ...     'search': 'Search bugs in Debian',
46
    ...     'advanced': 1,
3367.2.1 by Brad Bollenbach
fix bug 35075 (Bug Triagers would benifit from a way to list bugs filed without a package)
47
    ...     'field.status': 'Fix Released',
3255.1.2 by Diogo Matsubara
Fix https://launchpad.net/products/malone/+bug/34046 (Default search shouldn't include Fix Releasedbugs)
48
    ...     'field.searchtext': '',
3270.3.13 by Matthew Paul Thomas
Makes all except one pagetest pass. Fixes the remaining bug listing forms.
49
    ...     'field.orderby': '-importance'}
3255.1.2 by Diogo Matsubara
Fix https://launchpad.net/products/malone/+bug/34046 (Default search shouldn't include Fix Releasedbugs)
50
3553.3.44 by Brad Bollenbach
Fix the upstream status filter widget to 1. Ensure a radio button is selected by default, 2. Clarify the wording of each option, 3. Correct one filter option to work as intended for the known use cases
51
    >>> distro_advanced_search_listingview = create_view(
52
    ...     debian, '+bugs', form_values)
53
    >>> fix_released_bugtasks = list(
54
    ...     distro_advanced_search_listingview.search().batch)
3367.2.1 by Brad Bollenbach
fix bug 35075 (Bug Triagers would benifit from a way to list bugs filed without a package)
55
    >>> [(bugtask.bug.id, bugtask.status.name)
3255.1.2 by Diogo Matsubara
Fix https://launchpad.net/products/malone/+bug/34046 (Default search shouldn't include Fix Releasedbugs)
56
    ...     for bugtask in fix_released_bugtasks]
57
    [(8, 'FIXRELEASED')]
58
3553.3.44 by Brad Bollenbach
Fix the upstream status filter widget to 1. Ensure a radio button is selected by default, 2. Clarify the wording of each option, 3. Correct one filter option to work as intended for the known use cases
59
The advanced search page also has a widget to filter on upstream
60
status.
61
62
    >>> distro_advanced_search_listingview.shouldShowUpstreamStatusBox()
63
    True
64
3691.100.3 by Bjorn Tillenius
remove the use of ILaunchBag from MilestoneVocabulary.
65
It also allows filtering on milestones.
66
67
    >>> milestones = (
68
    ...     distro_advanced_search_listingview.getMilestoneWidgetValues())
69
    >>> for value in milestones:
70
    ...     print value['title']
8408.1.9 by Curtis Hovey
Fixed tests that were using the old milestone displayname.
71
    Debian 3.1
72
    Debian 3.1-rc1
3691.100.3 by Bjorn Tillenius
remove the use of ILaunchBag from MilestoneVocabulary.
73
74
The same milestone will be available for a debian package.
75
76
    >>> form_values = {'advanced': 1}
77
78
    >>> firefox_debian = debian.getSourcePackage('mozilla-firefox')
79
    >>> package_advanced_search_listingview = create_view(
80
    ...     firefox_debian, '+bugs', form_values)
81
    >>> milestones = (
82
    ...     package_advanced_search_listingview.getMilestoneWidgetValues())
83
    >>> for value in milestones:
84
    ...     print value['title']
8408.1.9 by Curtis Hovey
Fixed tests that were using the old milestone displayname.
85
    Debian 3.1
86
    Debian 3.1-rc1
3691.100.3 by Bjorn Tillenius
remove the use of ILaunchBag from MilestoneVocabulary.
87
3367.2.1 by Brad Bollenbach
fix bug 35075 (Bug Triagers would benifit from a way to list bugs filed without a package)
88
A triager may find it useful to query for bugs with no package:
89
90
    >>> ubuntu = getUtility(IDistributionSet).getByName('ubuntu')
91
92
    >>> form_values = {
93
    ...     'search': 'Search bugs in Ubuntu',
94
    ...     'advanced': 1,
95
    ...     'field.has_no_package': 'on',
3270.3.13 by Matthew Paul Thomas
Makes all except one pagetest pass. Fixes the remaining bug listing forms.
96
    ...     'field.orderby': '-importance'}
3367.2.1 by Brad Bollenbach
fix bug 35075 (Bug Triagers would benifit from a way to list bugs filed without a package)
97
98
    >>> distro_advanced_search_listingview = create_view(
99
    ...     ubuntu, '+bugs', form_values)
100
101
    >>> bugtasks_needing_packages = list(
102
    ...     distro_advanced_search_listingview.search().batch)
103
    >>> [bugtask.bug.id for bugtask in bugtasks_needing_packages]
104
    [2]
3255.1.2 by Diogo Matsubara
Fix https://launchpad.net/products/malone/+bug/34046 (Default search shouldn't include Fix Releasedbugs)
105
3361.1.8 by Diogo Matsubara
Fix https://launchpad.net/products/malone/+bug/39331(Malone search text field needs input validation)
106
If the search query contains new line characters they'll be replaced by
107
spaces.
108
109
    >>> form_values = {
110
    ...     'search': 'Search',
111
    ...     'field.searchtext': 'blackhole\n\rtrash\n\rfolder',
3270.3.34 by Matthew Paul Thomas
Drops priority from the code.
112
    ...     'field.orderby': '-importance'}
3361.1.8 by Diogo Matsubara
Fix https://launchpad.net/products/malone/+bug/39331(Malone search text field needs input validation)
113
114
    >>> distro_search_listingview = create_view(
115
    ...     ubuntu, '+bugs', form_values)
116
117
    >>> bugtasks_search_with_new_lines = list(
118
    ...     distro_search_listingview.search().batch)
119
    >>> [bugtask.bug.id for bugtask in bugtasks_search_with_new_lines]
120
    [2]
121
3470.1.1 by Diogo Matsubara
Fix https://launchpad.net/products/malone/+bug/33978 (Advanced search page doesn't do any input validation)
122
We can filter our search results by reporter
123
124
    >>> form_values = {
125
    ...     'search': 'Search bugs in Ubuntu',
126
    ...     'advanced': 1,
3893.2.3 by Bjorn Tillenius
fix test failure.
127
    ...     'field.bug_reporter': 'name12',
3270.3.28 by Matthew Paul Thomas
Changes severity->importance, and nukes priority display, in newly-introduced code. Places XXXes for code that should be cleaned up if/when priority is finally removed.
128
    ...     'field.orderby': '-importance'}
3470.1.1 by Diogo Matsubara
Fix https://launchpad.net/products/malone/+bug/33978 (Advanced search page doesn't do any input validation)
129
130
    >>> distro_advanced_search_listingview = create_view(
131
    ...     debian, '+bugs', form_values)
132
133
    >>> bugtasks_filtered_by_reporter = list(
134
    ...     distro_advanced_search_listingview.search().batch)
135
    >>> [(bugtask.bug.id, bugtask.bug.owner.name)
136
    ...     for bugtask in bugtasks_filtered_by_reporter]
137
    [(1, u'name12'), (2, u'name12')]
138
3553.3.44 by Brad Bollenbach
Fix the upstream status filter widget to 1. Ensure a radio button is selected by default, 2. Clarify the wording of each option, 3. Correct one filter option to work as intended for the known use cases
139
But if we query for an invalid person, the view displays a nice error
140
message.
3470.1.1 by Diogo Matsubara
Fix https://launchpad.net/products/malone/+bug/33978 (Advanced search page doesn't do any input validation)
141
142
    >>> form_values = {
143
    ...     'search': 'Search bugs in Ubuntu',
144
    ...     'advanced': 1,
3893.2.3 by Bjorn Tillenius
fix test failure.
145
    ...     'field.bug_reporter': 'invalid-reporter',
3270.3.28 by Matthew Paul Thomas
Changes severity->importance, and nukes priority display, in newly-introduced code. Places XXXes for code that should be cleaned up if/when priority is finally removed.
146
    ...     'field.orderby': '-importance'}
3470.1.1 by Diogo Matsubara
Fix https://launchpad.net/products/malone/+bug/33978 (Advanced search page doesn't do any input validation)
147
148
    >>> distro_advanced_search_listingview = create_view(
149
    ...     debian, '+bugs', form_values)
150
5243.1.1 by Jonathan Knowles
Renaming method getWidgetError (in LaunchpadFormView) to getFieldError.
151
    >>> distro_advanced_search_listingview.getFieldError('bug_reporter')
4584.2.10 by Graham Binns
Fixed bugtask-search-pages doctest
152
    u"There's no person with the name or email address 'invalid-reporter'."
3470.1.1 by Diogo Matsubara
Fix https://launchpad.net/products/malone/+bug/33978 (Advanced search page doesn't do any input validation)
153
3553.3.44 by Brad Bollenbach
Fix the upstream status filter widget to 1. Ensure a radio button is selected by default, 2. Clarify the wording of each option, 3. Correct one filter option to work as intended for the known use cases
154
The same if we try with an invalid assignee.
3470.1.1 by Diogo Matsubara
Fix https://launchpad.net/products/malone/+bug/33978 (Advanced search page doesn't do any input validation)
155
156
    >>> form_values = {
157
    ...     'search': 'Search bugs in Ubuntu',
158
    ...     'advanced': 1,
159
    ...     'field.assignee': 'invalid-assignee',
3270.3.28 by Matthew Paul Thomas
Changes severity->importance, and nukes priority display, in newly-introduced code. Places XXXes for code that should be cleaned up if/when priority is finally removed.
160
    ...     'field.orderby': '-importance'}
3470.1.1 by Diogo Matsubara
Fix https://launchpad.net/products/malone/+bug/33978 (Advanced search page doesn't do any input validation)
161
162
    >>> distro_advanced_search_listingview = create_view(
163
    ...     debian, '+bugs', form_values)
164
5243.1.1 by Jonathan Knowles
Renaming method getWidgetError (in LaunchpadFormView) to getFieldError.
165
    >>> distro_advanced_search_listingview.getFieldError('assignee')
4584.2.10 by Graham Binns
Fixed bugtask-search-pages doctest
166
    u"There's no person with the name or email address 'invalid-assignee'."
3470.1.1 by Diogo Matsubara
Fix https://launchpad.net/products/malone/+bug/33978 (Advanced search page doesn't do any input validation)
167
3485.6.5 by Brad Bollenbach
hide the component search widget when IDistribution.currentrelease is None
168
Searching by component is possible, as long as the context has defined a
4285.2.1 by Mark Shuttleworth
Massive renaming of distrorelease to distroseries
169
.currentseries.
3485.6.5 by Brad Bollenbach
hide the component search widget when IDistribution.currentrelease is None
170
171
    >>> form_values = {
172
    ...     'search': 'Search bugs in Ubuntu',
173
    ...     'advanced': 1,
174
    ...     'field.component': 1,
3270.3.34 by Matthew Paul Thomas
Drops priority from the code.
175
    ...     'field.orderby': '-importance'}
3485.6.5 by Brad Bollenbach
hide the component search widget when IDistribution.currentrelease is None
176
177
    >>> distro_advanced_search_listingview = create_view(
178
    ...     ubuntu, '+bugs', form_values)
179
180
    >>> distro_advanced_search_listingview.shouldShowComponentWidget()
181
    True
182
183
    >>> found_bugs = list(distro_advanced_search_listingview.search().batch)
184
185
    >>> sorted([bug.id for bug in found_bugs])
186
    [25]
187
4285.2.1 by Mark Shuttleworth
Massive renaming of distrorelease to distroseries
188
If the context does *not* have a currentseries, component searching is
3485.6.5 by Brad Bollenbach
hide the component search widget when IDistribution.currentrelease is None
189
ambiguous, because a package may be published in a different component
4285.2.1 by Mark Shuttleworth
Massive renaming of distrorelease to distroseries
190
in each series. In this case, the component search widget is hidden.
3485.6.5 by Brad Bollenbach
hide the component search widget when IDistribution.currentrelease is None
191
192
    >>> gentoo = getUtility(IDistributionSet).getByName('gentoo')
193
194
    >>> form_values = {
195
    ...     'search': 'Search bugs in Gentoo',
196
    ...     'advanced': 1,
197
    ...     'field.component': 1,
3270.3.34 by Matthew Paul Thomas
Drops priority from the code.
198
    ...     'field.orderby': '-importance'}
3485.6.5 by Brad Bollenbach
hide the component search widget when IDistribution.currentrelease is None
199
200
    >>> distro_advanced_search_listingview = create_view(
201
    ...     gentoo, '+bugs', form_values)
202
203
    >>> distro_advanced_search_listingview.shouldShowComponentWidget()
204
    False
205
6857.1.3 by Graham Binns
Driveby cleanup on bugtask-search-pages.txt.
206
207
== Distribution Series search page ==
3255.1.2 by Diogo Matsubara
Fix https://launchpad.net/products/malone/+bug/34046 (Default search shouldn't include Fix Releasedbugs)
208
4285.2.1 by Mark Shuttleworth
Massive renaming of distrorelease to distroseries
209
    >>> sarge = debian.getSeries('sarge')
3255.1.2 by Diogo Matsubara
Fix https://launchpad.net/products/malone/+bug/34046 (Default search shouldn't include Fix Releasedbugs)
210
211
The simple search form returns only open bugtasks.
212
213
    >>> form_values = {
214
    ...     'search': 'Search',
215
    ...     'field.searchtext': '',
3270.3.13 by Matthew Paul Thomas
Makes all except one pagetest pass. Fixes the remaining bug listing forms.
216
    ...     'field.orderby': '-importance'}
3255.1.2 by Diogo Matsubara
Fix https://launchpad.net/products/malone/+bug/34046 (Default search shouldn't include Fix Releasedbugs)
217
4285.2.1 by Mark Shuttleworth
Massive renaming of distrorelease to distroseries
218
    >>> distroseries_search_listingview = create_view(
3979.1.9 by Guilherme Salgado
Fix some tests and add all_milestones properties for DistroRelease/ProductSeries
219
    ...     sarge, "+bugs", form_values)
3255.1.2 by Diogo Matsubara
Fix https://launchpad.net/products/malone/+bug/34046 (Default search shouldn't include Fix Releasedbugs)
220
4285.2.1 by Mark Shuttleworth
Massive renaming of distrorelease to distroseries
221
    >>> open_bugtasks = list(distroseries_search_listingview.search().batch)
3504.1.45 by kiko
Fix test bustage caused by new and unique ordering semantics
222
    >>> [(bugtask.id, bugtask.bug.id, bugtask.status.name, bugtask.importance.name)
3270.4.2 by Bjorn Tillenius
fix test failures in bugtask-search-pages.txt
223
    ...  for bugtask in open_bugtasks]
4318.3.3 by Gavin Panella
First round of status renames throughout the tree.
224
    [(19, 3, 'NEW', 'MEDIUM')]
3504.1.45 by kiko
Fix test bustage caused by new and unique ordering semantics
225
226
Note that because we are not in a package context, the ordering was done
227
by BugTask.id and not Bug.id -- Bug IDs are not unique in the
228
distribution context.
3255.1.2 by Diogo Matsubara
Fix https://launchpad.net/products/malone/+bug/34046 (Default search shouldn't include Fix Releasedbugs)
229
3553.3.44 by Brad Bollenbach
Fix the upstream status filter widget to 1. Ensure a radio button is selected by default, 2. Clarify the wording of each option, 3. Correct one filter option to work as intended for the known use cases
230
And now we'll change the status of one of the bugtasks, but first we
231
need to be logged in.
3255.1.5 by Diogo Matsubara
fix broken tests
232
11716.1.12 by Curtis Hovey
Sorted imports in doctests.
233
    >>> from canonical.database.sqlbase import flush_database_updates
3255.1.2 by Diogo Matsubara
Fix https://launchpad.net/products/malone/+bug/34046 (Default search shouldn't include Fix Releasedbugs)
234
    >>> from canonical.launchpad.ftests import login
235
236
    >>> login("test@canonical.com")
11666.3.1 by Curtis Hovey
Merged apocalypse-0 into this branch to fix translations and codehosting.
237
11692.6.2 by Curtis Hovey
Use deglober to fixing simple glob imports in doctests.
238
    >>> from lp.bugs.interfaces.bugtask import BugTaskStatus, IBugTaskSet
3979.1.9 by Guilherme Salgado
Fix some tests and add all_milestones properties for DistroRelease/ProductSeries
239
    >>> open_bugtask = getUtility(IBugTaskSet).get(19)
3270.4.2 by Bjorn Tillenius
fix test failures in bugtask-search-pages.txt
240
    >>> open_bugtask.status.name
4318.3.3 by Gavin Panella
First round of status renames throughout the tree.
241
    'NEW'
3270.4.2 by Bjorn Tillenius
fix test failures in bugtask-search-pages.txt
242
    >>> open_bugtask.bug.id
243
    3
4318.3.11 by Gavin Panella
Changing transitionToStatus to accept user argument, part 2.
244
    >>> open_bugtask.transitionToStatus(
245
    ...     BugTaskStatus.INVALID, getUtility(ILaunchBag).user)
3255.1.5 by Diogo Matsubara
fix broken tests
246
    >>> flush_database_updates()
3255.1.2 by Diogo Matsubara
Fix https://launchpad.net/products/malone/+bug/34046 (Default search shouldn't include Fix Releasedbugs)
247
248
And the advanced form allows us to query for specific bug statuses.
249
250
    >>> form_values = {
3979.1.9 by Guilherme Salgado
Fix some tests and add all_milestones properties for DistroRelease/ProductSeries
251
    ...     'search': 'Search bugs in sarge',
3255.1.2 by Diogo Matsubara
Fix https://launchpad.net/products/malone/+bug/34046 (Default search shouldn't include Fix Releasedbugs)
252
    ...     'advanced': 1,
4318.3.3 by Gavin Panella
First round of status renames throughout the tree.
253
    ...     'field.status': 'Invalid',
3255.1.2 by Diogo Matsubara
Fix https://launchpad.net/products/malone/+bug/34046 (Default search shouldn't include Fix Releasedbugs)
254
    ...     'field.searchtext': '',
3270.3.13 by Matthew Paul Thomas
Makes all except one pagetest pass. Fixes the remaining bug listing forms.
255
    ...     'field.orderby': '-importance'}
3255.1.2 by Diogo Matsubara
Fix https://launchpad.net/products/malone/+bug/34046 (Default search shouldn't include Fix Releasedbugs)
256
4285.2.1 by Mark Shuttleworth
Massive renaming of distrorelease to distroseries
257
    >>> distroseries_advanced_search_view = create_view(
3979.1.9 by Guilherme Salgado
Fix some tests and add all_milestones properties for DistroRelease/ProductSeries
258
    ...     sarge, '+bugs', form_values)
4318.3.3 by Gavin Panella
First round of status renames throughout the tree.
259
    >>> invalid_bugtasks = list(
4285.2.1 by Mark Shuttleworth
Massive renaming of distrorelease to distroseries
260
    ...     distroseries_advanced_search_view.search().batch)
3367.2.1 by Brad Bollenbach
fix bug 35075 (Bug Triagers would benifit from a way to list bugs filed without a package)
261
    >>> [(bugtask.bug.id, bugtask.status.name)
4318.3.3 by Gavin Panella
First round of status renames throughout the tree.
262
    ...     for bugtask in invalid_bugtasks]
263
    [(3, 'INVALID')]
3216.2.9 by James Henstridge
test updates
264
3553.3.44 by Brad Bollenbach
Fix the upstream status filter widget to 1. Ensure a radio button is selected by default, 2. Clarify the wording of each option, 3. Correct one filter option to work as intended for the known use cases
265
The upstream status widget is also present here.
266
4285.2.1 by Mark Shuttleworth
Massive renaming of distrorelease to distroseries
267
    >>> distroseries_advanced_search_view.shouldShowUpstreamStatusBox()
3553.3.44 by Brad Bollenbach
Fix the upstream status filter widget to 1. Ensure a radio button is selected by default, 2. Clarify the wording of each option, 3. Correct one filter option to work as intended for the known use cases
268
    True
3216.2.9 by James Henstridge
test updates
269
3979.1.9 by Guilherme Salgado
Fix some tests and add all_milestones properties for DistroRelease/ProductSeries
270
There are no milestones to filter on, since sarge doesn't have any
3691.100.3 by Bjorn Tillenius
remove the use of ILaunchBag from MilestoneVocabulary.
271
milestones.
272
4285.2.1 by Mark Shuttleworth
Massive renaming of distrorelease to distroseries
273
    >>> distroseries_advanced_search_view.getMilestoneWidgetValues()
3691.100.3 by Bjorn Tillenius
remove the use of ILaunchBag from MilestoneVocabulary.
274
    []
275
3979.1.9 by Guilherme Salgado
Fix some tests and add all_milestones properties for DistroRelease/ProductSeries
276
The same is true for a sarge package.
3691.100.3 by Bjorn Tillenius
remove the use of ILaunchBag from MilestoneVocabulary.
277
278
    >>> form_values = {'advanced': 1}
3979.1.9 by Guilherme Salgado
Fix some tests and add all_milestones properties for DistroRelease/ProductSeries
279
    >>> firefox_sarge = sarge.getSourcePackage('mozilla-firefox')
3691.100.3 by Bjorn Tillenius
remove the use of ILaunchBag from MilestoneVocabulary.
280
    >>> package_advanced_search_view = create_view(
3979.1.9 by Guilherme Salgado
Fix some tests and add all_milestones properties for DistroRelease/ProductSeries
281
    ...     firefox_sarge, '+bugs', form_values)
3691.100.3 by Bjorn Tillenius
remove the use of ILaunchBag from MilestoneVocabulary.
282
    >>> package_advanced_search_view.getMilestoneWidgetValues()
283
    []
284
6857.1.3 by Graham Binns
Driveby cleanup on bugtask-search-pages.txt.
285
10724.1.1 by Henning Eggers
First batch of Project -> ProjectGrpoup renamings.
286
== ProjectGroup Search Page ==
3216.2.9 by James Henstridge
test updates
287
11692.6.2 by Curtis Hovey
Use deglober to fixing simple glob imports in doctests.
288
    >>> from lp.registry.interfaces.projectgroup import IProjectGroupSet
10326.1.1 by Henning Eggers
Mechanically renamed IProject* to IProjectGroup*.
289
    >>> mozilla = getUtility(IProjectGroupSet).getByName('mozilla')
3216.2.9 by James Henstridge
test updates
290
291
The simple search form returns only open bugtasks.
292
293
    >>> form_values = {
294
    ...     'search': 'Search',
295
    ...     'field.searchtext': '',
3270.3.28 by Matthew Paul Thomas
Changes severity->importance, and nukes priority display, in newly-introduced code. Places XXXes for code that should be cleaned up if/when priority is finally removed.
296
    ...     'field.orderby': '-importance'}
3216.2.9 by James Henstridge
test updates
297
298
    >>> mozilla_search_listingview = create_view(
299
    ...     mozilla, "+bugs", form_values)
300
301
    >>> open_bugtasks = list(mozilla_search_listingview.search().batch)
302
    >>> for bugtask in open_bugtasks:
303
    ...     print bugtask.bug.id, bugtask.product.name, bugtask.status.name
5292.4.29 by Graham Binns
Fixed the errors in bugtask-search-pages.txt caused by sampledata changes.
304
    15 thunderbird NEW
4318.3.3 by Gavin Panella
First round of status renames throughout the tree.
305
    5 firefox NEW
306
    4 firefox NEW
307
    1 firefox NEW
3216.2.9 by James Henstridge
test updates
308
309
And now we'll change the status of one of the bugtasks (we are still
310
logged in from earlier):
311
3554.1.6 by Brad Bollenbach
Fix bug 33882 (Critical bugs are listed as 8 in the side bar, but there actually aren't any)
312
    >>> previous_status = open_bugtasks[0].status
4318.3.11 by Gavin Panella
Changing transitionToStatus to accept user argument, part 2.
313
    >>> open_bugtasks[0].transitionToStatus(
314
    ...     BugTaskStatus.INVALID, getUtility(ILaunchBag).user)
3216.2.9 by James Henstridge
test updates
315
    >>> flush_database_updates()
316
317
And the advanced form allows us to query for specific bug statuses.
318
319
    >>> form_values = {
320
    ...     'search': 'Search bugs in the Mozilla Project',
321
    ...     'advanced': 1,
4318.3.3 by Gavin Panella
First round of status renames throughout the tree.
322
    ...     'field.status': 'Invalid',
3216.2.9 by James Henstridge
test updates
323
    ...     'field.searchtext': '',
3270.3.28 by Matthew Paul Thomas
Changes severity->importance, and nukes priority display, in newly-introduced code. Places XXXes for code that should be cleaned up if/when priority is finally removed.
324
    ...     'field.orderby': '-importance'}
3216.2.9 by James Henstridge
test updates
325
326
    >>> mozilla_search_listingview = create_view(mozilla, '+bugs', form_values)
4318.3.3 by Gavin Panella
First round of status renames throughout the tree.
327
    >>> invalid_bugtasks = list(mozilla_search_listingview.search().batch)
328
    >>> for bugtask in invalid_bugtasks:
3216.2.9 by James Henstridge
test updates
329
    ...     print bugtask.bug.id, bugtask.product.name, bugtask.status.name
5292.4.29 by Graham Binns
Fixed the errors in bugtask-search-pages.txt caused by sampledata changes.
330
    15 thunderbird INVALID
3216.2.9 by James Henstridge
test updates
331
4318.3.14 by Gavin Panella
Changing transitionToStatus to accept user argument, part 4.
332
    >>> open_bugtasks[0].transitionToStatus(
333
    ...     previous_status, getUtility(ILaunchBag).user)
3554.1.6 by Brad Bollenbach
Fix bug 33882 (Critical bugs are listed as 8 in the side bar, but there actually aren't any)
334
    >>> flush_database_updates()
335
3553.3.44 by Brad Bollenbach
Fix the upstream status filter widget to 1. Ensure a radio button is selected by default, 2. Clarify the wording of each option, 3. Correct one filter option to work as intended for the known use cases
336
This view does *not* render the upstream status widget.
337
338
    >>> mozilla_search_listingview.shouldShowUpstreamStatusBox()
339
    False
340
3216.2.9 by James Henstridge
test updates
341
Check what milestones are displayed on the advanced search form:
342
3470.1.1 by Diogo Matsubara
Fix https://launchpad.net/products/malone/+bug/33978 (Advanced search page doesn't do any input validation)
343
    >>> form_values = {
344
    ...     'advanced': 1}
345
3216.2.9 by James Henstridge
test updates
346
    >>> advanced_search_view = create_view(
3470.1.1 by Diogo Matsubara
Fix https://launchpad.net/products/malone/+bug/33978 (Advanced search page doesn't do any input validation)
347
    ...     mozilla, '+bugs', form_values)
3216.2.9 by James Henstridge
test updates
348
    >>> for value in advanced_search_view.getMilestoneWidgetValues():
349
    ...     print value['title']
8408.1.9 by Curtis Hovey
Fixed tests that were using the old milestone displayname.
350
    Mozilla Firefox 1.0
351
3216.2.9 by James Henstridge
test updates
352
6857.1.4 by Graham Binns
get_buglisting_search_filter_url() now takes a status_upstream parameter for convenience.
353
== Constructing search filter urls ==
354
355
There is a helper method, get_buglisting_search_filter_url(), which can
356
be used to construct bug search URLs. It takes keyword parameters for
357
the assignee, importance, status and status_upstream fields of a bug
358
search and returns the correct URL for a bug listing with those
359
parameters. The URL returned isn't tied to any specific bugtarget, so
360
it's up to the callsite to urljoin() the results of
361
get_buglisting_search_filter_url() with a bugtarget URL to make it
362
useful.
363
8565.1.2 by Bjorn Tillenius
Fix test failures.
364
    >>> from lp.bugs.browser.bugtask import (
6857.1.4 by Graham Binns
get_buglisting_search_filter_url() now takes a status_upstream parameter for convenience.
365
    ...     get_buglisting_search_filter_url)
366
367
Calling get_buglisting_search_filter_url() without any parameters will
368
return a plain search URL which, when visited, will display all open
369
bugs.
370
371
    >>> print get_buglisting_search_filter_url()
372
    +bugs?search=Search
373
374
Passing an assignee will add an assignee field to the query string. Not
375
that get_buglisting_search_filter_url() doesn't check any of the data
376
that's passed to it; that's for the target search to do.
377
378
    >>> print get_buglisting_search_filter_url(assignee='gmb')
379
    +bugs?search=Search&field.assignee=gmb
380
381
Passing an importance will add an importance field to the query string.
382
383
    >>> print get_buglisting_search_filter_url(importance='UNDECIDED')
384
    +bugs?search=Search&field.importance=UNDECIDED
385
386
Importance can be a single item or a list of items:
387
388
    >>> print get_buglisting_search_filter_url(importance=['LOW', 'HIGH'])
389
    +bugs?search=Search&field.importance=LOW&field.importance=HIGH
390
391
Passing a status will add a status field to the query string:
392
393
    >>> print get_buglisting_search_filter_url(status='TRIAGED')
394
    +bugs?search=Search&field.status=TRIAGED
395
396
Status, like importance, can be a list:
397
398
    >>> print get_buglisting_search_filter_url(status=['NEW', 'INCOMPLETE'])
399
    +bugs?search=Search&field.status=NEW&field.status=INCOMPLETE
400
401
Passing a status_upstream parameter will add a status_upstream field to
402
the query string.
403
404
    >>> print get_buglisting_search_filter_url(
405
    ...     status_upstream='open_upstream')
406
    +bugs?search=Search&field.status_upstream=open_upstream
407
408
The fields will always be rendered in the order assignee, importance,
409
status, status_upstream, regardless of what order they're passed to
410
get_buglisting_search_filter_url().
411
412
    >>> print get_buglisting_search_filter_url(
413
    ...     status_upstream='open_upstream', status='NEW',
9105.3.1 by Brad Crittenden
Changed sample data to remove sabdfl.
414
    ...     importance='WISHLIST', assignee='mark')
415
    +bugs?search=Search&field.assignee=mark&field.importance=WISHLIST&field.status=NEW&field.status_upstream=open_upstream
6857.1.4 by Graham Binns
get_buglisting_search_filter_url() now takes a status_upstream parameter for convenience.
416