Merge ~cjwatson/launchpad:charmrecipebuild-traversal into launchpad:master

Proposed by Colin Watson
Status: Needs review
Proposed branch: ~cjwatson/launchpad:charmrecipebuild-traversal
Merge into: launchpad:master
Diff against target: 60 lines (+24/-0)
2 files modified
lib/lp/buildmaster/browser/builder.py (+8/-0)
lib/lp/buildmaster/browser/tests/test_builder.py (+16/-0)
Reviewer Review Type Date Requested Status
Jürgen Gmach Approve
Review via email: mp+448363@code.launchpad.net

Commit message

Add +charmrecipebuild stepthrough navigation on BuilderSet

Description of the change

This is useful when repairing the build farm after outages, or otherwise needing to look up a charm recipe build by its ID alone. It goes with similar stepthroughs for other build types.

Compare the very similar https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/417863.

To post a comment you must log in.
Revision history for this message
Jürgen Gmach (jugmac00) wrote :

Can you think of a place where to document this?

review: Approve

Unmerged commits

b2cff53... by Colin Watson

Add +charmrecipebuild stepthrough navigation on BuilderSet

This is useful when repairing the build farm after outages, or otherwise
needing to look up a charm recipe build by its ID alone. It goes with
similar stepthroughs for other build types.

Succeeded
[SUCCEEDED] docs:0 (build)
[SUCCEEDED] lint:0 (build)
[SUCCEEDED] mypy:0 (build)
13 of 3 results

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/buildmaster/browser/builder.py b/lib/lp/buildmaster/browser/builder.py
2index a45ab35..60c65fb 100644
3--- a/lib/lp/buildmaster/browser/builder.py
4+++ b/lib/lp/buildmaster/browser/builder.py
5@@ -36,6 +36,7 @@ from lp.app.widgets.itemswidgets import LabeledMultiCheckBoxWidget
6 from lp.app.widgets.owner import HiddenUserWidget
7 from lp.app.widgets.textwidgets import DelimitedListWidget
8 from lp.buildmaster.interfaces.builder import IBuilder, IBuilderSet
9+from lp.charms.interfaces.charmrecipebuild import ICharmRecipeBuildSet
10 from lp.code.interfaces.cibuild import ICIBuildSet
11 from lp.code.interfaces.sourcepackagerecipebuild import (
12 ISourcePackageRecipeBuildSource,
13@@ -101,6 +102,13 @@ class BuilderSetNavigation(GetitemNavigation):
14 return None
15 return self.redirectSubTree(canonical_url(build, request=self.request))
16
17+ @stepthrough("+charmrecipebuild")
18+ def traverse_charmrecipebuild(self, name):
19+ build = get_build_by_id_str(ICharmRecipeBuildSet, name)
20+ if build is None:
21+ return None
22+ return self.redirectSubTree(canonical_url(build, request=self.request))
23+
24 @stepthrough("+cibuild")
25 def traverse_cibuild(self, name):
26 build = get_build_by_id_str(ICIBuildSet, name)
27diff --git a/lib/lp/buildmaster/browser/tests/test_builder.py b/lib/lp/buildmaster/browser/tests/test_builder.py
28index a582dc7..4ca44bb 100644
29--- a/lib/lp/buildmaster/browser/tests/test_builder.py
30+++ b/lib/lp/buildmaster/browser/tests/test_builder.py
31@@ -13,6 +13,7 @@ from lp.buildmaster.browser.tests.test_builder_views import BuildCreationMixin
32 from lp.buildmaster.enums import BuilderCleanStatus, BuildStatus
33 from lp.buildmaster.interfaces.builder import IBuilderSet
34 from lp.buildmaster.model.builder import Builder
35+from lp.charms.interfaces.charmrecipe import CHARM_RECIPE_ALLOW_CREATE
36 from lp.oci.interfaces.ocirecipe import OCI_RECIPE_ALLOW_CREATE
37 from lp.services.database.interfaces import IStore
38 from lp.services.database.sqlbase import get_transaction_timestamp
39@@ -108,6 +109,21 @@ class TestBuilderSetNavigation(TestCaseWithFactory):
40 browser.open(url)
41 self.assertEqual(expected_url, browser.url)
42
43+ def test_charm_recipe_build_api_redirects(self):
44+ self.useFixture(FeatureFixture({CHARM_RECIPE_ALLOW_CREATE: "on"}))
45+ build = self.factory.makeCharmRecipeBuild()
46+ url = (
47+ "http://api.launchpad.test/devel/builders/+charmrecipebuild/%s"
48+ % build.id
49+ )
50+ expected_url = "http://api.launchpad.test/devel" + canonical_url(
51+ build, path_only_if_possible=True
52+ )
53+ logout()
54+ browser = setupBrowser()
55+ browser.open(url)
56+ self.assertEqual(expected_url, browser.url)
57+
58 def test_ci_build_api_redirects(self):
59 build = self.factory.makeCIBuild()
60 url = "http://api.launchpad.test/devel/builders/+cibuild/%s" % build.id

Subscribers

People subscribed via source and target branches

to status/vote changes: