~launchpad-pqm/launchpad/devel

4621.5.1 by Curtis Hovey
Started the bugtask-expiration test.
1
= Bugtask Expiration =
2
5020.2.6 by Curtis Hovey
Removed the word 'Malone' from bug expiration.
3
Old unattended Incomplete bugtasks clutter the search results of
4
Launchpad Bugs making the bug staff's job difficult. A script is run
5
daily to locate unattended Incomplete bugtasks that have not been
10680.2.1 by Abel Deuring
Add a new bug task status 'Expired'; the bug task expiration script sets expired bug tasks to this status; related adjustments to the bug task views
6
updated in 2 months, and sets their status to Expired. Only bugtasks
5020.2.6 by Curtis Hovey
Removed the word 'Malone' from bug expiration.
7
for projects that use Launchpad to track bugs and have
5283.1.1 by Curtis Hovey
Restored the enable_bug_expiration UI. The can_expire code needs updating.
8
enable_bug_expiration set to True will be expired; this rule does not
5020.2.6 by Curtis Hovey
Removed the word 'Malone' from bug expiration.
9
apply to Bugs imported from upstream bug trackers. The preconditions
10
are:
4621.5.1 by Curtis Hovey
Started the bugtask-expiration test.
11
5283.1.1 by Curtis Hovey
Restored the enable_bug_expiration UI. The can_expire code needs updating.
12
1. The bugtask belongs to a project with enable_bug_expiration is True.
5020.1.5 by Curtis Hovey
Revises the narrative of the test.
13
2. The bugtask has the status Incomplete.
5020.1.13 by Curtis Hovey
Revisions per review.
14
3. The last update of the bug is older than 60 days.
5020.1.5 by Curtis Hovey
Revises the narrative of the test.
15
4. The bug is not a duplicate.
5418.1.1 by Curtis Hovey
Fix findExpirableBugTasks() by adding a derived table that contains
16
5. The bug does not have any other valid bugtasks.
17
6. The bugtask is not assigned to anyone.
18
7. The bugtask does not have a milestone.
4621.5.1 by Curtis Hovey
Started the bugtask-expiration test.
19
10680.2.1 by Abel Deuring
Add a new bug task status 'Expired'; the bug task expiration script sets expired bug tasks to this status; related adjustments to the bug task views
20
Bugtasks cannot transition to Expired automatically unless they meet
4621.5.5 by Curtis Hovey
Basic functionality for expiring bugs is complete.
21
all the rules stated above.
4621.5.2 by Curtis Hovey
Added cronscripts/expire-bugtask.py
22
5020.1.5 by Curtis Hovey
Revises the narrative of the test.
23
5020.1.6 by Curtis Hovey
Revised the narrative of the test.
24
== findExpirableBugTasks() Part 1 ==
25
26
BugTaskSet provides findExpirableBugTasks() to find bugtasks that
27
qualify for expiration. The bugtasks must must meet all the
28
preconditions stated in this tests introduction.
29
30
findExpirableBugTasks() requires a parameter for the minimum days old
31
(min_days_old) that the bugtask has been in the unattended Incomplete
5565.6.3 by Bjorn Tillenius
make the user parameter to findExpirableBugtasks() required. make all callsites specify it.
32
status. It also requires specifying the user that is doing the search.
5020.1.5 by Curtis Hovey
Revises the narrative of the test.
33
11716.1.15 by Curtis Hovey
Fixed multiline import statements in doctests.
34
    >>> from lp.bugs.interfaces.bugtask import (
11716.1.12 by Curtis Hovey
Sorted imports in doctests.
35
    ...     BugTaskStatus,
36
    ...     IBugTaskSet,
37
    ...     )
5821.5.4 by James Henstridge
Make doc/bugtask-expiration.txt almost pass -- line 182 is still
38
    >>> from storm.store import Store
5020.1.3 by Curtis Hovey
Merged the findExpirableBugTasks and bug-expiration script tests.
39
    >>> bugtaskset = getUtility(IBugTaskSet)
4621.5.2 by Curtis Hovey
Added cronscripts/expire-bugtask.py
40
5020.1.3 by Curtis Hovey
Merged the findExpirableBugTasks and bug-expiration script tests.
41
    >>> expirable_bugtasks = bugtaskset.findExpirableBugTasks()
42
    Traceback (most recent call last):
43
    ...
5565.6.3 by Bjorn Tillenius
make the user parameter to findExpirableBugtasks() required. make all callsites specify it.
44
    TypeError: findExpirableBugTasks() takes at least 3 arguments (1 given)
5020.1.3 by Curtis Hovey
Merged the findExpirableBugTasks and bug-expiration script tests.
45
5020.1.6 by Curtis Hovey
Revised the narrative of the test.
46
Looking back 9,999 days, findExpirableBugTasks() reports that there are
47
no expirable bugtasks in the sampledata.
5020.1.3 by Curtis Hovey
Merged the findExpirableBugTasks and bug-expiration script tests.
48
5565.6.3 by Bjorn Tillenius
make the user parameter to findExpirableBugtasks() required. make all callsites specify it.
49
    >>> expirable_bugtasks = bugtaskset.findExpirableBugTasks(9999, None)
5781.1.1 by Bjorn Tillenius
don't try to re-sort the already sorted expirable bugtasks. update the callsites to expect a SelectResults intead of a list.
50
    >>> expirable_bugtasks.count()
5020.1.3 by Curtis Hovey
Merged the findExpirableBugTasks and bug-expiration script tests.
51
    0
52
5020.1.6 by Curtis Hovey
Revised the narrative of the test.
53
54
== Setup ==
55
5020.1.3 by Curtis Hovey
Merged the findExpirableBugTasks and bug-expiration script tests.
56
Let's make some bugtasks that qualify for expiration. A Jokosher
57
bugtask and a conjoined pair of ubuntu_hoary and ubuntu bugtasks
58
will suffice.
4621.5.2 by Curtis Hovey
Added cronscripts/expire-bugtask.py
59
6385.5.1 by Bjorn Tillenius
rewrite bugtask-expiration.txt, so that it's actually testing what it's supposed to test.
60
IBug specifies two properties related to bug expiration. can_expire
61
tells you whether one or more of the bug's bug tasks may be expired, if
62
the bug doesn't get any more activity. permits_expiration on the other
63
hand, mainly tells you whether no bug tasks are in a state that they may
64
expire. If permits_expiration is True, it could very well be that no bug
65
tasks will be expired.  permits_expiration mainly exists to have
66
can_expire avoid an expensive db, in the case where we can easily tell
67
that no bug tasks can be expired.
68
11716.1.6 by Curtis Hovey
Converted glob imports in doctests to import for the true module.
69
    >>> from lp.registry.interfaces.distribution import IDistributionSet
70
    >>> from lp.registry.interfaces.person import IPersonSet
71
    >>> from lp.registry.interfaces.product import IProductSet
