Merge ~jugmac00/launchpad:fix-regression-for-create-lpcraft-jobs-on-push into launchpad:master

Proposed by Jürgen Gmach
Status: Merged
Approved by: Jürgen Gmach
Approved revision: 2db15399d83225310d6087ec69217b42dadc5efb
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~jugmac00/launchpad:fix-regression-for-create-lpcraft-jobs-on-push
Merge into: launchpad:master
Diff against target: 227 lines (+119/-9)
2 files modified
lib/lp/code/browser/tests/test_gitref.py (+116/-9)
lib/lp/oci/tests/test_ocirecipe.py (+3/-0)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+416818@code.launchpad.net

Commit message

Fix regression introduced with `create lpcraft jobs on push`.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve
Revision history for this message
Jürgen Gmach (jugmac00) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/lib/lp/code/browser/tests/test_gitref.py b/lib/lp/code/browser/tests/test_gitref.py
index 8af99ca..552e49a 100644
--- a/lib/lp/code/browser/tests/test_gitref.py
+++ b/lib/lp/code/browser/tests/test_gitref.py
@@ -6,6 +6,7 @@
6from datetime import datetime6from datetime import datetime
7import hashlib7import hashlib
8import re8import re
9from textwrap import dedent
910
10from fixtures import FakeLogger11from fixtures import FakeLogger
11import pytz12import pytz
@@ -153,7 +154,20 @@ class TestGitRefView(BrowserTestCase):
153 [ref] = self.factory.makeGitRefs(paths=["refs/heads/branch"])154 [ref] = self.factory.makeGitRefs(paths=["refs/heads/branch"])
154 log = self.makeCommitLog()155 log = self.makeCommitLog()
155 self.hosting_fixture.getLog.result = list(reversed(log))156 self.hosting_fixture.getLog.result = list(reversed(log))
156 self.scanRef(ref, log[-1])157 # XXX jugmac00 2022-03-14
158 # This is a workaround for the limitation of `GitHostingFixture` not
159 # implementing a proper `getCommits` method.
160 # If we would not supply the following configuration file,
161 # `CIBuild.requestBuildsForRefs`, which is unrelated to this test case,
162 # would fail.
163 configuration = dedent("""\
164 pipeline: [test]
165 jobs:
166 test:
167 series: foo
168 architectures: ["bar"]
169 """)
170 self.scanRef(ref, log[-1], blobs={".launchpad.yaml": configuration})
157171
158 # Make code hosting fail.172 # Make code hosting fail.
159 self.hosting_fixture.getLog = FakeMethod(173 self.hosting_fixture.getLog = FakeMethod(
@@ -193,7 +207,20 @@ class TestGitRefView(BrowserTestCase):
193 result=RevisionStatusResult.FAILED)207 result=RevisionStatusResult.FAILED)
194208
195 self.hosting_fixture.getLog.result = list(log)209 self.hosting_fixture.getLog.result = list(log)
196 self.scanRef(ref, log[-1])210 # XXX jugmac00 2022-03-14
211 # This is a workaround for the limitation of `GitHostingFixture` not
212 # implementing a proper `getCommits` method.
213 # If we would not supply the following configuration file,
214 # `CIBuild.requestBuildsForRefs`, which is unrelated to this test case,
215 # would fail.
216 configuration = dedent("""\
217 pipeline: [test]
218 jobs:
219 test:
220 series: foo
221 architectures: ["bar"]
222 """)
223 self.scanRef(ref, log[-1], blobs={".launchpad.yaml": configuration})
197 view = create_initialized_view(ref, "+index",224 view = create_initialized_view(ref, "+index",
198 principal=repository.owner)225 principal=repository.owner)
199 with person_logged_in(repository.owner):226 with person_logged_in(repository.owner):
@@ -533,7 +560,9 @@ class TestGitRefView(BrowserTestCase):
533 }560 }
534 for i in range(5)]561 for i in range(5)]
535562
536 def scanRef(self, ref, tip):563 def scanRef(self, ref, tip, blobs=None):
564 if blobs is not None:
565 tip["blobs"] = blobs
537 self.hosting_fixture.getRefs.result = {566 self.hosting_fixture.getRefs.result = {
538 ref.path: {"object": {"sha1": tip["sha1"], "type": "commit"}},567 ref.path: {"object": {"sha1": tip["sha1"], "type": "commit"}},
539 }568 }
@@ -550,7 +579,20 @@ class TestGitRefView(BrowserTestCase):
550 [ref] = self.factory.makeGitRefs(paths=["refs/heads/branch"])579 [ref] = self.factory.makeGitRefs(paths=["refs/heads/branch"])
551 log = self.makeCommitLog()580 log = self.makeCommitLog()
552 self.hosting_fixture.getLog.result = list(reversed(log))581 self.hosting_fixture.getLog.result = list(reversed(log))
553 self.scanRef(ref, log[-1])582 # XXX jugmac00 2022-03-14
583 # This is a workaround for the limitation of `GitHostingFixture` not
584 # implementing a proper `getCommits` method.
585 # If we would not supply the following configuration file,
586 # `CIBuild.requestBuildsForRefs`, which is unrelated to this test case,
587 # would fail.
588 configuration = dedent("""\
589 pipeline: [test]
590 jobs:
591 test:
592 series: foo
593 architectures: ["bar"]
594 """)
595 self.scanRef(ref, log[-1], blobs={".launchpad.yaml": configuration})
554 view = create_initialized_view(ref, "+index")596 view = create_initialized_view(ref, "+index")
555 contents = view()597 contents = view()
556 expected_texts = list(reversed([598 expected_texts = list(reversed([
@@ -573,7 +615,20 @@ class TestGitRefView(BrowserTestCase):
573 [ref] = self.factory.makeGitRefs(paths=["refs/heads/branch"])615 [ref] = self.factory.makeGitRefs(paths=["refs/heads/branch"])
574 log = self.makeCommitLog()616 log = self.makeCommitLog()
575 self.hosting_fixture.getLog.result = list(reversed(log))617 self.hosting_fixture.getLog.result = list(reversed(log))
576 self.scanRef(ref, log[-1])618 # XXX jugmac00 2022-03-14
619 # This is a workaround for the limitation of `GitHostingFixture` not
620 # implementing a proper `getCommits` method.
621 # If we would not supply the following configuration file,
622 # `CIBuild.requestBuildsForRefs`, which is unrelated to this test case,
623 # would fail.
624 configuration = dedent("""\
625 pipeline: [test]
626 jobs:
627 test:
628 series: foo
629 architectures: ["bar"]
630 """)
631 self.scanRef(ref, log[-1], blobs={".launchpad.yaml": configuration})
577 mp = self.factory.makeBranchMergeProposalForGit(target_ref=ref)632 mp = self.factory.makeBranchMergeProposalForGit(target_ref=ref)
578 merged_tip = dict(log[-1])633 merged_tip = dict(log[-1])
579 merged_tip["sha1"] = six.ensure_text(634 merged_tip["sha1"] = six.ensure_text(
@@ -603,7 +658,20 @@ class TestGitRefView(BrowserTestCase):
603 [ref] = self.factory.makeGitRefs(paths=["refs/heads/branch"])658 [ref] = self.factory.makeGitRefs(paths=["refs/heads/branch"])
604 log = self.makeCommitLog()659 log = self.makeCommitLog()
605 self.hosting_fixture.getLog.result = list(reversed(log))660 self.hosting_fixture.getLog.result = list(reversed(log))
606 self.scanRef(ref, log[-1])661 # XXX jugmac00 2022-03-14
662 # This is a workaround for the limitation of `GitHostingFixture` not
663 # implementing a proper `getCommits` method.
664 # If we would not supply the following configuration file,
665 # `CIBuild.requestBuildsForRefs`, which is unrelated to this test case,
666 # would fail.
667 configuration = dedent("""\
668 pipeline: [test]
669 jobs:
670 test:
671 series: foo
672 architectures: ["bar"]
673 """)
674 self.scanRef(ref, log[-1], blobs={".launchpad.yaml": configuration})
607 mp = self.factory.makeBranchMergeProposalForGit(target_ref=ref)675 mp = self.factory.makeBranchMergeProposalForGit(target_ref=ref)
608 merged_tip = dict(log[-1])676 merged_tip = dict(log[-1])
609 merged_tip["sha1"] = six.ensure_text(677 merged_tip["sha1"] = six.ensure_text(
@@ -638,7 +706,20 @@ class TestGitRefView(BrowserTestCase):
638 log = self.makeCommitLog()706 log = self.makeCommitLog()
639 log[4]["author"]["email"] = "“%s”" % log[4]["author"]["email"]707 log[4]["author"]["email"] = "“%s”" % log[4]["author"]["email"]
640 self.hosting_fixture.getLog.result = list(reversed(log))708 self.hosting_fixture.getLog.result = list(reversed(log))
641 self.scanRef(ref, log[-1])709 # XXX jugmac00 2022-03-14
710 # This is a workaround for the limitation of `GitHostingFixture` not
711 # implementing a proper `getCommits` method.
712 # If we would not supply the following configuration file,
713 # `CIBuild.requestBuildsForRefs`, which is unrelated to this test case,
714 # would fail.
715 configuration = dedent("""\
716 pipeline: [test]
717 jobs:
718 test:
719 series: foo
720 architectures: ["bar"]
721 """)
722 self.scanRef(ref, log[-1], blobs={".launchpad.yaml": configuration})
642 view = create_initialized_view(ref, "+index")723 view = create_initialized_view(ref, "+index")
643 contents = view()724 contents = view()
644 expected_texts = ["%.7s...\non 2015-01-05" % log[4]["sha1"]]725 expected_texts = ["%.7s...\non 2015-01-05" % log[4]["sha1"]]
@@ -675,7 +756,20 @@ class TestGitRefView(BrowserTestCase):
675 [ref] = self.factory.makeGitRefs(paths=["refs/heads/%s" % branch_name])756 [ref] = self.factory.makeGitRefs(paths=["refs/heads/%s" % branch_name])
676 log = self.makeCommitLog()757 log = self.makeCommitLog()
677 self.hosting_fixture.getLog.result = list(reversed(log))758 self.hosting_fixture.getLog.result = list(reversed(log))
678 self.scanRef(ref, log[-1])759 # XXX jugmac00 2022-03-14
760 # This is a workaround for the limitation of `GitHostingFixture` not
761 # implementing a proper `getCommits` method.
762 # If we would not supply the following configuration file,
763 # `CIBuild.requestBuildsForRefs`, which is unrelated to this test case,
764 # would fail.
765 configuration = dedent("""\
766 pipeline: [test]
767 jobs:
768 test:
769 series: foo
770 architectures: ["bar"]
771 """)
772 self.scanRef(ref, log[-1], blobs={".launchpad.yaml": configuration})
679 view = create_initialized_view(ref, "+index")773 view = create_initialized_view(ref, "+index")
680 recent_commits_tag = soupmatchers.Tag(774 recent_commits_tag = soupmatchers.Tag(
681 'recent commits', 'div', attrs={'id': 'recent-commits'})775 'recent commits', 'div', attrs={'id': 'recent-commits'})
@@ -734,7 +828,20 @@ class TestGitRefView(BrowserTestCase):
734 self.useFixture(FakeLogger())828 self.useFixture(FakeLogger())
735 [ref] = self.factory.makeGitRefs()829 [ref] = self.factory.makeGitRefs()
736 log = self.makeCommitLog()830 log = self.makeCommitLog()
737 self.scanRef(ref, log[-1])831 # XXX jugmac00 2022-03-14
832 # This is a workaround for the limitation of `GitHostingFixture` not
833 # implementing a proper `getCommits` method.
834 # If we would not supply the following configuration file,
835 # `CIBuild.requestBuildsForRefs`, which is unrelated to this test case,
836 # would fail.
837 configuration = dedent("""\
838 pipeline: [test]
839 jobs:
840 test:
841 series: foo
842 architectures: ["bar"]
843 """)
844 self.scanRef(ref, log[-1], blobs={".launchpad.yaml": configuration})
738 self.hosting_fixture.getLog.failure = TimeoutError845 self.hosting_fixture.getLog.failure = TimeoutError
739 view = create_initialized_view(ref, "+index")846 view = create_initialized_view(ref, "+index")
740 contents = view()847 contents = view()
diff --git a/lib/lp/oci/tests/test_ocirecipe.py b/lib/lp/oci/tests/test_ocirecipe.py
index b3b4475..a697657 100644
--- a/lib/lp/oci/tests/test_ocirecipe.py
+++ b/lib/lp/oci/tests/test_ocirecipe.py
@@ -31,6 +31,7 @@ from zope.security.proxy import removeSecurityProxy
31from lp.app.enums import InformationType31from lp.app.enums import InformationType
32from lp.buildmaster.enums import BuildStatus32from lp.buildmaster.enums import BuildStatus
33from lp.buildmaster.interfaces.processor import IProcessorSet33from lp.buildmaster.interfaces.processor import IProcessorSet
34from lp.code.tests.helpers import GitHostingFixture
34from lp.oci.interfaces.ocipushrule import (35from lp.oci.interfaces.ocipushrule import (
35 IOCIPushRuleSet,36 IOCIPushRuleSet,
36 OCIPushRuleAlreadyExists,37 OCIPushRuleAlreadyExists,
@@ -1296,6 +1297,7 @@ class TestOCIRecipeSet(TestCaseWithFactory):
1296 def test_findByGitRepository(self):1297 def test_findByGitRepository(self):
1297 # IOCIRecipeSet.findByGitRepository returns all OCI recipes with the1298 # IOCIRecipeSet.findByGitRepository returns all OCI recipes with the
1298 # given Git repository.1299 # given Git repository.
1300 self.useFixture(GitHostingFixture())
1299 repositories = [self.factory.makeGitRepository() for i in range(2)]1301 repositories = [self.factory.makeGitRepository() for i in range(2)]
1300 oci_recipes = []1302 oci_recipes = []
1301 for repository in repositories:1303 for repository in repositories:
@@ -1338,6 +1340,7 @@ class TestOCIRecipeSet(TestCaseWithFactory):
1338 oci_recipes[0].git_ref.path, oci_recipes[1].git_ref.path]))1340 oci_recipes[0].git_ref.path, oci_recipes[1].git_ref.path]))
13391341
1340 def test_detachFromGitRepository(self):1342 def test_detachFromGitRepository(self):
1343 self.useFixture(GitHostingFixture())
1341 repositories = [self.factory.makeGitRepository() for i in range(2)]1344 repositories = [self.factory.makeGitRepository() for i in range(2)]
1342 oci_recipes = []1345 oci_recipes = []
1343 paths = []1346 paths = []

Subscribers

People subscribed via source and target branches

to status/vote changes: