Merge lp:~gmb/launchpad/hide-update-now-on-success-bug-566605 into lp:launchpad

Proposed by Graham Binns on 2010-05-13
Status: Merged
Approved by: Graham Binns on 2010-05-14
Approved revision: no longer in the source branch.
Merged at revision: 10867
Proposed branch: lp:~gmb/launchpad/hide-update-now-on-success-bug-566605
Merge into: lp:launchpad
Prerequisite: lp:~gmb/launchpad/retry-rofo-watches-bug-566600
Diff against target: 126 lines (+51/-5)
3 files modified
lib/lp/bugs/doc/bugwatch.txt (+28/-1)
lib/lp/bugs/model/bugwatch.py (+5/-0)
lib/lp/bugs/stories/bugwatches/xx-edit-bugwatch.txt (+18/-4)
To merge this branch: bzr merge lp:~gmb/launchpad/hide-update-now-on-success-bug-566605
Reviewer Review Type Date Requested Status
Michael Nelson (community) code 2010-05-13 Approve on 2010-05-13
Review via email: mp+25228@code.launchpad.net

Commit message

The 'Update now' button will no longer appear for a bug watch whose latest update succeeded.

Description of the change

This branch fixes bug 566605 by preventing the "Update now" button from appearing for bug watches whose last update succeeded, regardless of how often they've failed in the past.

To post a comment you must log in.
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/doc/bugwatch.txt'
2--- lib/lp/bugs/doc/bugwatch.txt 2010-04-23 11:19:49 +0000
3+++ lib/lp/bugs/doc/bugwatch.txt 2010-05-14 13:11:29 +0000
4@@ -537,7 +537,10 @@
5 If the watch's updates have failed less than 60% of the time,
6 can_be_rescheduled will be True
7
8+ >>> import transaction
9 >>> from lp.bugs.interfaces.bugwatch import BugWatchActivityStatus
10+
11+ >>> transaction.commit()
12 >>> schedulable_watch.addActivity(
13 ... result=BugWatchActivityStatus.BUG_NOT_FOUND)
14 >>> schedulable_watch.can_be_rescheduled
15@@ -558,11 +561,32 @@
16 needs attention in order for it to be able to work again.
17
18 >>> schedulable_watch.next_check = None
19+ >>> transaction.commit()
20 >>> schedulable_watch.addActivity(
21 ... result=BugWatchActivityStatus.BUG_NOT_FOUND)
22 >>> schedulable_watch.can_be_rescheduled
23 False
24
25+If the watch has run and failed only once, can_be_rescheduled will be
26+true.
27+
28+ >>> from datetime import timedelta
29+ >>> run_once_failed_once_watch = factory.makeBugWatch()
30+ >>> run_once_failed_once_watch.next_check = (
31+ ... datetime.now(utc) + timedelta(days=7))
32+ >>> run_once_failed_once_watch.addActivity(
33+ ... result=BugWatchActivityStatus.BUG_NOT_FOUND)
34+ >>> run_once_failed_once_watch.can_be_rescheduled
35+ True
36+
37+If the most recent update on the watch succeded, can_be_rescheduled will
38+be False, regardless of the ratio of failures to successes.
39+
40+ >>> transaction.commit()
41+ >>> run_once_failed_once_watch.addActivity()
42+ >>> run_once_failed_once_watch.can_be_rescheduled
43+ False
44+
45
46 Rescheduling a watch
47 --------------------
48@@ -575,6 +599,8 @@
49 The schedulable_watch that we used in the previous test cannot currently
50 be rescheduled.
51
52+ >>> schedulable_watch = factory.makeBugWatch()
53+ >>> schedulable_watch.next_check = None
54 >>> schedulable_watch.can_be_rescheduled
55 False
56
57@@ -589,7 +615,8 @@
58 If we add some activity to the watch, to make its can_be_rescheduled
59 property become True, setNextCheck() will succeed.
60
61- >>> schedulable_watch.addActivity()
62+ >>> schedulable_watch.addActivity(
63+ ... result=BugWatchActivityStatus.BUG_NOT_FOUND)
64 >>> schedulable_watch.can_be_rescheduled
65 True
66
67
68=== modified file 'lib/lp/bugs/model/bugwatch.py'
69--- lib/lp/bugs/model/bugwatch.py 2010-05-13 12:02:00 +0000
70+++ lib/lp/bugs/model/bugwatch.py 2010-05-14 13:11:29 +0000
71@@ -345,6 +345,11 @@
72 # been checked.
73 return False
74
75+ if self.activity[0].result in BUG_WATCH_ACTIVITY_SUCCESS_STATUSES:
76+ # If the last update was successful the watch can't be
77+ # rescheduled.
78+ return False
79+
80 if self.failed_activity.is_empty():
81 # Don't show the reschedule button if the watch has never
82 # failed.
83
84=== modified file 'lib/lp/bugs/stories/bugwatches/xx-edit-bugwatch.txt'
85--- lib/lp/bugs/stories/bugwatches/xx-edit-bugwatch.txt 2010-05-13 12:02:00 +0000
86+++ lib/lp/bugs/stories/bugwatches/xx-edit-bugwatch.txt 2010-05-14 13:11:29 +0000
87@@ -130,8 +130,6 @@
88
89 For a new watch, the "Update Now" button isn't shown.
90
91- >>> from pytz import utc
92- >>> from datetime import datetime, timedelta
93 >>> login('foo.bar@canonical.com')
94 >>> bug_watch = factory.makeBugWatch()
95 >>> bug_watch.next_check = None
96@@ -203,8 +201,6 @@
97 If a watch has run once and failed once, the reschedule button will be
98 shown.
99
100- >>> from pytz import utc
101- >>> from datetime import datetime, timedelta
102 >>> login('foo.bar@canonical.com')
103 >>> bug_watch = factory.makeBugWatch()
104 >>> bug_watch.next_check = None
105@@ -222,3 +218,21 @@
106 ... user_browser.contents, 'informational message'):
107 ... print extract_text(message)
108 The ... bug watch has been scheduled for immediate checking.
109+
110+However, once the watch succeeds the button will disappear, even though
111+the watch has failed > 60% of the time. This is because the most recent
112+check succeeded, so there's no point in allowing users to reschedule the
113+watch for checking.
114+
115+ >>> from datetime import timedelta
116+
117+ >>> login('foo.bar@canonical.com')
118+ >>> bug_watch.next_check = datetime.now(utc) + timedelta(days=7)
119+ >>> bug_watch.addActivity()
120+ >>> logout()
121+
122+ >>> user_browser.open(watch_url)
123+ >>> user_browser.getControl('Update Now')
124+ Traceback (most recent call last):
125+ ...
126+ LookupError: label 'Update Now'