5020.2.13 by Curtis Hovey
Revisions per review.
72
    >>> ubuntu = getUtility(IDistributionSet).getByName('ubuntu')
73
    >>> jokosher = getUtility(IProductSet).getByName('jokosher')
74
    >>> sample_person = getUtility(IPersonSet).getByEmail(
75
    ...     'test@canonical.com')
5020.1.6 by Curtis Hovey
Revised the narrative of the test.
76
5020.1.3 by Curtis Hovey
Merged the findExpirableBugTasks and bug-expiration script tests.
77
    # A expirable bugtask. It will be expired because its conjoined
78
    # master can be expired.
8523.3.1 by Gavin Panella
Bugs tree reorg after automated migration.
79
    >>> from lp.bugs.tests.bug import create_old_bug
5020.1.6 by Curtis Hovey
Revised the narrative of the test.
80
    >>> ubuntu_bugtask = create_old_bug('expirable_distro', 351, ubuntu)
5020.3.9 by Curtis Hovey
Revisions per review.
81
    >>> ubuntu_bugtask.bug.permits_expiration
82
    True
83
    >>> ubuntu_bugtask.bug.can_expire
84
    True
5020.1.3 by Curtis Hovey
Merged the findExpirableBugTasks and bug-expiration script tests.
85
5020.1.6 by Curtis Hovey
Revised the narrative of the test.
86
    # An expirable bugtask, a distroseries. The ubuntu bugtask is its
5020.1.5 by Curtis Hovey
Revises the narrative of the test.
87
    # conjoined slave.
8523.3.1 by Gavin Panella
Bugs tree reorg after automated migration.
88
    >>> from lp.bugs.tests.bug import sync_bugtasks
5020.1.3 by Curtis Hovey
Merged the findExpirableBugTasks and bug-expiration script tests.
89
    >>> hoary_bugtask = bugtaskset.createTask(
90
    ...     bug=ubuntu_bugtask.bug, owner=sample_person,
91
    ...     distroseries=ubuntu.currentseries)
5020.1.13 by Curtis Hovey
Revisions per review.
92
    >>> ubuntu_bugtask.conjoined_master == hoary_bugtask
93
    True
5020.3.9 by Curtis Hovey
Revisions per review.
94
    >>> ubuntu_bugtask.bug.permits_expiration
95
    True
96
    >>> sync_bugtasks([ubuntu_bugtask, hoary_bugtask])
97
    >>> ubuntu_bugtask.bug.can_expire
98
    True
5020.1.3 by Curtis Hovey
Merged the findExpirableBugTasks and bug-expiration script tests.
99
100
    # A bugtask for a product that is expirable.
5020.1.6 by Curtis Hovey
Revised the narrative of the test.
101
    >>> jokosher_bugtask = create_old_bug('jokosher', 61, jokosher)
5020.3.9 by Curtis Hovey
Revisions per review.
102
    >>> jokosher_bugtask.bug.permits_expiration
103
    True
104
    >>> jokosher_bugtask.bug.can_expire
105
    True
5020.1.6 by Curtis Hovey
Revised the narrative of the test.
106
6244.1.2 by Abel Deuring
implemented reviewr's comments
107
A bugtask for a product with a bug watch. Note that this bugtask
10680.2.1 by Abel Deuring
Add a new bug task status 'Expired'; the bug task expiration script sets expired bug tasks to this status; related adjustments to the bug task views
108
has otherwise the same parameters as jokosher_bugtask. The
6244.1.2 by Abel Deuring
implemented reviewr's comments
109
bugwatch prevents expiration, hence this bugtask will not appear
110
in the listings of expirable bugtasks below.
111
11692.6.2 by Curtis Hovey
Use deglober to fixing simple glob imports in doctests.
112
    >>> from lp.bugs.interfaces.bugtracker import IBugTrackerSet
6244.1.1 by Abel Deuring
fix for bug 224819: bug with a bug watch marked for expiration
113
    >>> mozilla_bugtracker = getUtility(IBugTrackerSet)['mozilla.org']
10680.2.1 by Abel Deuring
Add a new bug task status 'Expired'; the bug task expiration script sets expired bug tasks to this status; related adjustments to the bug task views
114
    >>> jokosher_bugtask_watched = create_old_bug('jokosher watched',
6244.1.1 by Abel Deuring
fix for bug 224819: bug with a bug watch marked for expiration
115
    ...     61, jokosher, external_bugtracker=mozilla_bugtracker)
116
    >>> jokosher_bugtask_watched.bug.can_expire
117
    False
118
5020.1.6 by Curtis Hovey
Revised the narrative of the test.
119
Let's also make some bugs that almost qualify for expiration.
120
5020.3.9 by Curtis Hovey
Revisions per review.
121
    # A bugtask whose status is not Incomplete is not expirable.
5020.1.13 by Curtis Hovey
Revisions per review.
122
    # This one's status is New.
5020.2.13 by Curtis Hovey
Revisions per review.
123
    >>> thunderbird = getUtility(IProductSet).getByName('thunderbird')
5020.1.6 by Curtis Hovey
Revised the narrative of the test.
124
    >>> new_bugtask = bugtaskset.createTask(
125
    ...     bug=ubuntu_bugtask.bug, owner=sample_person,
126
    ...     product=thunderbird)
5020.1.13 by Curtis Hovey
Revisions per review.
127
    >>> new_bugtask.status.title
128
    'New'
5020.3.9 by Curtis Hovey
Revisions per review.
129
    >>> new_bugtask.bug.permits_expiration
130
    False
5020.3.5 by Curtis Hovey
Revised test and code to not use the now defunct enable_bug_expiration.
131
    >>> new_bugtask.bug.can_expire
132
    False
4621.5.2 by Curtis Hovey
Added cronscripts/expire-bugtask.py
133
4621.5.5 by Curtis Hovey
Basic functionality for expiring bugs is complete.
134
    # A bugtask that is not expirable because it is assigned.
6385.5.1 by Bjorn Tillenius
rewrite bugtask-expiration.txt, so that it's actually testing what it's supposed to test.
135
    >>> assigned_bugtask = create_old_bug(
136
    ...     'assigned', 61, ubuntu, assignee=sample_person)
5020.3.9 by Curtis Hovey
Revisions per review.
137
    >>> assigned_bugtask.bug.permits_expiration
138
    True
139
    >>> assigned_bugtask.bug.can_expire
140
    False
4621.5.2 by Curtis Hovey
Added cronscripts/expire-bugtask.py
141
5915.1.1 by Bjorn Tillenius
only Incomplete bugtasks are expirable.
142
    # A bug with two Ubuntu tasks, one assigned Incomplete, and one
143
    # Invalid task, is not expirable.
12561.3.16 by Curtis Hovey
fixed the setup of the test.
144
    >>> ubuntu_alsa = ubuntu.getSourcePackage('alsa-utils')
6385.5.1 by Bjorn Tillenius
rewrite bugtask-expiration.txt, so that it's actually testing what it's supposed to test.
145
    >>> another_assigned_bugtask = create_old_bug(
146
    ...     'assigned', 61, ubuntu, assignee=sample_person)
12561.3.16 by Curtis Hovey
fixed the setup of the test.
147
    >>> another_assigned_bugtask.transitionToTarget(ubuntu_alsa)
5915.1.1 by Bjorn Tillenius
only Incomplete bugtasks are expirable.
148
    >>> ubuntu_evolution = ubuntu.getSourcePackage('evolution')
149
    >>> invalid_bugtask = bugtaskset.createTask(
150
    ...     bug=another_assigned_bugtask.bug, owner=sample_person,
151
    ...     distribution=ubuntu,
152
    ...     sourcepackagename=ubuntu_evolution.sourcepackagename,
153
    ...     status=BugTaskStatus.INVALID)
154
    >>> another_assigned_bugtask.bug.permits_expiration
155
    True
156
    >>> another_assigned_bugtask.bug.can_expire
157
    False
158
4621.5.5 by Curtis Hovey
Basic functionality for expiring bugs is complete.
159
    # A bugtask that is not expirable because its status is CONFIRMED.
5020.1.3 by Curtis Hovey
Merged the findExpirableBugTasks and bug-expiration script tests.
160
    >>> confirmed_bugtask = create_old_bug(
161
    ...     'confirmed', 61, ubuntu, status=BugTaskStatus.CONFIRMED)
5020.3.9 by Curtis Hovey
Revisions per review.
162
    >>> confirmed_bugtask.bug.permits_expiration
163
    False
5020.3.1 by Curtis Hovey
Basic can_expire property is added. bugtask-expiration needs revision to show it off.
164
    >>> confirmed_bugtask.bug.can_expire
165
    False
5020.1.3 by Curtis Hovey
Merged the findExpirableBugTasks and bug-expiration script tests.
166
167
    # A bugtask that is not expirable because it is a duplicate.
6385.5.1 by Bjorn Tillenius
rewrite bugtask-expiration.txt, so that it's actually testing what it's supposed to test.
168
    >>> duplicate_bugtask = create_old_bug(
169
    ...     'duplicate', 61, ubuntu, duplicateof=confirmed_bugtask.bug)
5020.3.9 by Curtis Hovey
Revisions per review.
170
    >>> duplicate_bugtask.bug.permits_expiration
171
    True
5020.3.1 by Curtis Hovey
Basic can_expire property is added. bugtask-expiration needs revision to show it off.
172
    >>> duplicate_bugtask.bug.can_expire
173
    False
5020.1.1 by Curtis Hovey
Extened the findExpirableBugTasks to verify the known example cases. Added duplicate case. Switched to date_last_message. Test is broken because of loop that checks for valid siblings--new conjoined pairs are needed.
174
5020.3.9 by Curtis Hovey
Revisions per review.
175
    # A bugtask that is not expirable because it does not use
176
    # Launchpad Bugs.
5020.1.3 by Curtis Hovey
Merged the findExpirableBugTasks and bug-expiration script tests.
177
    >>> external_bugtask = create_old_bug('external', 61, thunderbird)
5020.3.9 by Curtis Hovey
Revisions per review.
178
    >>> external_bugtask.bug.permits_expiration
179
    False
5283.1.2 by Curtis Hovey
Revised the can_expire code parts to honor enable_bug_expiration. Added
180
    >>> thunderbird.enable_bug_expiration
181
    False
182
    >>> external_bugtask.bug.can_expire
5020.1.13 by Curtis Hovey
Revisions per review.
183
    False
5020.1.3 by Curtis Hovey
Merged the findExpirableBugTasks and bug-expiration script tests.
184
185
    # A bugtask that is not expirable because it has a milestone.
5821.5.4 by James Henstridge
Make doc/bugtask-expiration.txt almost pass -- line 182 is still
186
    >>> milestone = ubuntu.currentseries.newMilestone("0.1")
5821.6.23 by James Henstridge
merge from rocketfuel
187
    >>> Store.of(milestone).flush()
6385.5.1 by Bjorn Tillenius
rewrite bugtask-expiration.txt, so that it's actually testing what it's supposed to test.
188
    >>> milestone_bugtask = create_old_bug(
189
    ...     'milestone', 61, ubuntu,
5821.6.23 by James Henstridge
merge from rocketfuel
190
    ...     milestone=milestone)
5020.3.9 by Curtis Hovey
Revisions per review.
191
    >>> milestone_bugtask.bug.permits_expiration
192
    True
5020.3.1 by Curtis Hovey
Basic can_expire property is added. bugtask-expiration needs revision to show it off.
193
    >>> milestone_bugtask.bug.can_expire
194
    False
5020.1.3 by Curtis Hovey
Merged the findExpirableBugTasks and bug-expiration script tests.
195
11057.8.2 by Brian Murray
modify can_expire to use the days_before_expiration config option
196
    # Create a bugtask that is not old enough to expire
5020.1.3 by Curtis Hovey
Merged the findExpirableBugTasks and bug-expiration script tests.
197
    >>> recent_bugtask = create_old_bug('recent', 31, ubuntu)
5020.3.9 by Curtis Hovey
Revisions per review.
198
    >>> recent_bugtask.bug.permits_expiration
199
    True
5020.3.5 by Curtis Hovey
Revised test and code to not use the now defunct enable_bug_expiration.
200
    >>> recent_bugtask.bug.can_expire
11057.8.2 by Brian Murray
modify can_expire to use the days_before_expiration config option
201
    False
5020.1.3 by Curtis Hovey
Merged the findExpirableBugTasks and bug-expiration script tests.
202
5283.1.1 by Curtis Hovey
Restored the enable_bug_expiration UI. The can_expire code needs updating.
203
    # A bugtask that is not expirable; while the product uses Launchpad to
204
    # track bugs, enable_bug_expiration is set to False
205
    >>> firefox = getUtility(IProductSet).getByName('firefox')
206
    >>> no_expiration_bugtask = create_old_bug('no_expire', 61, firefox)
5283.1.2 by Curtis Hovey
Revised the can_expire code parts to honor enable_bug_expiration. Added
207
    >>> no_expiration_bugtask.bug.permits_expiration
208
    False
209
    >>> firefox.enable_bug_expiration
210
    False
211
    >>> no_expiration_bugtask.bug.can_expire
5283.1.1 by Curtis Hovey
Restored the enable_bug_expiration UI. The can_expire code needs updating.
212
    False
213
5020.1.6 by Curtis Hovey
Revised the narrative of the test.
214
The ubuntu, hoary, and jokosher bugs are the only ones that can be
215
expired. The other bugs do not meet one of the preconditions.
216
217
    >>> bugtasks = [ubuntu_bugtask, hoary_bugtask, jokosher_bugtask,
6244.1.1 by Abel Deuring
fix for bug 224819: bug with a bug watch marked for expiration
218
    ...     jokosher_bugtask_watched, new_bugtask, assigned_bugtask,
10680.2.1 by Abel Deuring
Add a new bug task status 'Expired'; the bug task expiration script sets expired bug tasks to this status; related adjustments to the bug task views
219
    ...     confirmed_bugtask, duplicate_bugtask, external_bugtask,
6244.1.1 by Abel Deuring
fix for bug 224819: bug with a bug watch marked for expiration
220
    ...     milestone_bugtask, recent_bugtask, no_expiration_bugtask]
