launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #00937
lp:~jtv/launchpad/buildfarmjob-getspecificjob-translationtemplatesbuild into lp:launchpad
Jeroen T. Vermeulen has proposed merging lp:~jtv/launchpad/buildfarmjob-getspecificjob-translationtemplatesbuild into lp:launchpad with lp:~jtv/launchpad/translationtemplatesbuild as a prerequisite.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers): code
Related bugs:
#536819 Translation template jobs should keep history
https://bugs.launchpad.net/bugs/536819
= BuildFarmJob.getSpecificJob for TranslationTemplatesBuild =
Completes the work on today's update of the Translations buildfarm classes to the current model: make sure BuildFarmJob.getSpecificJob works for TranslationTemplateBuild objects.
Jeroen
--
https://code.launchpad.net/~jtv/launchpad/buildfarmjob-getspecificjob-translationtemplatesbuild/+merge/34965
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jtv/launchpad/buildfarmjob-getspecificjob-translationtemplatesbuild into lp:launchpad.
=== modified file 'lib/lp/translations/configure.zcml'
--- lib/lp/translations/configure.zcml 2010-09-09 11:26:45 +0000
+++ lib/lp/translations/configure.zcml 2010-09-09 11:26:46 +0000
@@ -609,6 +609,12 @@
component="lp.translations.model.translationtemplatesbuildjob.TranslationTemplatesBuildJob"
provides="lp.buildmaster.interfaces.buildfarmjob.IBuildFarmJob"
name="TRANSLATIONTEMPLATESBUILD"/>
+ <adapter
+ provides="lp.buildmaster.interfaces.buildfarmjob.ISpecificBuildFarmJob"
+ for="lp.buildmaster.interfaces.buildfarmjob.IBuildFarmJob"
+ factory="lp.translations.model.translationtemplatesbuild.get_translation_templates_build_for_build_farm_job"
+ name="TRANSLATIONTEMPLATESBUILD"
+ permission="zope.Public"/>
<!-- TranslationTemplatesBuild -->
<class
=== modified file 'lib/lp/translations/model/translationtemplatesbuild.py'
--- lib/lp/translations/model/translationtemplatesbuild.py 2010-09-09 11:26:45 +0000
+++ lib/lp/translations/model/translationtemplatesbuild.py 2010-09-09 11:26:46 +0000
@@ -13,10 +13,12 @@
Reference,
Storm,
)
+from storm.store import Store
from zope.interface import (
classProvides,
implements,
)
+from zope.security.proxy import ProxyFactory
from canonical.launchpad.interfaces.lpstorm import IMasterStore
from lp.buildmaster.model.buildfarmjob import BuildFarmJobDerived
@@ -69,3 +71,11 @@
self.branch, BranchJobType.TRANSLATION_TEMPLATES_BUILD, metadata)
store.add(branch_job)
return TranslationTemplatesBuildJob(branch_job)
+
+
+def get_translation_templates_build_for_build_farm_job(build_farm_job):
+ """Return a `TranslationTemplatesBuild` from its `BuildFarmJob`."""
+ build = Store.of(build_farm_job).find(
+ TranslationTemplatesBuild,
+ TranslationTemplatesBuild.build_farm_job == build_farm_job).one()
+ return ProxyFactory(build)
=== modified file 'lib/lp/translations/tests/test_translationtemplatesbuild.py'
--- lib/lp/translations/tests/test_translationtemplatesbuild.py 2010-09-09 11:26:45 +0000
+++ lib/lp/translations/tests/test_translationtemplatesbuild.py 2010-09-09 11:26:46 +0000
@@ -14,6 +14,7 @@
from lp.buildmaster.interfaces.buildfarmjob import (
IBuildFarmJob,
IBuildFarmJobSource,
+ ISpecificBuildFarmJob,
)
from lp.testing import TestCaseWithFactory
from lp.translations.interfaces.translationtemplatesbuild import (
@@ -52,6 +53,7 @@
self.assertTrue(verifyObject(ITranslationTemplatesBuild, build))
self.assertTrue(verifyObject(IBuildFarmJob, build))
+ self.assertTrue(verifyObject(ISpecificBuildFarmJob, build))
self.assertEqual(build_farm_job, build.build_farm_job)
self.assertEqual(branch, build.branch)
@@ -64,3 +66,11 @@
translationtemplatesbuildjob = jobset.create(branch)
self.assertNotEqual(None, self._findBuildForBranch(branch))
+
+ def test_getSpecificJob(self):
+ source = getUtility(ITranslationTemplatesBuildSource)
+ build_farm_job = self._makeBuildFarmJob()
+ branch = self.factory.makeBranch()
+ build = source.create(build_farm_job, branch)
+
+ self.assertEqual(build, build_farm_job.getSpecificJob())