launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #30343
[Merge] ~cjwatson/launchpad:charmrecipebuild-traversal into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:charmrecipebuild-traversal into launchpad:master.
Commit message:
Add +charmrecipebuild stepthrough navigation on BuilderSet
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/448363
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.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:charmrecipebuild-traversal into launchpad:master.
diff --git a/lib/lp/buildmaster/browser/builder.py b/lib/lp/buildmaster/browser/builder.py
index a45ab35..60c65fb 100644
--- a/lib/lp/buildmaster/browser/builder.py
+++ b/lib/lp/buildmaster/browser/builder.py
@@ -36,6 +36,7 @@ from lp.app.widgets.itemswidgets import LabeledMultiCheckBoxWidget
from lp.app.widgets.owner import HiddenUserWidget
from lp.app.widgets.textwidgets import DelimitedListWidget
from lp.buildmaster.interfaces.builder import IBuilder, IBuilderSet
+from lp.charms.interfaces.charmrecipebuild import ICharmRecipeBuildSet
from lp.code.interfaces.cibuild import ICIBuildSet
from lp.code.interfaces.sourcepackagerecipebuild import (
ISourcePackageRecipeBuildSource,
@@ -101,6 +102,13 @@ class BuilderSetNavigation(GetitemNavigation):
return None
return self.redirectSubTree(canonical_url(build, request=self.request))
+ @stepthrough("+charmrecipebuild")
+ def traverse_charmrecipebuild(self, name):
+ build = get_build_by_id_str(ICharmRecipeBuildSet, name)
+ if build is None:
+ return None
+ return self.redirectSubTree(canonical_url(build, request=self.request))
+
@stepthrough("+cibuild")
def traverse_cibuild(self, name):
build = get_build_by_id_str(ICIBuildSet, name)
diff --git a/lib/lp/buildmaster/browser/tests/test_builder.py b/lib/lp/buildmaster/browser/tests/test_builder.py
index a582dc7..4ca44bb 100644
--- a/lib/lp/buildmaster/browser/tests/test_builder.py
+++ b/lib/lp/buildmaster/browser/tests/test_builder.py
@@ -13,6 +13,7 @@ from lp.buildmaster.browser.tests.test_builder_views import BuildCreationMixin
from lp.buildmaster.enums import BuilderCleanStatus, BuildStatus
from lp.buildmaster.interfaces.builder import IBuilderSet
from lp.buildmaster.model.builder import Builder
+from lp.charms.interfaces.charmrecipe import CHARM_RECIPE_ALLOW_CREATE
from lp.oci.interfaces.ocirecipe import OCI_RECIPE_ALLOW_CREATE
from lp.services.database.interfaces import IStore
from lp.services.database.sqlbase import get_transaction_timestamp
@@ -108,6 +109,21 @@ class TestBuilderSetNavigation(TestCaseWithFactory):
browser.open(url)
self.assertEqual(expected_url, browser.url)
+ def test_charm_recipe_build_api_redirects(self):
+ self.useFixture(FeatureFixture({CHARM_RECIPE_ALLOW_CREATE: "on"}))
+ build = self.factory.makeCharmRecipeBuild()
+ url = (
+ "http://api.launchpad.test/devel/builders/+charmrecipebuild/%s"
+ % build.id
+ )
+ expected_url = "http://api.launchpad.test/devel" + canonical_url(
+ build, path_only_if_possible=True
+ )
+ logout()
+ browser = setupBrowser()
+ browser.open(url)
+ self.assertEqual(expected_url, browser.url)
+
def test_ci_build_api_redirects(self):
build = self.factory.makeCIBuild()
url = "http://api.launchpad.test/devel/builders/+cibuild/%s" % build.id