5020.1.3 by Curtis Hovey
Merged the findExpirableBugTasks and bug-expiration script tests.
221
8523.3.1 by Gavin Panella
Bugs tree reorg after automated migration.
222
    >>> from lp.bugs.tests.bug import summarize_bugtasks
5020.1.5 by Curtis Hovey
Revises the narrative of the test.
223
    >>> summarize_bugtasks(bugtasks)
6244.1.1 by Abel Deuring
fix for bug 224819: bug with a bug watch marked for expiration
224
    ROLE             EXPIRE  AGE  STATUS      ASSIGNED  DUP    MILE   REPLIES
6385.5.1 by Bjorn Tillenius
rewrite bugtask-expiration.txt, so that it's actually testing what it's supposed to test.
225
    ubuntu           False   351  Incomplete  False     False  False  False
226
    hoary            False   351  Incomplete  False     False  False  False
6244.1.1 by Abel Deuring
fix for bug 224819: bug with a bug watch marked for expiration
227
    jokosher         True     61  Incomplete  False     False  False  False
6385.5.1 by Bjorn Tillenius
rewrite bugtask-expiration.txt, so that it's actually testing what it's supposed to test.
228
    jokosher watched False    61  Incomplete  False     False  False  False
6244.1.1 by Abel Deuring
fix for bug 224819: bug with a bug watch marked for expiration
229
    thunderbird      False   351  New         False     False  False  False
6385.5.1 by Bjorn Tillenius
rewrite bugtask-expiration.txt, so that it's actually testing what it's supposed to test.
230
    assigned         False    61  Incomplete  True      False  False  False
231
    confirmed        False    61  Confirmed   False     False  False  False
232
    duplicate        False    61  Incomplete  False     True   False  False
6244.1.1 by Abel Deuring
fix for bug 224819: bug with a bug watch marked for expiration
233
    external         False    61  Incomplete  False     False  False  False
6385.5.1 by Bjorn Tillenius
rewrite bugtask-expiration.txt, so that it's actually testing what it's supposed to test.
234
    milestone        False    61  Incomplete  False     False  True   False
11057.8.2 by Brian Murray
modify can_expire to use the days_before_expiration config option
235
    recent           False    31  Incomplete  False     False  False  False
6244.1.1 by Abel Deuring
fix for bug 224819: bug with a bug watch marked for expiration
236
    no_expire        False    61  Incomplete  False     False  False  False
5020.1.3 by Curtis Hovey
Merged the findExpirableBugTasks and bug-expiration script tests.
237
11057.8.1 by Brian Murray
create IBug.isExpirable() which is hopefully clearer than IBug.can_expire and export it via the API
238
== isExpirable() ==
239
240
In addition to can_expire bugs have an isExpirable method to which a custom
241
number of days, days_old, can be passed.  days_old is then used with
242
findExpirableBugTasks.  This allows projects to create their own janitor using
243
a different period for bug expiration.
244
245
    # Check to ensure that isExpirable() works without days_old, then set the
246
    # bug to Invalid so it doesn't affect the rest of the doctest
247
    >>> from lp.bugs.tests.bug import create_old_bug
248
    >>> very_old_bugtask = create_old_bug('expirable_distro', 351, ubuntu)
249
    >>> very_old_bugtask.bug.isExpirable()
250
    True
251
    >>> very_old_bugtask.transitionToStatus(
252
    ...     BugTaskStatus.INVALID, sample_person)
253
254
    # Pass isExpirable() a days_old parameter, then set the bug to Invalid so it
255
    # doesn't affect the rest of the doctest
256
    >>> from lp.bugs.tests.bug import create_old_bug
257
    >>> not_so_old_bugtask = create_old_bug('expirable_distro', 31, ubuntu)
258
    >>> not_so_old_bugtask.bug.isExpirable(days_old=14)
259
    True
260
    >>> not_so_old_bugtask.transitionToStatus(
261
    ...     BugTaskStatus.INVALID, sample_person)
262
5020.1.6 by Curtis Hovey
Revised the narrative of the test.
263
264
== findExpirableBugTasks() Part 2 ==
265
266
The value of the min_days_old controls the bugtasks that are
267
returned. The oldest bug in this test is 351 days old, the youngest is
268
31 days old. There are no bugs older than 351 days.
269
5565.6.3 by Bjorn Tillenius
make the user parameter to findExpirableBugtasks() required. make all callsites specify it.
270
    >>> expirable_bugtasks = bugtaskset.findExpirableBugTasks(351, None)
5781.1.1 by Bjorn Tillenius
don't try to re-sort the already sorted expirable bugtasks. update the callsites to expect a SelectResults intead of a list.
271
    >>> expirable_bugtasks.count()
5020.1.3 by Curtis Hovey
Merged the findExpirableBugTasks and bug-expiration script tests.
272
    0
273
5020.1.6 by Curtis Hovey
Revised the narrative of the test.
274
While there are bugtasks older than 350 days in the data, the hoary
275
bugtask does not display because its bug has other bugtasks that are
276
valid.
5020.1.3 by Curtis Hovey
Merged the findExpirableBugTasks and bug-expiration script tests.
277
5565.6.3 by Bjorn Tillenius
make the user parameter to findExpirableBugtasks() required. make all callsites specify it.
278
    >>> expirable_bugtasks = bugtaskset.findExpirableBugTasks(350, None)
5781.1.1 by Bjorn Tillenius
don't try to re-sort the already sorted expirable bugtasks. update the callsites to expect a SelectResults intead of a list.
279
    >>> expirable_bugtasks.count()
5020.1.3 by Curtis Hovey
Merged the findExpirableBugTasks and bug-expiration script tests.
280
    0
281
5020.3.2 by Curtis Hovey
tests work, though coverage should show off can_expire better.
282
    >>> hoary_bugtask.bug.can_expire
283
    False
5020.1.6 by Curtis Hovey
Revised the narrative of the test.
284
    >>> summarize_bugtasks(hoary_bugtask.bug.bugtasks)
5283.1.1 by Curtis Hovey
Restored the enable_bug_expiration UI. The can_expire code needs updating.
285
    ROLE         EXPIRE  AGE  STATUS      ASSIGNED  DUP    MILE   REPLIES
6385.5.1 by Bjorn Tillenius
rewrite bugtask-expiration.txt, so that it's actually testing what it's supposed to test.
286
    ubuntu       False   351  Incomplete  False     False  False  False
287
    hoary        False   351  Incomplete  False     False  False  False
5416.1.1 by Graham Binns
findExpirableBugTasks no longer checks for a lack of a conjoined master. That check is now done by the bug expiration code itself.
288
    thunderbird  False   351  New         False     False  False  False
5020.1.6 by Curtis Hovey
Revised the narrative of the test.
289
290
If the valid bugtask becomes Invalid or Won't Fix, the hoary bugtask
5020.1.13 by Curtis Hovey
Revisions per review.
291
will be expirable.
5020.1.6 by Curtis Hovey
Revised the narrative of the test.
292
293
    >>> new_bugtask.transitionToStatus(BugTaskStatus.WONTFIX, sample_person)
5020.3.1 by Curtis Hovey
Basic can_expire property is added. bugtask-expiration needs revision to show it off.
294
    >>> sync_bugtasks(new_bugtask)
5020.3.2 by Curtis Hovey
tests work, though coverage should show off can_expire better.
295
    >>> hoary_bugtask.bug.can_expire
296
    True
5020.1.6 by Curtis Hovey
Revised the narrative of the test.
297
    >>> summarize_bugtasks(hoary_bugtask.bug.bugtasks)
5283.1.1 by Curtis Hovey
Restored the enable_bug_expiration UI. The can_expire code needs updating.
298
    ROLE         EXPIRE  AGE  STATUS      ASSIGNED  DUP    MILE   REPLIES
5416.1.1 by Graham Binns
findExpirableBugTasks no longer checks for a lack of a conjoined master. That check is now done by the bug expiration code itself.
299
    ubuntu       True    351  Incomplete  False     False  False  False
300
    hoary        True    351  Incomplete  False     False  False  False
5020.1.6 by Curtis Hovey
Revised the narrative of the test.
301
    thunderbird  False   351  Won't Fix   False     False  False  False
302
5565.6.3 by Bjorn Tillenius
make the user parameter to findExpirableBugtasks() required. make all callsites specify it.
303
    >>> expirable_bugtasks = bugtaskset.findExpirableBugTasks(350, None)
5020.1.5 by Curtis Hovey
Revises the narrative of the test.
304
    >>> summarize_bugtasks(expirable_bugtasks)
5283.1.1 by Curtis Hovey
Restored the enable_bug_expiration UI. The can_expire code needs updating.
305
    ROLE         EXPIRE  AGE  STATUS      ASSIGNED  DUP    MILE   REPLIES
5416.1.1 by Graham Binns
findExpirableBugTasks no longer checks for a lack of a conjoined master. That check is now done by the bug expiration code itself.
306
    ubuntu       True    351  Incomplete  False     False  False  False
5020.1.3 by Curtis Hovey
Merged the findExpirableBugTasks and bug-expiration script tests.
307
    hoary        True    351  Incomplete  False     False  False  False
308
5020.1.6 by Curtis Hovey
Revised the narrative of the test.
309
The ubuntu bugtask is never returned; it is a conjoined slave to the
310
hoary bugtask. Slave bugtasks cannot be directly expired, so they are
311
not returned by findExpirableBugTasks().
312
5020.1.13 by Curtis Hovey
Revisions per review.
313
    >>> ubuntu_bugtask.status.title
314
    'Incomplete'
315
    >>> ubuntu_bugtask.conjoined_master == hoary_bugtask
316
    True
317
5020.1.4 by Curtis Hovey
Minor organization changes.
318
Reducing the age to 60 days old, both hoary and jokosher bugtasks
5020.1.3 by Curtis Hovey
Merged the findExpirableBugTasks and bug-expiration script tests.
319
are returned.
320
5565.6.3 by Bjorn Tillenius
make the user parameter to findExpirableBugtasks() required. make all callsites specify it.
321
    >>> expirable_bugtasks = bugtaskset.findExpirableBugTasks(60, None)
5020.1.5 by Curtis Hovey
Revises the narrative of the test.
322
    >>> summarize_bugtasks(expirable_bugtasks)
5283.1.1 by Curtis Hovey
Restored the enable_bug_expiration UI. The can_expire code needs updating.
323
    ROLE         EXPIRE  AGE  STATUS      ASSIGNED  DUP    MILE   REPLIES
5416.1.1 by Graham Binns
findExpirableBugTasks no longer checks for a lack of a conjoined master. That check is now done by the bug expiration code itself.
324
    ubuntu       True    351  Incomplete  False     False  False  False
5254.2.5 by Curtis Hovey
Revised findExpirableBugTasks to accept a target.
325
    hoary        True    351  Incomplete  False     False  False  False
5020.1.3 by Curtis Hovey
Merged the findExpirableBugTasks and bug-expiration script tests.
326
    jokosher     True     61  Incomplete  False     False  False  False
5254.2.5 by Curtis Hovey
Revised findExpirableBugTasks to accept a target.
327
5305.1.1 by Curtis Hovey
I Moved the bug expiration model changes to support a browser view of all
328
5254.2.1 by Curtis Hovey
Added a first draft of the test changes to support a link on the bug page
329
When a bug is passed as an argument to findExpirableBugTasks(), it
5305.1.2 by Curtis Hovey
Revisions per review.
330
returns that bug's expirable BugTasks, or an empty list. Passing the bug
331
that has the hoary and ubuntu bugtasks with 0 min_days_old returns just
332
the hoary bugtask.
5254.2.1 by Curtis Hovey
Added a first draft of the test changes to support a link on the bug page
333
334
    >>> expirable_bugtasks = bugtaskset.findExpirableBugTasks(
5565.6.3 by Bjorn Tillenius
make the user parameter to findExpirableBugtasks() required. make all callsites specify it.
335
    ...     0, None, bug=hoary_bugtask.bug)
5254.2.1 by Curtis Hovey
Added a first draft of the test changes to support a link on the bug page
336
    >>> summarize_bugtasks(expirable_bugtasks)
5254.2.8 by Curtis Hovey
Merge from RF. Resolved two conflicts.
337
    ROLE         EXPIRE  AGE  STATUS      ASSIGNED  DUP    MILE   REPLIES
5416.1.1 by Graham Binns
findExpirableBugTasks no longer checks for a lack of a conjoined master. That check is now done by the bug expiration code itself.
338
    ubuntu       True    351  Incomplete  False     False  False  False
5254.2.1 by Curtis Hovey
Added a first draft of the test changes to support a link on the bug page
339
    hoary        True    351  Incomplete  False     False  False  False
340
341
When a BugTarget is passed as an argument to findExpirableBugTasks(), it
5305.1.2 by Curtis Hovey
Revisions per review.
342
returns all the target's expirable bugtasks, or an empty list. If the
5418.1.1 by Curtis Hovey
Fix findExpirableBugTasks() by adding a derived table that contains
343
target's pillar has not enabled bug expiration, None is always returned.
5305.1.2 by Curtis Hovey
Revisions per review.
344
Passing ubuntu with 0 min_days_old shows that the distribution has two
345
bugtasks that can expire if they are not confirmed.
5254.2.1 by Curtis Hovey
Added a first draft of the test changes to support a link on the bug page
346
347
    >>> expirable_bugtasks = bugtaskset.findExpirableBugTasks(
5565.6.3 by Bjorn Tillenius
make the user parameter to findExpirableBugtasks() required. make all callsites specify it.
348
    ...     0, None, target=ubuntu)
5254.2.1 by Curtis Hovey
Added a first draft of the test changes to support a link on the bug page
349
    >>> summarize_bugtasks(expirable_bugtasks)
5254.2.8 by Curtis Hovey
Merge from RF. Resolved two conflicts.
350
    ROLE         EXPIRE  AGE  STATUS      ASSIGNED  DUP    MILE   REPLIES
5416.1.1 by Graham Binns
findExpirableBugTasks no longer checks for a lack of a conjoined master. That check is now done by the bug expiration code itself.
351
    ubuntu       True    351  Incomplete  False     False  False  False
5254.2.1 by Curtis Hovey
Added a first draft of the test changes to support a link on the bug page
352
    hoary        True    351  Incomplete  False     False  False  False
11057.8.2 by Brian Murray
modify can_expire to use the days_before_expiration config option
353
    recent       False    31  Incomplete  False     False  False  False
5254.2.1 by Curtis Hovey
Added a first draft of the test changes to support a link on the bug page
354
11774.1.3 by Deryck Hodge
Add a test for adding limit to findExpirableBugTasks.
355
findExpirableBugTasks also accepts a limit argument, which allows for limiting
356
the number of bugtasks returned.
357
358
    >>> expirable_bugtasks = bugtaskset.findExpirableBugTasks(
359
    ...     0, None, target=ubuntu, limit=2)
360
    >>> summarize_bugtasks(expirable_bugtasks)
361
    ROLE         EXPIRE  AGE  STATUS      ASSIGNED  DUP    MILE   REPLIES
362
    ubuntu       True    351  Incomplete  False     False  False  False
363
    hoary        True    351  Incomplete  False     False  False  False
364
5418.1.1 by Curtis Hovey
Fix findExpirableBugTasks() by adding a derived table that contains
365
Thunderbird has not enabled bug expiration. Even when the min_days_old
5254.2.1 by Curtis Hovey
Added a first draft of the test changes to support a link on the bug page
366
is set to 0, no bugtasks are replaced.
367
368
    >>> expirable_bugtasks = bugtaskset.findExpirableBugTasks(
5565.6.3 by Bjorn Tillenius
make the user parameter to findExpirableBugtasks() required. make all callsites specify it.
369
    ...     0, None, target=thunderbird)
5254.2.1 by Curtis Hovey
Added a first draft of the test changes to support a link on the bug page
370
    >>> summarize_bugtasks(expirable_bugtasks)
5254.2.8 by Curtis Hovey
Merge from RF. Resolved two conflicts.
371
    ROLE         EXPIRE  AGE  STATUS      ASSIGNED  DUP    MILE   REPLIES
5254.2.1 by Curtis Hovey
Added a first draft of the test changes to support a link on the bug page
372
5020.1.3 by Curtis Hovey
Merged the findExpirableBugTasks and bug-expiration script tests.
373
5565.6.1 by Bjorn Tillenius
only return expirable bugs the user has permission to see.
374
== Privacy ==
375
5565.6.7 by Bjorn Tillenius
don't depend on bug ids in doctest.
376
The user parameter indicates which user is performing the search. Only
5565.6.1 by Bjorn Tillenius
only return expirable bugs the user has permission to see.
377
bugs that the user has permission to view are returned. A value of None
378
indicates the anonymous user.
379
380
    >>> expirable_bugtasks = bugtaskset.findExpirableBugTasks(
381
    ...     0, user=None, target=ubuntu)
5565.6.7 by Bjorn Tillenius
don't depend on bug ids in doctest.
382
    >>> visible_bugs = set(bugtask.bug for bugtask in expirable_bugtasks)
383
    >>> print sorted(bug.title for bug in visible_bugs)
384
    [u'expirable_distro', u'recent']
5565.6.1 by Bjorn Tillenius
only return expirable bugs the user has permission to see.
385
386
If one of the bugs is set to private, anonymous users can no longer see
387
it as being marked for expiration.
388
5565.6.7 by Bjorn Tillenius
don't depend on bug ids in doctest.
389
    >>> private_bug = ubuntu_bugtask.bug
390
    >>> private_bug.title
391
    u'expirable_distro'
392
    >>> private_bug.setPrivate(True, sample_person)
5565.6.1 by Bjorn Tillenius
only return expirable bugs the user has permission to see.
393
    True
394
395
    >>> expirable_bugtasks = bugtaskset.findExpirableBugTasks(
396
    ...     0, user=None, target=ubuntu)
5565.6.7 by Bjorn Tillenius
don't depend on bug ids in doctest.
397
    >>> visible_bugs = set(bugtask.bug for bugtask in expirable_bugtasks)
398
    >>> print sorted(bug.title for bug in visible_bugs)
399
    [u'recent']
5565.6.1 by Bjorn Tillenius
only return expirable bugs the user has permission to see.
400
401
No Privileges Person can't see the bug either...
402
403
    >>> no_priv = getUtility(IPersonSet).getByName('no-priv')
7968.1.3 by Bjorn Tillenius
Make sure the extra argument is passed to unsubscribed().
404
    >>> private_bug.unsubscribe(no_priv, no_priv)
5565.6.1 by Bjorn Tillenius
only return expirable bugs the user has permission to see.
405
    >>> expirable_bugtasks = bugtaskset.findExpirableBugTasks(
406
    ...     0, user=no_priv, target=ubuntu)
5565.6.7 by Bjorn Tillenius
don't depend on bug ids in doctest.
407
    >>> visible_bugs = set(bugtask.bug for bugtask in expirable_bugtasks)
408
    >>> print sorted(bug.title for bug in visible_bugs)
409
    [u'recent']
5565.6.1 by Bjorn Tillenius
only return expirable bugs the user has permission to see.
410
411
... unless he's subscribed to the bug.
412
5565.6.7 by Bjorn Tillenius
don't depend on bug ids in doctest.
413
    >>> private_bug.subscribe(no_priv, sample_person)
11536.1.2 by Gavin Panella
Fix many tests, and a bug or two.
414
    <lp.bugs.model.bugsubscription.BugSubscription ...>
5565.6.1 by Bjorn Tillenius
only return expirable bugs the user has permission to see.
415
    >>> expirable_bugtasks = bugtaskset.findExpirableBugTasks(
416
    ...     0, user=no_priv, target=ubuntu)
5565.6.7 by Bjorn Tillenius
don't depend on bug ids in doctest.
417
    >>> visible_bugs = set(bugtask.bug for bugtask in expirable_bugtasks)
418
    >>> print sorted(bug.title for bug in visible_bugs)
419
    [u'expirable_distro', u'recent']
5565.6.1 by Bjorn Tillenius
only return expirable bugs the user has permission to see.
420
5565.6.2 by Bjorn Tillenius
allow the Janitor to see private bugs to be expired.
421
The Janitor needs to be able to access all bugs, even private ones, in
422
order to be able to expire them. If the Janitor is passed as the user,
423
even the private bugs are returned.
424
13130.1.6 by Curtis Hovey
Move ILaunchpadCelebrity to lp.app.
425
    >>> from lp.app.interfaces.launchpad import ILaunchpadCelebrities
5565.6.2 by Bjorn Tillenius
allow the Janitor to see private bugs to be expired.
426
    >>> janitor = getUtility(ILaunchpadCelebrities).janitor
5565.6.7 by Bjorn Tillenius
don't depend on bug ids in doctest.
427
    >>> private_bug.isSubscribed(janitor)
5565.6.2 by Bjorn Tillenius
allow the Janitor to see private bugs to be expired.
428
    False
429
430
    >>> expirable_bugtasks = bugtaskset.findExpirableBugTasks(
431
    ...     0, user=janitor, target=ubuntu)
5565.6.7 by Bjorn Tillenius
don't depend on bug ids in doctest.
432
    >>> visible_bugs = set(bugtask.bug for bugtask in expirable_bugtasks)
433
    >>> print sorted(bug.title for bug in visible_bugs)
434
    [u'expirable_distro', u'recent']
5565.6.2 by Bjorn Tillenius
allow the Janitor to see private bugs to be expired.
435
5565.6.7 by Bjorn Tillenius
don't depend on bug ids in doctest.
436
    >>> private_bug.setPrivate(False, sample_person)
5565.6.1 by Bjorn Tillenius
only return expirable bugs the user has permission to see.
437
    True
438
439
5020.1.13 by Curtis Hovey
Revisions per review.
440
== The default expiration age ==
5020.1.5 by Curtis Hovey
Revises the narrative of the test.
441
442
The expiration age is set using the
443
config.malone.days_before_expiration configuration variable. It
444
defaults to 60 days. The period is measured from the date_incomplete
445
field. We expire bugtasks that are Incomplete and unattended for 60
446
days or more.
447
448
    >>> from canonical.config import config
449
    >>> old_age_days = config.malone.days_before_expiration
450
    >>> old_age_days
451
    60
452
453
5020.1.3 by Curtis Hovey
Merged the findExpirableBugTasks and bug-expiration script tests.
454
== Running the script ==
455
10680.2.1 by Abel Deuring
Add a new bug task status 'Expired'; the bug task expiration script sets expired bug tasks to this status; related adjustments to the bug task views
456
There are no Expired Bugtasks in sampledata, from the tests above.
5020.1.5 by Curtis Hovey
Revises the narrative of the test.
457
11626.3.12 by Curtis Hovey
Cross fingers and toes and hope for the best--remove all glob imports of bugs from
458
    >>> from lp.bugs.model.bugtask import BugTask
10680.2.1 by Abel Deuring
Add a new bug task status 'Expired'; the bug task expiration script sets expired bug tasks to this status; related adjustments to the bug task views
459
    >>> BugTask.selectBy(status=BugTaskStatus.EXPIRED).count()
460
    0
5020.1.5 by Curtis Hovey
Revises the narrative of the test.
461
5020.1.10 by Curtis Hovey
Grammar fixes.
462
    >>> # We want to check the hoary bugtask messages later.
5020.1.6 by Curtis Hovey
Revised the narrative of the test.
463
    >>> starting_bug_messages_count = (hoary_bugtask.bug.messages.count())
5020.1.5 by Curtis Hovey
Revises the narrative of the test.
464
5020.1.7 by Curtis Hovey
Added test for bug activity.
465
The script 'expire-bugtasks.py' writes its report to stdout. It makes
5020.1.13 by Curtis Hovey
Revisions per review.
466
its database changes as the user configured in
467
config.malone.expiration_dbuser.
5020.1.7 by Curtis Hovey
Added test for bug activity.
468
469
    >>> config.malone.expiration_dbuser
470
    'bugnotification'
5020.1.3 by Curtis Hovey
Merged the findExpirableBugTasks and bug-expiration script tests.
471
4621.5.2 by Curtis Hovey
Added cronscripts/expire-bugtask.py
472
    # Commit the current transaction because the script will run in
473
    # another transaction, and thus it won't see the changes done on
474
    # this test unless we commit.
4621.5.4 by Curtis Hovey
Save point. Lots do do according to the bugtask-expiration.txt doctest.
475
    >>> commit()
4621.5.1 by Curtis Hovey
Started the bugtask-expiration test.
476
477
    >>> import subprocess
478
    >>> process = subprocess.Popen(
4621.5.2 by Curtis Hovey
Added cronscripts/expire-bugtask.py
479
    ...     'cronscripts/expire-bugtasks.py', shell=True,
4621.5.1 by Curtis Hovey
Started the bugtask-expiration test.
480
    ...     stdin=subprocess.PIPE, stdout=subprocess.PIPE,
481
    ...     stderr=subprocess.PIPE)
482
    >>> (out, err) = process.communicate()
483
    >>> print err
7675.624.69 by Tim Penhey
More lockfile creation fixes.
484
    INFO    Creating lockfile: /var/lock/launchpad-expire-bugtasks.lock
5020.1.6 by Curtis Hovey
Revised the narrative of the test.
485
    INFO    Expiring unattended, INCOMPLETE bugtasks older than
5020.2.6 by Curtis Hovey
Removed the word 'Malone' from bug expiration.
486
            60 days for projects that use Launchpad Bugs.
5416.1.1 by Graham Binns
findExpirableBugTasks no longer checks for a lack of a conjoined master. That check is now done by the bug expiration code itself.
487
    INFO    Found 3 bugtasks to expire.
4621.5.6 by Curtis Hovey
Added a product bugtask to the expire bugtasks test.
488
    INFO    Expired 2 bugtasks.
4621.5.1 by Curtis Hovey
Started the bugtask-expiration test.
489
    INFO    Finished expiration run.
490
    <BLANKLINE>
491
    >>> print out
492
    <BLANKLINE>
493
    >>> process.returncode
494
    0
495
6385.5.1 by Bjorn Tillenius
rewrite bugtask-expiration.txt, so that it's actually testing what it's supposed to test.
496
    >>> bugtasks = [BugTask.get(bugtask.id) for bugtask in bugtasks]
4621.5.1 by Curtis Hovey
Started the bugtask-expiration test.
497
4621.5.2 by Curtis Hovey
Added cronscripts/expire-bugtask.py
498
499
== After the script has run ==
500
10680.2.1 by Abel Deuring
Add a new bug task status 'Expired'; the bug task expiration script sets expired bug tasks to this status; related adjustments to the bug task views
501
There are three Expired bugtasks. Jokosher, hoary and ubuntu were
5020.1.5 by Curtis Hovey
Revises the narrative of the test.
502
expired by the expiration process. Although ubuntu was never returned
5020.1.6 by Curtis Hovey
Revised the narrative of the test.
503
by findExpirableBugTasks(), it was expired because its master (hoary)
504
was expired. The remaining bugtasks are unchanged.
4621.5.2 by Curtis Hovey
Added cronscripts/expire-bugtask.py
505
5020.1.5 by Curtis Hovey
Revises the narrative of the test.
506
    >>> summarize_bugtasks(bugtasks)
6244.1.1 by Abel Deuring
fix for bug 224819: bug with a bug watch marked for expiration
507
    ROLE             EXPIRE  AGE  STATUS      ASSIGNED  DUP    MILE   REPLIES
10680.2.1 by Abel Deuring
Add a new bug task status 'Expired'; the bug task expiration script sets expired bug tasks to this status; related adjustments to the bug task views
508
    ubuntu           False     0  Expired     False     False  False  False
509
    hoary            False     0  Expired     False     False  False  False
510
    jokosher         False     0  Expired     False     False  False  False
6385.5.1 by Bjorn Tillenius
rewrite bugtask-expiration.txt, so that it's actually testing what it's supposed to test.
511
    jokosher watched False    61  Incomplete  False     False  False  False
6244.1.1 by Abel Deuring
fix for bug 224819: bug with a bug watch marked for expiration
512
    thunderbird      False     0  Won't Fix   False     False  False  False
6385.5.1 by Bjorn Tillenius
rewrite bugtask-expiration.txt, so that it's actually testing what it's supposed to test.
513
    assigned         False    61  Incomplete  True      False  False  False
514
    confirmed        False    61  Confirmed   False     False  False  False
515
    duplicate        False    61  Incomplete  False     True   False  False
6244.1.1 by Abel Deuring
fix for bug 224819: bug with a bug watch marked for expiration
516
    external         False    61  Incomplete  False     False  False  False
6385.5.1 by Bjorn Tillenius
rewrite bugtask-expiration.txt, so that it's actually testing what it's supposed to test.
517
    milestone        False    61  Incomplete  False     False  True   False
11057.8.2 by Brian Murray
modify can_expire to use the days_before_expiration config option
518
    recent           False    31  Incomplete  False     False  False  False
6244.1.1 by Abel Deuring
fix for bug 224819: bug with a bug watch marked for expiration
519
    no_expire        False    61  Incomplete  False     False  False  False
5020.1.3 by Curtis Hovey
Merged the findExpirableBugTasks and bug-expiration script tests.
520
5020.1.10 by Curtis Hovey
Grammar fixes.
521
The bugtasks statusexplanation was updated to explain the change in
4621.5.5 by Curtis Hovey
Basic functionality for expiring bugs is complete.
522
status.
523
6385.5.1 by Bjorn Tillenius
rewrite bugtask-expiration.txt, so that it's actually testing what it's supposed to test.
524
    >>> hoary_bugtask = BugTask.get(hoary_bugtask.id)
5020.1.3 by Curtis Hovey
Merged the findExpirableBugTasks and bug-expiration script tests.
525
    >>> print hoary_bugtask.statusexplanation
4621.5.5 by Curtis Hovey
Basic functionality for expiring bugs is complete.
526
    [Expired for Ubuntu Hoary because there has been no activity for 60 days.]
4621.5.1 by Curtis Hovey
Started the bugtask-expiration test.
527
528
The message explaining the reason for the expiration was posted by the
5020.1.5 by Curtis Hovey
Revises the narrative of the test.
529
Launchpad Janitor celebrity. Only one message was created for when the
530
master and slave bugtasks were expired.
4621.5.5 by Curtis Hovey
Basic functionality for expiring bugs is complete.
531
5020.1.5 by Curtis Hovey
Revises the narrative of the test.
532
    >>> starting_bug_messages_count
533
    2
534
    >>> hoary_bugtask.bug.messages.count()
5020.1.3 by Curtis Hovey
Merged the findExpirableBugTasks and bug-expiration script tests.
535
    3
4621.5.5 by Curtis Hovey
Basic functionality for expiring bugs is complete.
536
7960.1.12 by Gavin Panella
Changes to statusexplanation are no longer being logged.
537
    >>> message = hoary_bugtask.bug.messages[-1]
4621.5.5 by Curtis Hovey
Basic functionality for expiring bugs is complete.
538
    >>> print message.owner.name
4621.5.26 by Curtis Hovey
Renamed launchpad-janitor to janitor per review.
539
    janitor
4621.5.5 by Curtis Hovey
Basic functionality for expiring bugs is complete.
540
541
    >>> print message.text_contents
542
    [Expired for Ubuntu Hoary because there has been no activity for 60 days.]
5020.1.4 by Curtis Hovey
Minor organization changes.
543
7960.1.12 by Gavin Panella
Changes to statusexplanation are no longer being logged.
544
The bug's activity log was updated too with the status change.
5020.1.4 by Curtis Hovey
Minor organization changes.
545
8342.5.9 by Gavin Panella
Another test, another dollar.
546
    >>> activity = hoary_bugtask.bug.activity[-1]
547
    >>> print "%s  %s  %s  %s" % (
548
    ...     activity.person.displayname, activity.whatchanged,
549
    ...     activity.oldvalue, activity.newvalue)
10680.2.1 by Abel Deuring
Add a new bug task status 'Expired'; the bug task expiration script sets expired bug tasks to this status; related adjustments to the bug task views
550
    Launchpad Janitor  Ubuntu Hoary: status  Incomplete  Expired
5283.1.1 by Curtis Hovey
Restored the enable_bug_expiration UI. The can_expire code needs updating.
551
552
553
== enable_bug_expiration ==
554
555
The bugtask no_expiration_bugtask has not been expired because it does
556
not participate in bug expiration. When uses_bug_expiration is set to
557
True for a project, old bugs will be expired the next time the bugs are
558
expired.
559
560
    >>> no_expiration_bugtask.pillar.enable_bug_expiration = True
561
    >>> from canonical.launchpad.ftests import sync
562
    >>> sync(no_expiration_bugtask.pillar)
5283.1.2 by Curtis Hovey
Revised the can_expire code parts to honor enable_bug_expiration. Added
563
564
    >>> no_expiration_bugtask.bug.permits_expiration
565
    True
566
    >>> no_expiration_bugtask.bug.can_expire
567
    True
5565.6.3 by Bjorn Tillenius
make the user parameter to findExpirableBugtasks() required. make all callsites specify it.
568
    >>> expirable_bugtasks = bugtaskset.findExpirableBugTasks(60, None)
5283.1.1 by Curtis Hovey
Restored the enable_bug_expiration UI. The can_expire code needs updating.
569
    >>> summarize_bugtasks(expirable_bugtasks)
570
    ROLE         EXPIRE  AGE  STATUS      ASSIGNED  DUP    MILE   REPLIES
571
    no_expire    True    61   Incomplete  False     False  False  False
572