Merge lp:~mwhudson/launchpad/bmj-iterReady-missing-term into lp:launchpad

Proposed by Michael Hudson-Doyle
Status: Merged
Approved by: Aaron Bentley
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~mwhudson/launchpad/bmj-iterReady-missing-term
Merge into: lp:launchpad
Diff against target: 51 lines
2 files modified
lib/lp/code/model/branchmergeproposaljob.py (+2/-1)
lib/lp/code/model/tests/test_branchmergeproposals.py (+16/-0)
To merge this branch: bzr merge lp:~mwhudson/launchpad/bmj-iterReady-missing-term
Reviewer Review Type Date Requested Status
Aaron Bentley (community) Approve
Review via email: mp+14389@code.launchpad.net

Commit message

Add a missing term to the query for ready branchmergeproposal jobs.

To post a comment you must log in.
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

While working on fixing this query for another branch of mine, I noticed that it's missing a join between the "job" and the "branch" sides of the query. Here's a test case and the fix.

Revision history for this message
Aaron Bentley (abentley) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

 merge approved

Thanks for catching this!

Michael Hudson wrote:
> Michael Hudson has proposed merging lp:~mwhudson/launchpad/bmj-iterReady-missing-term into lp:launchpad/devel.
>
> Requested reviews:
> Aaron Bentley (abentley)
>
>
> While working on fixing this query for another branch of mine, I noticed that it's missing a join between the "job" and the "branch" sides of the query. Here's a test case and the fix.
>

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkrwnocACgkQ0F+nu1YWqI19MwCfZgA/WNhs9DaBlPspKWwH+Ej4
KhkAn1baqBPWOm5yThIveu0HcWIPkTr3
=cg11
-----END PGP SIGNATURE-----

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/model/branchmergeproposaljob.py'
2--- lib/lp/code/model/branchmergeproposaljob.py 2009-09-16 13:47:41 +0000
3+++ lib/lp/code/model/branchmergeproposaljob.py 2009-11-03 21:15:22 +0000
4@@ -173,6 +173,8 @@
5 And(BranchMergeProposalJob.job_type == klass.class_job_type,
6 BranchMergeProposalJob.job == Job.id,
7 Job.id.is_in(Job.ready_jobs),
8+ BranchMergeProposalJob.branch_merge_proposal
9+ == BranchMergeProposal.id,
10 BranchMergeProposal.source_branch == Branch.id,
11 # A proposal isn't considered ready if it has no revisions,
12 # or if it is hosted but pending a mirror.
13@@ -180,7 +182,6 @@
14 Or(Branch.next_mirror_time == None,
15 Branch.branch_type != BranchType.HOSTED)
16 ))
17- jobs.config(distinct=True)
18 return (klass(job) for job in jobs)
19
20 def getOopsVars(self):
21
22=== modified file 'lib/lp/code/model/tests/test_branchmergeproposals.py'
23--- lib/lp/code/model/tests/test_branchmergeproposals.py 2009-10-05 14:17:48 +0000
24+++ lib/lp/code/model/tests/test_branchmergeproposals.py 2009-11-03 21:15:22 +0000
25@@ -1331,10 +1331,26 @@
26 """Skip Jobs with a hosted source branch that needs mirroring."""
27 # Suppress events to avoid creating a MergeProposalCreatedJob early.
28 bmp = capture_events(self.factory.makeBranchMergeProposal)[0]
29+ self.factory.makeRevisionsForBranch(bmp.source_branch, count=1)
30 bmp.source_branch.requestMirror()
31 job = MergeProposalCreatedJob.create(bmp)
32 self.assertEqual([], list(MergeProposalCreatedJob.iterReady()))
33
34+ def test_iterReady_joins_properly(self):
35+ """An up-to-date branch does not cause a job for a needs-mirroring
36+ branch to be returned."""
37+ # Suppress events to avoid creating MergeProposalCreatedJobs early.
38+ bmp = capture_events(self.factory.makeBranchMergeProposal)[0]
39+ bmp2 = capture_events(self.factory.makeBranchMergeProposal)[0]
40+ # Give both branches some revisions.
41+ self.factory.makeRevisionsForBranch(bmp.source_branch, count=1)
42+ self.factory.makeRevisionsForBranch(bmp2.source_branch, count=1)
43+ # Request a mirror and create a job for one of them.
44+ bmp.source_branch.requestMirror()
45+ MergeProposalCreatedJob.create(bmp)
46+ # No jobs are ready.
47+ self.assertEqual([], list(MergeProposalCreatedJob.iterReady()))
48+
49 def test_iterReady_includes_mirrored_needing_mirror(self):
50 """Skip Jobs with a hosted source branch that needs mirroring."""
51 source_branch = self.factory.makeProductBranch(