Merge lp:~jtv/launchpad/translationtemplatesbuild into lp:launchpad/db-devel

Proposed by Jeroen T. Vermeulen
Status: Merged
Approved by: Jeroen T. Vermeulen
Approved revision: no longer in the source branch.
Merged at revision: 9793
Proposed branch: lp:~jtv/launchpad/translationtemplatesbuild
Merge into: lp:launchpad/db-devel
Diff against target: 423 lines (+242/-23)
12 files modified
database/schema/comments.sql (+5/-0)
database/schema/patch-2208-99-0.sql (+17/-0)
database/schema/security.cfg (+2/-0)
lib/lp/buildmaster/model/buildfarmjob.py (+1/-1)
lib/lp/code/doc/branch.txt (+1/-0)
lib/lp/code/model/branch.py (+9/-7)
lib/lp/translations/configure.zcml (+11/-0)
lib/lp/translations/interfaces/translationtemplatesbuild.py (+39/-0)
lib/lp/translations/model/translationtemplatesbuild.py (+71/-0)
lib/lp/translations/model/translationtemplatesbuildbehavior.py (+4/-2)
lib/lp/translations/model/translationtemplatesbuildjob.py (+16/-13)
lib/lp/translations/tests/test_translationtemplatesbuild.py (+66/-0)
To merge this branch: bzr merge lp:~jtv/launchpad/translationtemplatesbuild
Reviewer Review Type Date Requested Status
Stuart Bishop (community) db Approve
Michael Nelson (community) code Approve
Robert Collins db Pending
Review via email: mp+34952@code.launchpad.net

Commit message

TranslationTemplatesBuild.

Description of the change

= TranslationTemplatesBuild =

Buildfarm work. This creates a new TranslationTemplatesBuild class, which holds a reference to BuildFarmJob as per…

    http://people.ubuntu.com/~wgrant/launchpad/buildfarm/new-build-model-again.png

Until we actually move over to the new data model, the TranslationTemplatesBuild objects are created from the factory for the old TranslationTemplatesBuildJob. I also create the BuildFarmJob object in there, as I've seen in other build classes; we may want to move that into the TranslationTemplatesBuild factory later but doing it this way should maximize our flexibility if someone else entirely is (or will be) responsible for creating them.

The big picture I may still be missing is who's responsible for creating what objects. Implementing makeJob for the old-style setup triggered some upheaval in the TranslationTemplatesBuildJob factory, and now I'm not sure the BuildQueue is created in the right place, the specific job isn't being created redundantly elsewhere, etc.

Jeroen

To post a comment you must log in.
Revision history for this message
Michael Nelson (michael.nelson) wrote :

