launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #01055
[Merge] lp:~stevenk/launchpad/db-clean-up-lint-idsjob into lp:launchpad
Steve Kowalik has proposed merging lp:~stevenk/launchpad/db-clean-up-lint-idsjob into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
This branch just cleans up lint for the InitialiseDistroSeriesJob/DistributionJob code I landed earlier.
--
https://code.launchpad.net/~stevenk/launchpad/db-clean-up-lint-idsjob/+merge/35621
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/db-clean-up-lint-idsjob into lp:launchpad.
=== modified file 'lib/lp/soyuz/interfaces/distributionjob.py'
--- lib/lp/soyuz/interfaces/distributionjob.py 2010-09-01 07:58:43 +0000
+++ lib/lp/soyuz/interfaces/distributionjob.py 2010-09-16 01:42:50 +0000
@@ -13,7 +13,7 @@
from lazr.enum import DBEnumeratedType, DBItem
from zope.interface import Attribute, Interface
from zope.schema import Int, Object
-
+
from canonical.launchpad import _
from lp.services.job.interfaces.job import IJob, IJobSource, IRunnableJob
@@ -23,10 +23,10 @@
class IDistributionJob(Interface):
"""A Job that initialises acts on a distribution."""
-
+
id = Int(
- title=_('DB ID'), required=True, readonly=True,
- description=_("The tracking number for this job."))
+ title=_('DB ID'), required=True, readonly=True,
+ description=_("The tracking number for this job."))
distribution = Object(
title=_('The Distribution this job is about.'),
@@ -37,9 +37,9 @@
schema=IDistroSeries, required=False)
job = Object(
- title=_('The common Job attributes'), schema=IJob, required=True)
-
- metadata = Attribute('A dict of data about the job.')
+ title=_('The common Job attributes'), schema=IJob, required=True)
+
+ metadata = Attribute('A dict of data about the job.')
def destroySelf():
"""Destroy this object."""
@@ -64,4 +64,3 @@
class IInitialiseDistroSeriesJob(IRunnableJob):
"""A Job that performs actions on a distribution."""
-
=== modified file 'lib/lp/soyuz/model/distributionjob.py'
--- lib/lp/soyuz/model/distributionjob.py 2010-09-03 07:05:50 +0000
+++ lib/lp/soyuz/model/distributionjob.py 2010-09-16 01:42:50 +0000
@@ -13,14 +13,14 @@
from storm.base import Storm
from storm.locals import And, Int, Reference, Unicode
-from zope.component import getUtility
-from zope.interface import classProvides, implements
+from zope.interface import implements
from canonical.database.enumcol import EnumCol
from canonical.launchpad.interfaces.lpstorm import IStore
from lazr.delegates import delegates
-
+
+from lp.app.errors import NotFoundError
from lp.registry.model.distribution import Distribution
from lp.registry.model.distroseries import DistroSeries
from lp.soyuz.interfaces.distributionjob import (
@@ -80,12 +80,12 @@
:return: the DistributionJob with the specified id, as
the current DistributionJobDerived subclass.
- :raises: SQLObjectNotFound if there is no job with the specified id,
+ :raises: NotFoundError if there is no job with the specified id,
or its job_type does not match the desired subclass.
"""
job = DistributionJob.get(job_id)
if job.job_type != cls.class_job_type:
- raise SQLObjectNotFound(
+ raise NotFoundError(
'No object found with id %d and type %s' % (job_id,
cls.class_job_type.title))
return cls(job)
@@ -110,4 +110,3 @@
('distribution_job_type', self.context.job_type.title),
])
return vars
-
=== modified file 'lib/lp/soyuz/model/initialisedistroseriesjob.py'
--- lib/lp/soyuz/model/initialisedistroseriesjob.py 2010-09-03 07:05:50 +0000
+++ lib/lp/soyuz/model/initialisedistroseriesjob.py 2010-09-16 01:42:50 +0000
@@ -7,12 +7,10 @@
"InitialiseDistroSeriesJob",
]
-from zope.component import getUtility
from zope.interface import classProvides, implements
from canonical.launchpad.interfaces.lpstorm import IMasterStore
-from lp.services.job.model.job import Job
from lp.soyuz.interfaces.distributionjob import (
DistributionJobType,
IInitialiseDistroSeriesJob,
@@ -48,4 +46,3 @@
ids = InitialiseDistroSeries(self.distroseries)
ids.check()
ids.initialise()
-
=== modified file 'lib/lp/soyuz/tests/test_initialisedistroseriesjob.py'
--- lib/lp/soyuz/tests/test_initialisedistroseriesjob.py 2010-09-03 07:05:50 +0000
+++ lib/lp/soyuz/tests/test_initialisedistroseriesjob.py 2010-09-16 01:42:50 +0000
@@ -18,7 +18,7 @@
class InitialiseDistroSeriesJobTests(TestCaseWithFactory):
"""Test case for InitialiseDistroSeriesJob."""
-
+
layer = LaunchpadZopelessLayer
def test_getOopsVars(self):
@@ -35,12 +35,12 @@
def _getJobs(self):
"""Return the pending InitialiseDistroSeriesJobs as a list."""
return list(InitialiseDistroSeriesJob.iterReady())
-
+
def _getJobCount(self):
"""Return the number of InitialiseDistroSeriesJobs in the
queue."""
return len(self._getJobs())
-
+
def test_create_only_creates_one(self):
distroseries = self.factory.makeDistroSeries()
# If there's already a InitialiseDistroSeriesJob for a
@@ -49,7 +49,7 @@
job = getUtility(IInitialiseDistroSeriesJobSource).create(
distroseries)
transaction.commit()
-
+
# There will now be one job in the queue.
self.assertEqual(1, self._getJobCount())