Merge lp:~twom/launchpad/no-rescan-with-no-jobs into lp:launchpad

Proposed by Tom Wardill
Status: Merged
Merged at revision: 18870
Proposed branch: lp:~twom/launchpad/no-rescan-with-no-jobs
Merge into: lp:launchpad
Prerequisite: lp:~twom/launchpad/merge-proposal-rescan-link
Diff against target: 86 lines (+12/-10)
5 files modified
lib/lp/code/browser/branch.py (+3/-3)
lib/lp/code/browser/branchmergeproposal.py (+3/-1)
lib/lp/code/browser/gitrepository.py (+3/-3)
lib/lp/code/browser/tests/test_branch.py (+2/-2)
lib/lp/code/browser/tests/test_gitrepository.py (+1/-1)
To merge this branch: bzr merge lp:~twom/launchpad/no-rescan-with-no-jobs
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Maximiliano Bertacchini (community) Approve
Review via email: mp+362479@code.launchpad.net

Commit message

No scan jobs existing is a valid state, don't show the rescan button in these situations

To post a comment you must log in.
Revision history for this message
Maximiliano Bertacchini (maxiberta) wrote :

LGTM

review: Approve
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=== modified file 'lib/lp/code/browser/branch.py'
2--- lib/lp/code/browser/branch.py 2019-01-23 17:11:52 +0000
3+++ lib/lp/code/browser/branch.py 2019-01-31 14:45:54 +0000
4@@ -592,10 +592,10 @@
5 def show_rescan_link(self):
6 """Only show the rescan button if the latest scan has failed"""
7 scan_job = self.context.getLatestScanJob()
8- # If there are no jobs, we failed to create one for some reason,
9- # so we should allow a rescan
10+ # Having no jobs is a valid situation as there is a prune job.
11+ # We don't need to allow a rescan
12 if not scan_job:
13- return True
14+ return False
15 return scan_job.job.status == JobStatus.FAILED
16
17 @cachedproperty
18
19=== modified file 'lib/lp/code/browser/branchmergeproposal.py'
20--- lib/lp/code/browser/branchmergeproposal.py 2019-01-31 13:48:34 +0000
21+++ lib/lp/code/browser/branchmergeproposal.py 2019-01-31 14:45:54 +0000
22@@ -801,8 +801,10 @@
23 @property
24 def show_diff_update_link(self):
25 latest_preview = self.context.getLatestDiffUpdateJob()
26+ # Having no jobs is a valid situation as there is a prune job.
27+ # We don't need to allow a rescan
28 if not latest_preview:
29- return True
30+ return False
31 return latest_preview.job.status == JobStatus.FAILED
32
33
34
35=== modified file 'lib/lp/code/browser/gitrepository.py'
36--- lib/lp/code/browser/gitrepository.py 2019-01-28 15:36:56 +0000
37+++ lib/lp/code/browser/gitrepository.py 2019-01-31 14:45:54 +0000
38@@ -446,10 +446,10 @@
39 def show_rescan_link(self):
40 """Only show the rescan button if the latest scan has failed"""
41 scan_job = self.context.getLatestScanJob()
42- # If there are no jobs, we failed to create one for some reason,
43- # so we should allow a rescan
44+ # Having no jobs is a valid situation as there is a prune job.
45+ # We don't need to allow a rescan
46 if not scan_job:
47- return True
48+ return False
49 return scan_job.job.status == JobStatus.FAILED
50
51
52
53=== modified file 'lib/lp/code/browser/tests/test_branch.py'
54--- lib/lp/code/browser/tests/test_branch.py 2019-01-23 18:14:05 +0000
55+++ lib/lp/code/browser/tests/test_branch.py 2019-01-31 14:45:54 +0000
56@@ -322,7 +322,7 @@
57 branch = self.factory.makeAnyBranch()
58 view = create_initialized_view(branch, '+index')
59 result = view.show_rescan_link
60- self.assertTrue(result)
61+ self.assertFalse(result)
62
63 def test_show_rescan_link_latest_didnt_fail(self):
64 branch = self.factory.makeAnyBranch()
65@@ -646,7 +646,7 @@
66 logout()
67 with StormStatementRecorder() as recorder:
68 browser.open(branch_url)
69- self.assertThat(recorder, HasQueryCount(Equals(29)))
70+ self.assertThat(recorder, HasQueryCount(Equals(30)))
71
72
73 class TestBranchViewPrivateArtifacts(BrowserTestCase):
74
75=== modified file 'lib/lp/code/browser/tests/test_gitrepository.py'
76--- lib/lp/code/browser/tests/test_gitrepository.py 2019-01-28 17:19:44 +0000
77+++ lib/lp/code/browser/tests/test_gitrepository.py 2019-01-31 14:45:54 +0000
78@@ -445,7 +445,7 @@
79 repository = self.factory.makeGitRepository()
80 view = create_initialized_view(repository, '+index')
81 result = view.show_rescan_link
82- self.assertTrue(result)
83+ self.assertFalse(result)
84
85 def test_show_rescan_link_latest_didnt_fail(self):
86 repository = self.factory.makeGitRepository()