We did this review from a paste while LP was down. In summary, r=me assuming you'll not land this until you've got a second branch that ensures the builder (current builds/history) pages display these correctly (ie. you'll need to ensure BFJ.getSpecificJob() finds the appropriate adapted.

Thanks!

10:09 < jtv> noodles775: thanks for the review btw… I _would_ point you to my buildfarm work now, but Maintenance. :
/
10:10 * noodles775 breathes a sigh of relief ;)
10:11 < noodles775> jtv: if you can paste your MP (and a diff), I can do that too :)
10:13 < jtv> noodles775: the MP is at https://code.edge.launchpad.net/~jtv/launchpad/translationtemplatesbuild/+merge
/34952
10:13 < noodles775> jtv: sorry, I meant paste the text of your MP to paste.....com :)
10:13 < jtv> noodles775: yes, I'm otp so a little slow sorry :)
10:22 < jtv> noodles775: my diff is here: http://paste.ubuntu.com/490815/
10:31 < noodles775> jtv: Was that a decision to allow both interfaces for TranslationTemplateBuild via ZCML (rather t
han having ITranslationTemplatesBuild inherit from IBuildFarmJob - like IPackageBuild does)?
10:32 < jtv> noodles775: barely registered. :) I tend to avoid interface hierarchies because they can get a little confusing in combination with class hierarchies, but if that's wrong I'll happily change it.
10:32 < jtv> (not that zcml can't get a little confusing…)
10:33 < noodles775> I'm not sure if its better or worse... I think of it with the question: Is the interface ITranslationTemplatesBuild also an IBuildFarmJob? I'm not fussed either, I was just surprised.
10:34 < jtv> We're sort of probing the boundaries between is-a and has-a here, aren't we?
10:35 < jtv> I guess in python we're doing inheritance, just not in the db—in which case perhaps I should change this after all.
11:09 < noodles775> jtv: sheesh, it'll be nice to get rid of the BFJOld stuff (and makeJob). A question, in your makeJob() method, you don't add the TTBJ to the store... am I missing something? I'm wondering if you meant to call TTBJ.create() there?
11:10 < jtv> noodles775: ah good point, thanks
11:11 < jtv> noodles775: ah! Actually I do add it to the store.
11:11 < jtv> noodles775: in terms of db storage, the BranchJob _is_ the TTBJ
11:31 < noodles775> jtv: ah, so TTBJ isn't a storm class itself. Right.
11:31 < jtv> just one more reason to clean out these stables :)
11:41 < noodles775> jtv: so r=me, assuming that you won't be landing this without further branches (ie. to ensure BFJ.getSpecificJob() works for TranslationTemplatesBuild.
11:41 < noodles775> Thanks!
11:42 < jtv> noodles775: that's actually a lot more than I was hoping for, thanks! Any other points I need to cover?
11:43 < noodles775> jtv: er, you could refactor the code and get rid of IBuildFarmJobOld? ;)
11:44 < noodles775> I can't think of any other things... the above will make it self apparent when you look at current builders or builder histories after having dispatched TTBs.
11:45 < noodles775> (sorry, where "the above" is ensuring BFJ.getSpecificJob() works for the translation template builds)
11:45 < jtv> OK, so I'll move on to that next then.

review: Approve (code)
Revision history for this message
Stuart Bishop (stub) wrote :

Fine. Our naming 'standards' don't quite cope with this table, so I'll let it pass (TranslationTemplatesBuild vs. TranslationTemplateBuild).

patch-2208-13-0.sql

review: Approve (db)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'database/schema/comments.sql'
--- database/schema/comments.sql 2010-09-09 16:53:16 +0000
+++ database/schema/comments.sql 2010-09-10 11:48:51 +0000
@@ -839,6 +839,11 @@
839COMMENT ON COLUMN TranslationRelicensingAgreement.allow_relicensing IS 'Does this person want their translations relicensed under BSD.';839COMMENT ON COLUMN TranslationRelicensingAgreement.allow_relicensing IS 'Does this person want their translations relicensed under BSD.';
840COMMENT ON COLUMN TranslationRelicensingAgreement.date_decided IS 'Date when the last change of opinion was registered.';840COMMENT ON COLUMN TranslationRelicensingAgreement.date_decided IS 'Date when the last change of opinion was registered.';
841841
842-- TranslationTemplatesBuild
843COMMENT ON TABLE TranslationTemplatesBuild IS 'Build-farm record of a translation templates build.';
844COMMENT ON COLUMN TranslationTemplatesBuild.build_farm_job IS 'Associated BuildFarmJob.';
845COMMENT ON COLUMN TranslationTemplatesBuild.branch IS 'Branch to build templates out of.';
846
842-- RevisionAuthor847-- RevisionAuthor
843COMMENT ON TABLE RevisionAuthor IS 'All distinct authors for revisions.';848COMMENT ON TABLE RevisionAuthor IS 'All distinct authors for revisions.';
844COMMENT ON COLUMN RevisionAuthor.name IS 'The exact text extracted from the branch revision.';849COMMENT ON COLUMN RevisionAuthor.name IS 'The exact text extracted from the branch revision.';
845850
=== added file 'database/schema/patch-2208-99-0.sql'
--- database/schema/patch-2208-99-0.sql 1970-01-01 00:00:00 +0000
+++ database/schema/patch-2208-99-0.sql 2010-09-10 11:48:51 +0000
@@ -0,0 +1,17 @@
1-- Copyright 2010 Canonical Ltd. This software is licensed under the
2-- GNU Affero General Public License version 3 (see the file LICENSE).
3
4SET client_min_messages=ERROR;
5
6CREATE TABLE TranslationTemplatesBuild (
7 id SERIAL PRIMARY KEY,
8 build_farm_job integer NOT NULL REFERENCES BuildFarmJob(id),
9 branch integer NOT NULL REFERENCES Branch(id));
10
11CREATE INDEX translationtemplatesbuild__build_farm_job__idx ON
12 TranslationTemplatesBuild(build_farm_job);
13
14CREATE INDEX translationtemplatesbuild__branch__idx ON
15 TranslationTemplatesBuild(branch);
16
17INSERT INTO LaunchpadDatabaseRevision VALUES (2208, 99, 0);
018
=== modified file 'database/schema/security.cfg'
--- database/schema/security.cfg 2010-09-10 02:46:28 +0000
+++ database/schema/security.cfg 2010-09-10 11:48:51 +0000
@@ -276,6 +276,7 @@
276public.translationgroup = SELECT, INSERT, UPDATE276public.translationgroup = SELECT, INSERT, UPDATE
277public.translationimportqueueentry = SELECT, INSERT, UPDATE, DELETE277public.translationimportqueueentry = SELECT, INSERT, UPDATE, DELETE
278public.translationmessage = SELECT, INSERT, UPDATE278public.translationmessage = SELECT, INSERT, UPDATE
279public.translationtemplatesbuild = SELECT, INSERT, DELETE
279public.translator = SELECT, INSERT, UPDATE, DELETE280public.translator = SELECT, INSERT, UPDATE, DELETE
280public.usertouseremail = SELECT, UPDATE281public.usertouseremail = SELECT, UPDATE
281public.validpersoncache = SELECT282public.validpersoncache = SELECT
@@ -1436,6 +1437,7 @@
1436[translationsbranchscanner]1437[translationsbranchscanner]
1437type=user1438type=user
1438groups=branchscanner,translations_approval1439groups=branchscanner,translations_approval
1440public.translationtemplatesbuild = SELECT, INSERT
14391441
1440[translationstobranch]1442[translationstobranch]
1441type=user1443type=user
14421444
=== modified file 'lib/lp/buildmaster/model/buildfarmjob.py'
--- lib/lp/buildmaster/model/buildfarmjob.py 2010-08-30 15:00:23 +0000
+++ lib/lp/buildmaster/model/buildfarmjob.py 2010-09-10 11:48:51 +0000
@@ -272,7 +272,7 @@
272 return self.date_finished - self.date_started272 return self.date_finished - self.date_started
273273
274 def makeJob(self):274 def makeJob(self):
275 """See `IBuildFarmJob`."""275 """See `IBuildFarmJobOld`."""
276 raise NotImplementedError276 raise NotImplementedError
277277
278 def jobStarted(self):278 def jobStarted(self):
279279
=== modified file 'lib/lp/code/doc/branch.txt'
--- lib/lp/code/doc/branch.txt 2010-07-26 09:15:31 +0000
+++ lib/lp/code/doc/branch.txt 2010-09-10 11:48:51 +0000
@@ -379,6 +379,7 @@
379 sourcepackagerecipedata.base_branch379 sourcepackagerecipedata.base_branch
380 sourcepackagerecipedatainstruction.branch380 sourcepackagerecipedatainstruction.branch
381 specificationbranch.branch381 specificationbranch.branch
382 translationtemplatesbuild.branch
382383
383(Unfortunately, references can form a cycle-- note that codereviewcomments384(Unfortunately, references can form a cycle-- note that codereviewcomments
384 aren't shown.)385 aren't shown.)
385386
=== modified file 'lib/lp/code/model/branch.py'
--- lib/lp/code/model/branch.py 2010-09-03 11:54:23 +0000
+++ lib/lp/code/model/branch.py 2010-09-10 11:48:51 +0000
@@ -26,7 +26,6 @@
26 And,26 And,
27 Count,27 Count,
28 Desc,28 Desc,
29 Max,
30 NamedFunc,29 NamedFunc,
31 Not,30 Not,
32 Or,31 Or,
@@ -59,11 +58,6 @@
59 IPrivacy,58 IPrivacy,
60 )59 )
61from canonical.launchpad.webapp import urlappend60from canonical.launchpad.webapp import urlappend
62from canonical.launchpad.webapp.interfaces import (
63 IStoreSelector,
64 MAIN_STORE,
65 SLAVE_FLAVOR,
66 )
67from lp.app.errors import UserCannotUnsubscribePerson61from lp.app.errors import UserCannotUnsubscribePerson
68from lp.buildmaster.model.buildqueue import BuildQueue62from lp.buildmaster.model.buildqueue import BuildQueue
69from lp.code.bzr import (63from lp.code.bzr import (
@@ -1023,10 +1017,14 @@
1023 """Delete jobs for this branch prior to deleting branch.1017 """Delete jobs for this branch prior to deleting branch.
10241018
1025 This deletion includes `BranchJob`s associated with the branch,1019 This deletion includes `BranchJob`s associated with the branch,
1026 as well as `BuildQueue` entries for `TranslationTemplateBuildJob`s.1020 as well as `BuildQueue` entries for `TranslationTemplateBuildJob`s
1021 and `TranslationTemplateBuild`s.
1027 """1022 """
1028 # Avoid circular imports.1023 # Avoid circular imports.
1029 from lp.code.model.branchjob import BranchJob1024 from lp.code.model.branchjob import BranchJob
1025 from lp.translations.model.translationtemplatesbuild import (
1026 TranslationTemplatesBuild,
1027 )
10301028
1031 store = Store.of(self)1029 store = Store.of(self)
1032 affected_jobs = Select(1030 affected_jobs = Select(
@@ -1040,6 +1038,10 @@
1040 # Delete Jobs. Their BranchJobs cascade along in the database.1038 # Delete Jobs. Their BranchJobs cascade along in the database.
1041 store.find(Job, Job.id.is_in(affected_jobs)).remove()1039 store.find(Job, Job.id.is_in(affected_jobs)).remove()
10421040
1041 store.find(
1042 TranslationTemplatesBuild,
1043 TranslationTemplatesBuild.branch == self).remove()
1044
1043 def destroySelf(self, break_references=False):1045 def destroySelf(self, break_references=False):
1044 """See `IBranch`."""1046 """See `IBranch`."""
1045 from lp.code.interfaces.branchjob import IReclaimBranchSpaceJobSource1047 from lp.code.interfaces.branchjob import IReclaimBranchSpaceJobSource
10461048
=== modified file 'lib/lp/translations/configure.zcml'
--- lib/lp/translations/configure.zcml 2010-08-19 02:11:43 +0000
+++ lib/lp/translations/configure.zcml 2010-09-10 11:48:51 +0000
@@ -610,6 +610,17 @@
610 provides="lp.buildmaster.interfaces.buildfarmjob.IBuildFarmJob"610 provides="lp.buildmaster.interfaces.buildfarmjob.IBuildFarmJob"
611 name="TRANSLATIONTEMPLATESBUILD"/>611 name="TRANSLATIONTEMPLATESBUILD"/>
612612
613 <!-- TranslationTemplatesBuild -->
614 <class
615 class="lp.translations.model.translationtemplatesbuild.TranslationTemplatesBuild">
616 <allow interface="lp.translations.interfaces.translationtemplatesbuild.ITranslationTemplatesBuild"/>
617 </class>
618 <securedutility
619 component="lp.translations.model.translationtemplatesbuild.TranslationTemplatesBuild"
620 provides="lp.translations.interfaces.translationtemplatesbuild.ITranslationTemplatesBuildSource">
621 <allow interface="lp.translations.interfaces.translationtemplatesbuild.ITranslationTemplatesBuildSource"/>
622 </securedutility>
623
613 <!-- TranslationTemplateBuildBehavior -->624 <!-- TranslationTemplateBuildBehavior -->
614 <class625 <class
615 class="lp.translations.model.translationtemplatesbuildbehavior.TranslationTemplatesBuildBehavior">626 class="lp.translations.model.translationtemplatesbuildbehavior.TranslationTemplatesBuildBehavior">
616627
=== added file 'lib/lp/translations/interfaces/translationtemplatesbuild.py'
--- lib/lp/translations/interfaces/translationtemplatesbuild.py 1970-01-01 00:00:00 +0000
+++ lib/lp/translations/interfaces/translationtemplatesbuild.py 2010-09-10 11:48:51 +0000
@@ -0,0 +1,39 @@
1# Copyright 2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).
3
4"""Interface and utility for `TranslationTemplatesBuild`."""
5
6__metaclass__ = type
7__all__ = [
8 'ITranslationTemplatesBuild',
9 'ITranslationTemplatesBuildSource',
10 ]
11
12from lazr.restful.fields import Reference
13from zope.interface import Interface
14
15from canonical.launchpad import _
16from lp.buildmaster.interfaces.buildfarmjob import IBuildFarmJob
17from lp.code.interfaces.branch import IBranch
18
19
20class ITranslationTemplatesBuild(IBuildFarmJob):
21 """The build information for translation templates builds."""
22
23 build_farm_job = Reference(
24 title=_("The build farm job that this extends."),
25 required=True, readonly=True, schema=IBuildFarmJob)
26
27 branch = Reference(
28 title=_("The branch that this build operates on."),
29 required=True, readonly=True, schema=IBranch)
30
31
32class ITranslationTemplatesBuildSource(Interface):
33 """Utility for `ITranslationTemplatesBuild`."""
34
35 def create(build_farm_job, branch):
36 """Create a new `ITranslationTemplatesBuild`."""
37
38 def findByBranch(branch):
39 """Find `ITranslationTemplatesBuild`s for `branch`."""
040
=== added file 'lib/lp/translations/model/translationtemplatesbuild.py'
--- lib/lp/translations/model/translationtemplatesbuild.py 1970-01-01 00:00:00 +0000
+++ lib/lp/translations/model/translationtemplatesbuild.py 2010-09-10 11:48:51 +0000
@@ -0,0 +1,71 @@
1# Copyright 2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).
3
4"""`TranslationTemplatesBuild` class."""
5
6__metaclass__ = type
7__all__ = [
8 'TranslationTemplatesBuild',
9 ]
10
11from storm.locals import (
12 Int,
13 Reference,
14 Storm,
15 )
16from zope.interface import (
17 classProvides,
18 implements,
19 )
20
21from canonical.launchpad.interfaces.lpstorm import IMasterStore
22from lp.buildmaster.model.buildfarmjob import BuildFarmJobDerived
23from lp.code.model.branchjob import (
24 BranchJob,
25 BranchJobType,
26 )
27from lp.translations.interfaces.translationtemplatesbuild import (
28 ITranslationTemplatesBuild,
29 ITranslationTemplatesBuildSource,
30 )
31from lp.translations.model.translationtemplatesbuildjob import (
32 TranslationTemplatesBuildJob,
33 )
34
35
36class TranslationTemplatesBuild(BuildFarmJobDerived, Storm):
37 """A `BuildFarmJob` extension for translation templates builds."""
38
39 implements(ITranslationTemplatesBuild)
40 classProvides(ITranslationTemplatesBuildSource)
41
42 __storm_table__ = 'TranslationTemplatesBuild'
43
44 id = Int(primary=True)
45 build_farm_job_id = Int(name='build_farm_job', allow_none=False)
46 build_farm_job = Reference(build_farm_job_id, 'BuildFarmJob.id')
47 branch_id = Int(name='branch', allow_none=False)
48 branch = Reference(branch_id, 'Branch.id')
49
50 def __init__(self, build_farm_job, branch):
51 super(TranslationTemplatesBuild, self).__init__()
52 self.build_farm_job = build_farm_job
53 self.branch = branch
54
55 @classmethod
56 def create(self, build_farm_job, branch):
57 """See `ITranslationTemplatesBuildSource`."""
58 build = TranslationTemplatesBuild(build_farm_job, branch)
59 IMasterStore(TranslationTemplatesBuild).add(build)
60 return build
61
62 def makeJob(self):
63 """See `IBuildFarmJobOld`."""
64 store = IMasterStore(BranchJob)
65
66 # Pass public HTTP URL for the branch.
67 metadata = {'branch_url': self.branch.composePublicURL()}
68 branch_job = BranchJob(
69 self.branch, BranchJobType.TRANSLATION_TEMPLATES_BUILD, metadata)
70 store.add(branch_job)
71 return TranslationTemplatesBuildJob(branch_job)
072
=== modified file 'lib/lp/translations/model/translationtemplatesbuildbehavior.py'
--- lib/lp/translations/model/translationtemplatesbuildbehavior.py 2010-08-20 20:31:18 +0000
+++ lib/lp/translations/model/translationtemplatesbuildbehavior.py 2010-09-10 11:48:51 +0000
@@ -44,8 +44,10 @@
44 self._builder.slave.cacheFile(logger, chroot)44 self._builder.slave.cacheFile(logger, chroot)
45 cookie = self.buildfarmjob.generateSlaveBuildCookie()45 cookie = self.buildfarmjob.generateSlaveBuildCookie()
4646
47 args = {'arch_tag': self._getDistroArchSeries().architecturetag}47 args = {
48 args.update(self.buildfarmjob.metadata)48 'arch_tag': self._getDistroArchSeries().architecturetag,
49 'branch_url': self.buildfarmjob.branch.composePublicURL(),
50 }
4951
50 filemap = {}52 filemap = {}
5153
5254
=== modified file 'lib/lp/translations/model/translationtemplatesbuildjob.py'
--- lib/lp/translations/model/translationtemplatesbuildjob.py 2010-08-27 15:03:18 +0000
+++ lib/lp/translations/model/translationtemplatesbuildjob.py 2010-09-10 11:48:51 +0000
@@ -25,6 +25,7 @@
25 )25 )
26from lp.buildmaster.enums import BuildFarmJobType26from lp.buildmaster.enums import BuildFarmJobType
27from lp.buildmaster.interfaces.buildfarmbranchjob import IBuildFarmBranchJob27from lp.buildmaster.interfaces.buildfarmbranchjob import IBuildFarmBranchJob
28from lp.buildmaster.interfaces.buildfarmjob import IBuildFarmJobSource
28from lp.buildmaster.interfaces.buildqueue import IBuildQueueSet29from lp.buildmaster.interfaces.buildqueue import IBuildQueueSet
29from lp.buildmaster.model.buildfarmjob import (30from lp.buildmaster.model.buildfarmjob import (
30 BuildFarmJobOld,31 BuildFarmJobOld,
@@ -37,6 +38,9 @@
37 BranchJobDerived,38 BranchJobDerived,
38 BranchJobType,39 BranchJobType,
39 )40 )
41from lp.translations.interfaces.translationtemplatesbuild import (
42 ITranslationTemplatesBuildSource,
43 )
40from lp.translations.interfaces.translationtemplatesbuildjob import (44from lp.translations.interfaces.translationtemplatesbuildjob import (
41 ITranslationTemplatesBuildJobSource,45 ITranslationTemplatesBuildJobSource,
42 )46 )
@@ -128,25 +132,24 @@
128 @classmethod132 @classmethod
129 def create(cls, branch):133 def create(cls, branch):
130 """See `ITranslationTemplatesBuildJobSource`."""134 """See `ITranslationTemplatesBuildJobSource`."""
131 store = IMasterStore(BranchJob)
132
133 # Pass public HTTP URL for the branch.
134 metadata = {'branch_url': branch.composePublicURL()}
135 branch_job = BranchJob(
136 branch, BranchJobType.TRANSLATION_TEMPLATES_BUILD, metadata)
137 store.add(branch_job)
138 specific_job = TranslationTemplatesBuildJob(branch_job)
139 duration_estimate = cls.duration_estimate
140
141 # XXX Danilo Segan bug=580429: we hard-code processor to the Ubuntu135 # XXX Danilo Segan bug=580429: we hard-code processor to the Ubuntu
142 # default processor architecture. This stops the buildfarm from136 # default processor architecture. This stops the buildfarm from
143 # accidentally dispatching the jobs to private builders.137 # accidentally dispatching the jobs to private builders.
138 processor = cls._getBuildArch()
139
140 build_farm_job = getUtility(IBuildFarmJobSource).new(
141 BuildFarmJobType.TRANSLATIONTEMPLATESBUILD, processor=processor)
142 build = getUtility(ITranslationTemplatesBuildSource).create(
143 build_farm_job, branch)
144
145 specific_job = build.makeJob()
146 duration_estimate = cls.duration_estimate
147
144 build_queue_entry = BuildQueue(148 build_queue_entry = BuildQueue(
145 estimated_duration=duration_estimate,149 estimated_duration=duration_estimate,
146 job_type=BuildFarmJobType.TRANSLATIONTEMPLATESBUILD,150 job_type=BuildFarmJobType.TRANSLATIONTEMPLATESBUILD,
147 job=specific_job.job.id,151 job=specific_job.job, processor=processor)
148 processor=cls._getBuildArch())152 IMasterStore(BuildQueue).add(build_queue_entry)
149 store.add(build_queue_entry)
150153
151 return specific_job154 return specific_job
152155
153156
=== added file 'lib/lp/translations/tests/test_translationtemplatesbuild.py'
--- lib/lp/translations/tests/test_translationtemplatesbuild.py 1970-01-01 00:00:00 +0000
+++ lib/lp/translations/tests/test_translationtemplatesbuild.py 2010-09-10 11:48:51 +0000
@@ -0,0 +1,66 @@
1# Copyright 2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).
3
4"""`TranslationTemplatesBuild` tests."""
5
6__metaclass__ = type
7
8from storm.store import Store
9from zope.component import getUtility
10from zope.interface.verify import verifyObject
11
12from canonical.testing import DatabaseFunctionalLayer
13from lp.buildmaster.enums import BuildFarmJobType
14from lp.buildmaster.interfaces.buildfarmjob import (
15 IBuildFarmJob,
16 IBuildFarmJobSource,
17 )
18from lp.testing import TestCaseWithFactory
19from lp.translations.interfaces.translationtemplatesbuild import (
20 ITranslationTemplatesBuild,
21 ITranslationTemplatesBuildSource,
22 )
23from lp.translations.model.translationtemplatesbuild import (
24 TranslationTemplatesBuild,
25 )
26from lp.translations.interfaces.translationtemplatesbuildjob import (
27 ITranslationTemplatesBuildJobSource,
28 )
29
30
31class TestTranslationTemplatesBuild(TestCaseWithFactory):
32
33 layer = DatabaseFunctionalLayer
34
35 def _findBuildForBranch(self, branch):
36 """Find the `TranslationTemplatesBuild` for `branch`, if any."""
37 return Store.of(branch).find(
38 TranslationTemplatesBuild,
39 TranslationTemplatesBuild.branch == branch).one()
40
41 def _makeBuildFarmJob(self):
42 """Create a `BuildFarmJob` for testing."""
43 source = getUtility(IBuildFarmJobSource)
44 return source.new(BuildFarmJobType.TRANSLATIONTEMPLATESBUILD)
45
46 def test_baseline(self):
47 source = getUtility(ITranslationTemplatesBuildSource)
48 branch = self.factory.makeBranch()
49 build_farm_job = self._makeBuildFarmJob()
50
51 build = source.create(build_farm_job, branch)
52
53 self.assertTrue(verifyObject(ITranslationTemplatesBuild, build))
54 self.assertTrue(verifyObject(IBuildFarmJob, build))
55 self.assertEqual(build_farm_job, build.build_farm_job)
56 self.assertEqual(branch, build.branch)
57
58 def test_created_by_buildjobsource(self):
59 # ITranslationTemplatesBuildJobSource.create also creates a
60 # TranslationTemplatesBuild. This utility will become obsolete
61 # later.
62 jobset = getUtility(ITranslationTemplatesBuildJobSource)
63 branch = self.factory.makeBranch()
64
65 translationtemplatesbuildjob = jobset.create(branch)
66 self.assertNotEqual(None, self._findBuildForBranch(branch))

Subscribers

People subscribed via source and target branches

to status/vote changes: