← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:fix-oci-recipe-build-ui into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:fix-oci-recipe-build-ui into launchpad:master.

Commit message:
Add missing object formatter for OCIRecipe

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/382026

This fixes OCIRecipeBuild:+index.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:fix-oci-recipe-build-ui into launchpad:master.
diff --git a/lib/lp/app/browser/configure.zcml b/lib/lp/app/browser/configure.zcml
index 6573fb2..0fd4bed 100644
--- a/lib/lp/app/browser/configure.zcml
+++ b/lib/lp/app/browser/configure.zcml
@@ -1,4 +1,4 @@
-<!-- Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
+<!-- Copyright 2009-2020 Canonical Ltd.  This software is licensed under the
      GNU Affero General Public License version 3 (see the file LICENSE).
 -->
 
@@ -861,6 +861,12 @@
       name="fmt"
       />
   <adapter
+      for="lp.oci.interfaces.ocirecipe.IOCIRecipe"
+      provides="zope.traversing.interfaces.IPathAdapter"
+      factory="lp.app.browser.tales.OCIRecipeFormatterAPI"
+      name="fmt"
+      />
+  <adapter
       for="lp.snappy.interfaces.snap.ISnap"
       provides="zope.traversing.interfaces.IPathAdapter"
       factory="lp.app.browser.tales.SnapFormatterAPI"
diff --git a/lib/lp/app/browser/tales.py b/lib/lp/app/browser/tales.py
index 22bb6c4..df20fcb 100644
--- a/lib/lp/app/browser/tales.py
+++ b/lib/lp/app/browser/tales.py
@@ -1,4 +1,4 @@
-# Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2020 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Implementation of the lp: htmlform: fmt: namespaces in TALES."""
@@ -1905,6 +1905,20 @@ class LiveFSFormatterAPI(CustomizableFormatter):
                 'owner': self._context.owner.displayname}
 
 
+class OCIRecipeFormatterAPI(CustomizableFormatter):
+    """Adapter providing fmt support for IOCIRecipe objects."""
+
+    _link_summary_template = _(
+        'OCI recipe %(pillar_name)s/%(oci_project_name)s/%(recipe_name)s for '
+        '%(owner)s')
+
+    def _link_summary_values(self):
+        return {'pillar_name': self._context.oci_project.pillar.name,
+                'oci_project_name': self._context.oci_project.name,
+                'recipe_name': self._context.name,
+                'owner': self._context.owner.displayname}
+
+
 class SnapFormatterAPI(CustomizableFormatter):
     """Adapter providing fmt support for ISnap objects."""
 
diff --git a/lib/lp/oci/browser/tests/test_ocirecipebuild.py b/lib/lp/oci/browser/tests/test_ocirecipebuild.py
index 72f29e9..97afb77 100644
--- a/lib/lp/oci/browser/tests/test_ocirecipebuild.py
+++ b/lib/lp/oci/browser/tests/test_ocirecipebuild.py
@@ -20,7 +20,10 @@ from lp.testing import (
     BrowserTestCase,
     TestCaseWithFactory,
     )
-from lp.testing.layers import DatabaseFunctionalLayer
+from lp.testing.layers import (
+    DatabaseFunctionalLayer,
+    LaunchpadFunctionalLayer,
+    )
 from lp.testing.pages import (
     extract_text,
     find_main_content,
@@ -51,6 +54,32 @@ class TestCanonicalUrlForOCIRecipeBuild(TestCaseWithFactory):
                 "+recipe/recipe/+build/"))
 
 
+class TestOCIRecipeBuildView(BrowserTestCase):
+
+    layer = LaunchpadFunctionalLayer
+
+    def setUp(self):
+        super(TestOCIRecipeBuildView, self).setUp()
+        self.useFixture(FeatureFixture({OCI_RECIPE_ALLOW_CREATE: 'on'}))
+
+    def test_index(self):
+        build = self.factory.makeOCIRecipeBuild()
+        recipe = build.recipe
+        oci_project = recipe.oci_project
+        self.assertTextMatchesExpressionIgnoreWhitespace("""\
+            386 build of .*
+            created .*
+            Build status
+            Needs building
+            Build details
+            Recipe: OCI recipe %s/%s/%s for %s
+            Architecture: i386
+            """ % (
+                oci_project.pillar.name, oci_project.name, recipe.name,
+                recipe.owner.display_name),
+            self.getMainText(build))
+
+
 class TestOCIRecipeBuildOperations(BrowserTestCase):
 
     layer = DatabaseFunctionalLayer