launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #00728
[Merge] lp:~michael.nelson/launchpad/distro-series-difference-model into lp:launchpad
Michael Nelson has proposed merging lp:~michael.nelson/launchpad/distro-series-difference-model into lp:launchpad with lp:~michael.nelson/launchpad/distro-series-difference-schema as a prerequisite.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Just an in-progress MP for discussion atm.
Possible new model to support:
https://dev.launchpad.net/LEP/DerivativeDistributions
--
https://code.launchpad.net/~michael.nelson/launchpad/distro-series-difference-model/+merge/33516
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~michael.nelson/launchpad/distro-series-difference-model into lp:launchpad.
=== modified file 'lib/lp/registry/configure.zcml'
--- lib/lp/registry/configure.zcml 2010-08-23 03:25:20 +0000
+++ lib/lp/registry/configure.zcml 2010-08-24 12:54:48 +0000
@@ -102,6 +102,13 @@
date_last_modified
person"/>
</class>
+
+ <!-- DistroSeriesDifference -->
+ <securedutility
+ component="lp.registry.model.distroseriesdifference.DistroSeriesDifference"
+ provides="lp.registry.interfaces.distroseriesdifference.IDistroSeriesDifferenceSource">
+ <allow interface="lp.registry.interfaces.distroseriesdifference.IDistroSeriesDifferenceSource"/>
+ </securedutility>
<class
class="lp.registry.model.distroseries.DistroSeries">
<allow
=== modified file 'lib/lp/registry/enum.py'
--- lib/lp/registry/enum.py 2010-08-20 20:31:18 +0000
+++ lib/lp/registry/enum.py 2010-08-24 12:54:48 +0000
@@ -6,6 +6,7 @@
__metaclass__ = type
__all__ = [
'BugNotificationLevel',
+ 'DistroSeriesDifferenceStatus',
]
from lazr.enum import (
@@ -47,3 +48,29 @@
notifications about new events in the bugs's discussion, like new
comments.
""")
+
+
+class DistroSeriesDifferenceStatus(DBEnumeratedType):
+ """Distribution series difference status.
+
+ The status of a package difference between two DistroSeries.
+ """
+
+ NEEDS_ATTENTION = DBItem(1, """
+ Needs attention
+
+ This difference is current and needs attention.
+ """)
+
+ IGNORED = DBItem(2, """
+ Ignored
+
+ This difference is being ignored until a new package is uploaded
+ or the status is manually updated.
+ """)
+
+ IGNORED_ALWAYS = DBItem(3, """
+ Ignored always
+
+ This difference should always be ignored.
+ """)
=== added file 'lib/lp/registry/exceptions.py'
--- lib/lp/registry/exceptions.py 1970-01-01 00:00:00 +0000
+++ lib/lp/registry/exceptions.py 2010-08-24 12:54:48 +0000
@@ -0,0 +1,17 @@
+# Copyright 2010 Canonical Ltd. This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""Exceptions for the Registry app."""
+
+__metaclass__ = type
+__all__ = [
+ 'NotADerivedSeriesError',
+ ]
+
+
+class NotADerivedSeriesError(Exception):
+ """A distro series difference must be created with a derived series.
+
+ This is raised when a DistroSeriesDifference is created with a
+ non-derived series - that is, a distroseries with a null Parent."""
+
=== added file 'lib/lp/registry/interfaces/distroseriesdifference.py'
--- lib/lp/registry/interfaces/distroseriesdifference.py 1970-01-01 00:00:00 +0000
+++ lib/lp/registry/interfaces/distroseriesdifference.py 2010-08-24 12:54:48 +0000
@@ -0,0 +1,79 @@
+# Copyright 2010 Canonical Ltd. This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""Interface classes for a difference between two distribution series."""
+
+__metaclass__ = type
+
+
+__all__ = [
+ 'IDistroSeriesDifference',
+ ]
+
+from lazr.restful.fields import Reference
+from zope.interface import Interface
+from zope.schema import (
+ Choice,
+ Int,
+ Text,
+ )
+
+from canonical.launchpad import _
+from lp.registry.enum import DistroSeriesDifferenceStatus
+from lp.registry.interfaces.distroseries import IDistroSeries
+from lp.soyuz.interfaces.publishing import ISourcePackagePublishingHistory
+
+
+class IDistroSeriesDifference(Interface):
+ """An interface for a package difference between two distroseries."""
+
+ id = Int(title=_('ID'), required=True, readonly=True)
+
+ derived_series = Reference(
+ IDistroSeries, title=_("Derived series"), required=True,
+ readonly=True, description=_(
+ "The distribution series which, together with its parent, "
+ "identifies the two series with the difference."))
+
+ source_package = Reference(
+ ISourcePackagePublishingHistory,
+ title=_("Source package"), required=False,
+ readonly=True, description=_(
+ "The package in this distribution series."))
+
+ parent_source_package = Reference(
+ ISourcePackagePublishingHistory,
+ title=_("Parent source package"), required=False,
+ readonly=True, description=_(
+ "The package in the parent distribution series."))
+
+ comment = Text(
+ title=_('Custom information about the current status of this '
+ 'difference'), required=False, readonly=False)
+
+ status = Choice(
+ title=_('Distro series difference status.'),
+ description=_('The current status of this difference.'),
+ vocabulary=DistroSeriesDifferenceStatus,
+ required=True, readonly=False)
+
+
+class IDistroSeriesDifferenceSource(Interface):
+ """A utility of this interface can be used to create differences."""
+
+ def new(derived_series, source_package=None, parent_source_package=None,
+ status=DistroSeriesDifferenceStatus.NEEDS_ATTENTION):
+ """Create an `IDistroSeriesDifference`.
+
+ :param derived_series: The distribution series which was derived
+ from a parent. If a series without a parent is passed an
+ exception is raised.
+ :type derived_series: `IDistroSeries`.
+ :param source_package: A source package in the derived series.
+ :type source_package: `ISourcePackagePublishingHistory`.
+ :param parent_source_package: A source package in the parent series.
+ :type source_package: `ISourcePackagePublishingHistory`.
+ :param status: The current status of this difference.
+ :type status: `DistorSeriesDifferenceStatus`.
+ """
+
=== added file 'lib/lp/registry/model/distroseriesdifference.py'
--- lib/lp/registry/model/distroseriesdifference.py 1970-01-01 00:00:00 +0000
+++ lib/lp/registry/model/distroseriesdifference.py 2010-08-24 12:54:48 +0000
@@ -0,0 +1,69 @@
+# Copyright 2010 Canonical Ltd. This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""Database classes for a difference between two distribution series."""
+
+__metaclass__ = type
+
+__all__ = [
+ 'DistroSeriesDifference',
+ ]
+
+from storm.locals import (
+ Int,
+ Reference,
+ Storm,
+ Unicode,
+ )
+from zope.interface import implements
+
+from canonical.database.enumcol import DBEnum
+from canonical.launchpad.interfaces.lpstorm import IMasterStore
+from lp.registry.enum import DistroSeriesDifferenceStatus
+from lp.registry.exceptions import NotADerivedSeriesError
+from lp.registry.interfaces.distroseriesdifference import (
+ IDistroSeriesDifference,
+ )
+
+
+class DistroSeriesDifference(Storm):
+ """See `DistroSeriesDifference`."""
+ implements(IDistroSeriesDifference)
+ __storm_table__ = 'DistroSeriesDifference'
+
+ id = Int(primary=True)
+
+ derived_series_id = Int(name='derived_series', allow_none=False)
+ derived_series = Reference(
+ derived_series_id, 'DistroSeries.id')
+
+ source_package_id = Int(
+ name='source_package_publishing_history', allow_none=True)
+ source_package = Reference(
+ source_package_id,
+ 'SourcePackagePublishingHistory.id')
+
+ parent_source_package_id = Int(
+ name='parent_source_package_publishing_history', allow_none=True)
+ parent_source_package = Reference(
+ parent_source_package_id,
+ 'SourcePackagePublishingHistory.id')
+
+ comment = Unicode(name='comment', allow_none=True)
+ status = DBEnum(name='status', allow_none=False,
+ enum=DistroSeriesDifferenceStatus)
+
+ @staticmethod
+ def new(derived_series, source_package=None, parent_source_package=None,
+ status=DistroSeriesDifferenceStatus.NEEDS_ATTENTION):
+ """See `IDistroSeriesDifference`."""
+ if derived_series.parent_series is None:
+ raise NotADerivedSeriesError()
+
+ store = IMasterStore(DistroSeriesDifference)
+ diff = DistroSeriesDifference()
+ diff.derived_series = derived_series
+ diff.source_package = source_package
+ diff.parent_source_package = parent_source_package
+ diff.status = DistroSeriesDifferenceStatus.NEEDS_ATTENTION
+ return store.add(diff)
=== added file 'lib/lp/registry/tests/test_distroseriesdifference.py'
--- lib/lp/registry/tests/test_distroseriesdifference.py 1970-01-01 00:00:00 +0000
+++ lib/lp/registry/tests/test_distroseriesdifference.py 2010-08-24 12:54:48 +0000
@@ -0,0 +1,43 @@
+# Copyright 2010 Canonical Ltd. This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""Model tests for the DistroSeriesDifference class."""
+
+__metaclass__ = type
+
+import unittest
+
+from canonical.launchpad.webapp.testing import verifyObject
+from canonical.testing import DatabaseFunctionalLayer
+from lp.testing import TestCaseWithFactory
+from lp.registry.exceptions import NotADerivedSeriesError
+from lp.registry.interfaces.distroseriesdifference import (
+ IDistroSeriesDifference,
+ )
+
+
+class DistroSeriesDifferenceTestCase(TestCaseWithFactory):
+
+ layer = DatabaseFunctionalLayer
+
+ def test_implements_interface(self):
+ # The implementation implements the interface correctly.
+ ds_diff = self.factory.makeDistroSeriesDifference()
+
+ verifyObject(IDistroSeriesDifference, ds_diff)
+
+ def test_at_least_one_source_package(self):
+ self.fail('Not implemented. Waiting on implementation feedback.')
+
+ def test_new_non_derived_series(self):
+ # A DistroSeriesDifference cannot be created with a non-derived
+ # series.
+ distro_series = self.factory.makeDistroSeries()
+ self.assertRaises(
+ NotADerivedSeriesError,
+ self.factory.makeDistroSeriesDifference,
+ derived_series=distro_series)
+
+
+def test_suite():
+ return unittest.TestLoader().loadTestsFromName(__name__)
=== modified file 'lib/lp/testing/factory.py'
--- lib/lp/testing/factory.py 2010-08-23 08:12:39 +0000
+++ lib/lp/testing/factory.py 2010-08-24 12:54:48 +0000
@@ -158,10 +158,17 @@
MirrorSpeed,
)
from lp.registry.interfaces.distroseries import IDistroSeries
+<<<<<<< TREE
from lp.registry.interfaces.gpg import (
GPGKeyAlgorithm,
IGPGKeySet,
)
+=======
+from lp.registry.interfaces.distroseriesdifference import (
+ IDistroSeriesDifferenceSource,
+ )
+from lp.registry.interfaces.gpg import GPGKeyAlgorithm, IGPGKeySet
+>>>>>>> MERGE-SOURCE
from lp.registry.interfaces.mailinglist import (
IMailingListSet,
MailingListStatus,
@@ -1807,6 +1814,26 @@
# Most people think of distro releases as distro series.
makeDistroSeries = makeDistroRelease
+ def makeDistroSeriesDifference(self, derived_series=None,
+ source_package=None,
+ parent_source_package=None):
+ """Create a new distro series source package difference."""
+ parent_series=None
+ if derived_series is None:
+ parent_series = self.makeDistroSeries()
+ derived_series = self.makeDistroSeries(
+ parent_series=parent_series)
+ if source_package is None:
+ source_package = self.makeSourcePackagePublishingHistory(
+ distroseries=derived_series)
+ if parent_source_package is None:
+ sp_name = source_package.sourcepackagerelease.sourcepackagename
+ parent_source_package = self.makeSourcePackagePublishingHistory(
+ distroseries=parent_series, sourcepackagename=sp_name)
+
+ return getUtility(IDistroSeriesDifferenceSource).new(
+ derived_series, source_package, parent_source_package)
+
def makeDistroArchSeries(self, distroseries=None,
architecturetag=None, processorfamily=None,
official=True, owner=None,