launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #24067
[Merge] ~twom/launchpad:oci-recipe-targetseries into launchpad:master
Tom Wardill has proposed merging ~twom/launchpad:oci-recipe-targetseries into launchpad:master with ~twom/launchpad:oci-recipe-target as a prerequisite.
Commit message:
Add implementation for OCIRecipeTargetSeries
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~twom/launchpad/+git/launchpad/+merge/374036
Adds interface, model, tests, zcml and security.cfg changes for OCIRecipeTargetSeries
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~twom/launchpad:oci-recipe-targetseries into launchpad:master.
diff --git a/database/schema/security.cfg b/database/schema/security.cfg
index 5e27806..4f05694 100644
--- a/database/schema/security.cfg
+++ b/database/schema/security.cfg
@@ -1240,6 +1240,7 @@ public.milestone = SELECT, INSERT, UPDATE
public.openididentifier = SELECT
public.ocirecipename = SELECT, INSERT, UPDATE
public.ocirecipetarget = SELECT, INSERT, UPDATE, DELETE
+public.ocirecipetargetseries = SELECT, INSERT, UPDATE
public.packageupload = SELECT, INSERT, UPDATE
public.packageuploadbuild = SELECT, INSERT, UPDATE
public.packageuploadcustom = SELECT, INSERT, UPDATE
@@ -1417,6 +1418,7 @@ public.milestone = SELECT
public.milestonetag = SELECT
public.ocirecipename = SELECT
public.ocirecipetarget = SELECT
+public.ocirecipetargetseries = SELECT
public.openididentifier = SELECT
public.packagecopyjob = SELECT, INSERT
public.packagediff = SELECT, INSERT, UPDATE, DELETE
@@ -1535,6 +1537,7 @@ public.milestone = SELECT
public.milestonetag = SELECT
public.ocirecipename = SELECT
public.ocirecipetarget = SELECT
+public.ocirecipetargetseries = SELECT
public.openididentifier = SELECT
public.packagecopyjob = SELECT, INSERT, UPDATE
public.packagediff = SELECT, UPDATE
@@ -1639,6 +1642,7 @@ public.milestone = SELECT
public.milestonetag = SELECT
public.ocirecipename = SELECT
public.ocirecipetarget = SELECT
+public.ocirecipetargetseries = SELECT
public.person = SELECT
public.personlanguage = SELECT
public.personsettings = SELECT
@@ -1842,6 +1846,7 @@ public.milestone = SELECT
public.milestonetag = SELECT, INSERT, DELETE
public.ocirecipename = SELECT
public.ocirecipetarget = SELECT
+public.ocirecipetargetseries = SELECT
public.openididentifier = SELECT
public.packageset = SELECT
public.packagesetgroup = SELECT
@@ -1963,6 +1968,7 @@ public.message = SELECT, INSERT
public.messagechunk = SELECT, INSERT
public.ocirecipename = SELECT
public.ocirecipetarget = SELECT
+public.ocirecipetargetseries = SELECT
public.openididentifier = SELECT
public.person = SELECT
public.product = SELECT
@@ -2022,6 +2028,7 @@ public.messagechunk = SELECT, INSERT
public.milestone = SELECT
public.ocirecipename = SELECT
public.ocirecipetarget = SELECT
+public.ocirecipetargetseries = SELECT
public.person = SELECT
public.personsettings = SELECT
public.previewdiff = SELECT, INSERT
@@ -2160,6 +2167,7 @@ public.messagechunk = SELECT, INSERT
public.milestonetag = SELECT
public.ocirecipename = SELECT
public.ocirecipetarget = SELECT
+public.ocirecipetargetseries = SELECT
public.person = SELECT, INSERT
public.personsettings = SELECT, INSERT
public.product = SELECT, INSERT, UPDATE
@@ -2549,6 +2557,7 @@ public.gitrepository = SELECT
public.job = SELECT, INSERT, UPDATE
public.ocirecipename = SELECT
public.ocirecipetarget = SELECT
+public.ocirecipetargetseries = SELECT
public.person = SELECT
public.packaging = SELECT
public.product = SELECT, UPDATE
@@ -2573,6 +2582,7 @@ public.distribution = SELECT
public.distroseries = SELECT
public.ocirecipename = SELECT
public.ocirecipetarget = SELECT
+public.ocirecipetargetseries = SELECT
public.product = SELECT
public.productseries = SELECT
public.sourcepackagename = SELECT
@@ -2586,6 +2596,7 @@ public.gitrepository = SELECT
public.job = SELECT, UPDATE
public.ocirecipename = SELECT
public.ocirecipetarget = SELECT
+public.ocirecipetargetseries = SELECT
public.person = SELECT
public.product = SELECT
public.snap = SELECT
diff --git a/lib/lp/registry/configure.zcml b/lib/lp/registry/configure.zcml
index d03b8f7..a22cb2a 100644
--- a/lib/lp/registry/configure.zcml
+++ b/lib/lp/registry/configure.zcml
@@ -758,6 +758,26 @@
interface="lp.registry.interfaces.ocirecipetarget.IOCIRecipeTargetSet"/>
</securedutility>
+ <!-- OCIRecipeTargetSeries -->
+ <class
+ class="lp.registry.model.ocirecipetargetseries.OCIRecipeTargetSeries">
+ <allow
+ interface="lp.registry.interfaces.ocirecipetargetseries.IOCIRecipeTargetSeries"/>
+ </class>
+
+ <!-- OCIRecipeTargetSeriesSet -->
+ <securedutility
+ class="lp.registry.model.ocirecipetargetseries.OCIRecipeTargetSeriesSet"
+ provides="lp.registry.interfaces.ocirecipetargetseries.IOCIRecipeTargetSeriesSet">
+ <allow
+ interface="lp.registry.interfaces.ocirecipetargetseries.IOCIRecipeTargetSeriesSet"/>
+ </securedutility>
+ <class
+ class="lp.registry.model.ocirecipetargetseries.OCIRecipeTargetSeriesSet">
+ <allow
+ interface="lp.registry.interfaces.ocirecipetargetseries.IOCIRecipeTargetSeriesSet"/>
+ </class>
+
<!-- SourcePackageName -->
<class
diff --git a/lib/lp/registry/interfaces/ocirecipetargetseries.py b/lib/lp/registry/interfaces/ocirecipetargetseries.py
new file mode 100644
index 0000000..fc5df30
--- /dev/null
+++ b/lib/lp/registry/interfaces/ocirecipetargetseries.py
@@ -0,0 +1,48 @@
+# Copyright 2019 Canonical Ltd. This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""Interface implementing `OCIRecipeTargetSeries`."""
+
+from __future__ import absolute_import, print_function, unicode_literals
+
+__metaclass__ = type
+__all__ = [
+ 'IOCIRecipeTargetSeries',
+ 'IOCIRecipeTargetSeriesSet'
+ ]
+
+from lazr.restful.fields import Reference
+from zope.interface import Interface
+from zope.schema import (
+ Int,
+ TextLine,
+ )
+
+from lp import _
+from lp.app.validators.name import name_validator
+from lp.registry.interfaces.ocirecipetarget import IOCIRecipeTarget
+
+
+class IOCIRecipeTargetSeries(Interface):
+ """A series of an Open Container Initiative recipe target,
+ used to allow tracking bugs against multiple versions of images.
+ """
+
+ id = Int(title=_("ID"), required=True, readonly=True)
+
+ ocirecipetarget = Reference(
+ IOCIRecipeTarget,
+ title=_("The target that this series belongs to."),
+ required=True)
+
+ name = TextLine(
+ title=_("Name"), constraint=name_validator,
+ required=True, readonly=False,
+ description=_("The name of this series."))
+
+
+class IOCIRecipeTargetSeriesSet(Interface):
+ """A set of OCIRecipeTargetSeries."""
+
+ def new(ocirecipetarget, name):
+ """Create a new `OCIRecipeTargetSeries`."""
diff --git a/lib/lp/registry/model/ocirecipetargetseries.py b/lib/lp/registry/model/ocirecipetargetseries.py
new file mode 100644
index 0000000..42f2cda
--- /dev/null
+++ b/lib/lp/registry/model/ocirecipetargetseries.py
@@ -0,0 +1,60 @@
+# Copyright 2019 Canonical Ltd. This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""Model implementing `OCIRecipeTargetSeries`."""
+
+from __future__ import absolute_import, print_function, unicode_literals
+
+__metaclass__ = type
+__all__ = [
+ 'OCIRecipeTargetSeries',
+ ]
+
+from storm.locals import (
+ Int,
+ Reference,
+ Unicode,
+ )
+from zope.interface import implementer
+
+from lp.app.validators.name import valid_name
+from lp.registry.errors import InvalidName
+from lp.registry.interfaces.ocirecipetargetseries import (
+ IOCIRecipeTargetSeries,
+ IOCIRecipeTargetSeriesSet,
+ )
+from lp.services.database.interfaces import IMasterStore
+from lp.services.database.stormbase import StormBase
+
+
+@implementer(IOCIRecipeTargetSeries)
+class OCIRecipeTargetSeries(StormBase):
+ """See `IOCIRecipeTargetSeries`."""
+
+ __storm_table__ = "OCIRecipeTargetSeries"
+
+ id = Int(primary=True)
+
+ ocirecipetarget_id = Int(name='ocirecipetarget', allow_none=False)
+ ocirecipetarget = Reference(ocirecipetarget_id, "OCIRecipeTarget.id")
+
+ name = Unicode(name="name", allow_none=False)
+
+ def __init__(self, ocirecipetarget, name):
+ if not valid_name(name):
+ raise InvalidName(
+ "%s is not a valid name for an OCI recipe series." % name)
+ self.name = name
+ self.ocirecipetarget = ocirecipetarget
+
+
+@implementer(IOCIRecipeTargetSeriesSet)
+class OCIRecipeTargetSeriesSet:
+ """See `IOCIRecipeTargetSeriesSet`."""
+
+ def new(self, ocirecipetarget, name):
+ """See `IOCIRecipeTargetSeriesSet`."""
+ store = IMasterStore(OCIRecipeTargetSeries)
+ target_series = OCIRecipeTargetSeries(ocirecipetarget, name)
+ store.add(target_series)
+ return target_series
diff --git a/lib/lp/registry/tests/test_ocirecipetargetseries.py b/lib/lp/registry/tests/test_ocirecipetargetseries.py
new file mode 100644
index 0000000..d3307b5
--- /dev/null
+++ b/lib/lp/registry/tests/test_ocirecipetargetseries.py
@@ -0,0 +1,52 @@
+# Copyright 2019 Canonical Ltd. This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""Test OCIRecipeTargetSeries."""
+
+from __future__ import absolute_import, print_function, unicode_literals
+
+__metaclass__ = type
+
+from zope.component import getUtility
+
+from lp.registry.interfaces.ocirecipetargetseries import (
+ IOCIRecipeTargetSeries,
+ IOCIRecipeTargetSeriesSet,
+ )
+from lp.registry.model.ocirecipetargetseries import OCIRecipeTargetSeries
+from lp.testing import TestCaseWithFactory
+from lp.testing.layers import DatabaseFunctionalLayer
+
+
+class TestOCIRecipeTargetSeries(TestCaseWithFactory):
+
+ layer = DatabaseFunctionalLayer
+
+ def test_implements_interface(self):
+ recipe_target = self.factory.makeOCIRecipeTarget()
+ target_series = OCIRecipeTargetSeries(recipe_target, 'test-name')
+ self.assertProvides(target_series, IOCIRecipeTargetSeries)
+
+ def test_init(self):
+ name = 'test-name'
+ recipe_target = self.factory.makeOCIRecipeTarget()
+ target_series = OCIRecipeTargetSeries(recipe_target, name)
+ self.assertEqual(recipe_target, target_series.ocirecipetarget)
+ self.assertEqual(name, target_series.name)
+
+
+class TestOCIRecipeTargetSeriesSet(TestCaseWithFactory):
+
+ layer = DatabaseFunctionalLayer
+
+ def test_implements_interface(self):
+ target_series_set = getUtility(IOCIRecipeTargetSeriesSet)
+ self.assertProvides(target_series_set, IOCIRecipeTargetSeriesSet)
+
+ def test_new(self):
+ name = 'test-name'
+ recipe_target = self.factory.makeOCIRecipeTarget()
+ target_series = getUtility(IOCIRecipeTargetSeriesSet).new(
+ recipe_target, name)
+ self.assertEqual(recipe_target, target_series.ocirecipetarget)
+ self.assertEqual(name, target_series.name)
Follow ups