Merge lp:~henninge/launchpad/recife-pofile-creation into lp:~launchpad/launchpad/recife

Proposed by Henning Eggers
Status: Merged
Merged at revision: 9165
Proposed branch: lp:~henninge/launchpad/recife-pofile-creation
Merge into: lp:~launchpad/launchpad/recife
Diff against target: 160 lines (+81/-13)
1 file modified
lib/lp/translations/tests/test_pofile.py (+81/-13)
To merge this branch: bzr merge lp:~henninge/launchpad/recife-pofile-creation
Reviewer Review Type Date Requested Status
Jeroen T. Vermeulen (community) Approve
Review via email: mp+33800@code.launchpad.net

Description of the change

This is a follow-up to this merge:
https://code.launchpad.net/~henninge/launchpad/bug-545354-enable-sharing/+merge/27123

It add tests that show that when a new POFile is created, it is also created in sharing sourcepackages and upstream projects. POTemplate._createPOFilesInSharingPOTemplates uses POTemplateSharingSubset.getSharingPOTemplates which implements finding sharing templates across source packages and upstream projects.

Run the new tests like this:

bin/test -vvcm lp.translations.tests.test_pofile -t test_pofile_creation_shared_

To post a comment you must log in.
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

Honourable of you to come back and add the tests. As per IRC, a few notes:
 * These templates are "sharing," not "shared." Because they share POTMsgSets, not because anyone shares the POTemplates.
 * You mention a POTemplate's name being "the same." Same as what?
 * Avoid looking up warty and hoary in the sample data. Just create new series.
 * Try shortcutting some of the setup by having your first makeSourcePackage call create your SourcePackageName (and perhaps DistroSeries) implicitly.
 * One of the missing articles in the test_pofile_creation_shared_in_ubuntu comment is confusing.

Apart from that, r=me.

review: Approve
Revision history for this message
Henning Eggers (henninge) wrote :

Am 27.08.2010 09:35, schrieb Jeroen T. Vermeulen:
> Review: Approve
> Honourable of you to come back and add the tests. As per IRC, a few notes:

Well, the original task was to implement this but I found that it already was
- just not tested... ;-)

> * These templates are "sharing," not "shared." Because they share POTMsgSets, not because anyone shares the POTemplates.
> * You mention a POTemplate's name being "the same." Same as what?
> * Avoid looking up warty and hoary in the sample data. Just create new series.

Did all these.

> * Try shortcutting some of the setup by having your first makeSourcePackage call create your SourcePackageName (and perhaps DistroSeries) implicitly.

Did a little of that.

> * One of the missing articles in the test_pofile_creation_shared_in_ubuntu comment is confusing.

Fixed.

>
> Apart from that, r=me.

Thank you very much!

Henning

1=== modified file 'lib/lp/translations/tests/test_pofile.py'
2--- lib/lp/translations/tests/test_pofile.py 2010-08-26 16:20:09 +0000
3+++ lib/lp/translations/tests/test_pofile.py 2010-08-27 10:03:01 +0000
4@@ -239,7 +239,7 @@
5 # Test the canonical_url of the POFile.
6 pofile_url = (
7 'http://translations.launchpad.dev/foo/devel/+pots/messages/'
8- '%s' % self.devel_pofile.language.code )
9+ '%s' % self.devel_pofile.language.code)
10 self.assertEqual(pofile_url, canonical_url(self.devel_pofile))
11 view_name = '+details'
12 view_url = "%s/%s" % (pofile_url, view_name)
13@@ -919,15 +919,15 @@
14 "Diverged translation")])
15
16
17-class TestSharedPOFileCreation(TestCaseWithFactory):
18- """Test that POFiles are created in shared POTemplates."""
19+class TestSharingPOFileCreation(TestCaseWithFactory):
20+ """Test that POFiles are created in sharing POTemplates."""
21
22 layer = ZopelessDatabaseLayer
23
24 def setUp(self):
25- # Create a product with two series and a shared POTemplate
26+ # Create a product with two series and a sharing POTemplate
27 # in different series ('devel' and 'stable').
28- super(TestSharedPOFileCreation, self).setUp()
29+ super(TestSharingPOFileCreation, self).setUp()
30 self.foo = self.factory.makeProduct()
31 self.foo_devel = self.factory.makeProductSeries(
32 name='devel', product=self.foo)
33@@ -935,10 +935,10 @@
34 name='stable', product=self.foo)
35 self.foo.official_rosetta = True
36
37- def test_pofile_creation_shared(self):
38+ def test_pofile_creation_sharing(self):
39 # When a pofile is created in a POTemplate it is also created in
40- # all shared templates.
41- # POTemplate is 'shared' if it has the same name ('messages').
42+ # all sharing templates.
43+ # Two POTemplates are sharing if they have the same name ('messages').
44 devel_potemplate = self.factory.makePOTemplate(
45 productseries=self.foo_devel, name="messages")
46 stable_potemplate = self.factory.makePOTemplate(
47@@ -951,18 +951,20 @@
48 self.assertEqual(pofile_devel.language.code,
49 pofile_stable.language.code)
50
51- def test_pofile_creation_shared_upstream(self):
52+ def test_pofile_creation_sharing_upstream(self):
53 # When a pofile is created in a POTemplate of an Ubuntu package
54 # it is also created in all shared templates in the upstream project.
55 # POTemplate is 'shared' if it has the same name ('messages').
56 ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
57- hoary = ubuntu ['hoary']
58- packagename = self.factory.makeSourcePackageName()
59- sourcepackage = self.factory.makeSourcePackage(packagename, hoary)
60+ distroseries = self.factory.makeDistroSeries(distribution=ubuntu)
61+ ubuntu.translation_focus = distroseries
62+ sourcepackage = self.factory.makeSourcePackage(
63+ distroseries=distroseries)
64 sourcepackage.setPackaging(self.foo_devel, self.factory.makePerson())
65 sourcepackage.setPackaging(self.foo_stable, self.factory.makePerson())
66 package_potemplate = self.factory.makePOTemplate(
67- distroseries=hoary, sourcepackagename=packagename,
68+ distroseries=distroseries,
69+ sourcepackagename=sourcepackage.sourcepackagename,
70 name="messages")
71 devel_potemplate = self.factory.makePOTemplate(
72 productseries=self.foo_devel, name="messages")
73@@ -979,47 +981,46 @@
74 stable_pofile = stable_potemplate.getPOFileByLang('eo')
75 self.assertNotEqual(None, stable_pofile)
76
77- def test_pofile_creation_shared_in_ubuntu(self):
78- # When a pofile is created in a POTemplate of project it is also
79- # created in all shared templates in the linked Ubuntu package.
80- # POTemplate is 'shared' if it has the same name ('messages').
81+ def test_pofile_creation_sharing_in_ubuntu(self):
82+ # When a pofile is created in a POTemplate of a project it is also
83+ # created in all sharing templates in the linked Ubuntu package.
84+ # Two POTemplates are sharing if they have the same name ('messages').
85 ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
86- hoary = ubuntu ['hoary']
87- warty = ubuntu['warty']
88+ distroseries1 = self.factory.makeDistroSeries(distribution=ubuntu)
89+ distroseries2 = self.factory.makeDistroSeries(distribution=ubuntu)
90 packagename = self.factory.makeSourcePackageName()
91- hoary_package = self.factory.makeSourcePackage(packagename, hoary)
92- warty_package = self.factory.makeSourcePackage(packagename, warty)
93- self.factory.makeSourcePackagePublishingHistory(
94- sourcepackagename=packagename, distroseries=hoary)
95- self.factory.makeSourcePackagePublishingHistory(
96- sourcepackagename=packagename, distroseries=warty)
97+ self.factory.makeSourcePackage(packagename, distroseries1)
98+ self.factory.makeSourcePackage(packagename, distroseries2)
99+ self.factory.makeSourcePackagePublishingHistory(
100+ sourcepackagename=packagename, distroseries=distroseries1)
101+ self.factory.makeSourcePackagePublishingHistory(
102+ sourcepackagename=packagename, distroseries=distroseries2)
103 owner = self.factory.makePerson()
104- self.foo_stable.setPackaging(hoary, packagename, owner)
105- self.foo_stable.setPackaging(warty, packagename, owner)
106+ self.foo_stable.setPackaging(distroseries1, packagename, owner)
107+ self.foo_stable.setPackaging(distroseries2, packagename, owner)
108
109-
110 stable_potemplate = self.factory.makePOTemplate(
111 productseries=self.foo_stable, name="messages")
112- hoary_potemplate = self.factory.makePOTemplate(
113- distroseries=hoary, sourcepackagename=packagename,
114+ distroseries1_potemplate = self.factory.makePOTemplate(
115+ distroseries=distroseries1, sourcepackagename=packagename,
116 name="messages")
117- warty_potemplate = self.factory.makePOTemplate(
118- distroseries=warty, sourcepackagename=packagename,
119+ distroseries2_potemplate = self.factory.makePOTemplate(
120+ distroseries=distroseries2, sourcepackagename=packagename,
121 name="messages")
122
123- self.assertEqual(None, hoary_potemplate.getPOFileByLang('eo'))
124- self.assertEqual(None, warty_potemplate.getPOFileByLang('eo'))
125+ self.assertEqual(None, distroseries1_potemplate.getPOFileByLang('eo'))
126+ self.assertEqual(None, distroseries2_potemplate.getPOFileByLang('eo'))
127
128 stable_pofile = stable_potemplate.newPOFile('eo')
129
130- hoary_pofile = hoary_potemplate.getPOFileByLang('eo')
131- self.assertNotEqual(None, hoary_pofile)
132- warty_pofile = warty_potemplate.getPOFileByLang('eo')
133- self.assertNotEqual(None, warty_pofile)
134+ distroseries1_pofile = distroseries1_potemplate.getPOFileByLang('eo')
135+ self.assertNotEqual(None, distroseries1_pofile)
136+ distroseries2_pofile = distroseries2_potemplate.getPOFileByLang('eo')
137+ self.assertNotEqual(None, distroseries2_pofile)
138
139- def test_pofile_creation_not_shared(self):
140+ def test_pofile_creation_not_sharing(self):
141 # When a pofile is created in a POTemplate it is not created in
142- # other templates that are not shared.
143+ # other templates that are not sharing.
144 potemplate_devel_1 = self.factory.makePOTemplate(
145 productseries=self.foo_devel, name="template-1")
146 potemplate_stable_2 = self.factory.makePOTemplate(
147@@ -1031,7 +1032,7 @@
148
149 def test_potemplate_creation(self):
150 # When a potemplate is created it receives a copy of all pofiles in
151- # all shared potemplates.
152+ # all sharing potemplates.
153 foo_other = self.factory.makeProductSeries(
154 name='other', product=self.foo)
155 self.factory.makePOTemplate(
156@@ -1121,7 +1122,7 @@
157 layer = ZopelessDatabaseLayer
158
159 def setUp(self):
160- # Create a product with two series and a shared POTemplate
161+ # Create a product with two series and a sharing POTemplate
162 # in different series ('devel' and 'stable').
163 super(TestTranslationPOFilePOTMsgSetOrdering, self).setUp()
164 self.foo = self.factory.makeProduct()
165@@ -1131,7 +1132,7 @@
166 name='stable', product=self.foo)
167 self.foo.official_rosetta = True
168
169- # POTemplate is 'shared' if it has the same name ('messages').
170+ # Two POTemplates are sharing if they have the same name ('messages').
171 self.devel_potemplate = self.factory.makePOTemplate(
172 productseries=self.foo_devel, name="messages")
173 self.stable_potemplate = self.factory.makePOTemplate(self.foo_stable,

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/translations/tests/test_pofile.py'
2--- lib/lp/translations/tests/test_pofile.py 2010-08-24 07:12:53 +0000
3+++ lib/lp/translations/tests/test_pofile.py 2010-08-27 10:07:46 +0000
4@@ -18,6 +18,7 @@
5 from zope.security.proxy import removeSecurityProxy
6
7 from canonical.database.constants import UTC_NOW
8+from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities
9 from canonical.launchpad.webapp.publisher import canonical_url
10 from canonical.testing import (
11 LaunchpadZopelessLayer,
12@@ -238,7 +239,7 @@
13 # Test the canonical_url of the POFile.
14 pofile_url = (
15 'http://translations.launchpad.dev/foo/devel/+pots/messages/'
16- '%s' % self.devel_pofile.language.code )
17+ '%s' % self.devel_pofile.language.code)
18 self.assertEqual(pofile_url, canonical_url(self.devel_pofile))
19 view_name = '+details'
20 view_url = "%s/%s" % (pofile_url, view_name)
21@@ -918,15 +919,15 @@
22 "Diverged translation")])
23
24
25-class TestSharedPOFileCreation(TestCaseWithFactory):
26- """Test that POFiles are created in shared POTemplates."""
27+class TestSharingPOFileCreation(TestCaseWithFactory):
28+ """Test that POFiles are created in sharing POTemplates."""
29
30 layer = ZopelessDatabaseLayer
31
32 def setUp(self):
33- # Create a product with two series and a shared POTemplate
34+ # Create a product with two series and a sharing POTemplate
35 # in different series ('devel' and 'stable').
36- super(TestSharedPOFileCreation, self).setUp()
37+ super(TestSharingPOFileCreation, self).setUp()
38 self.foo = self.factory.makeProduct()
39 self.foo_devel = self.factory.makeProductSeries(
40 name='devel', product=self.foo)
41@@ -934,10 +935,10 @@
42 name='stable', product=self.foo)
43 self.foo.official_rosetta = True
44
45- def test_pofile_creation_shared(self):
46+ def test_pofile_creation_sharing(self):
47 # When a pofile is created in a POTemplate it is also created in
48- # all shared templates.
49- # POTemplate is 'shared' if it has the same name ('messages').
50+ # all sharing templates.
51+ # Two POTemplates are sharing if they have the same name ('messages').
52 devel_potemplate = self.factory.makePOTemplate(
53 productseries=self.foo_devel, name="messages")
54 stable_potemplate = self.factory.makePOTemplate(
55@@ -950,9 +951,76 @@
56 self.assertEqual(pofile_devel.language.code,
57 pofile_stable.language.code)
58
59- def test_pofile_creation_not_shared(self):
60+ def test_pofile_creation_sharing_upstream(self):
61+ # When a pofile is created in a POTemplate of an Ubuntu package
62+ # it is also created in all shared templates in the upstream project.
63+ # POTemplate is 'shared' if it has the same name ('messages').
64+ ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
65+ distroseries = self.factory.makeDistroSeries(distribution=ubuntu)
66+ ubuntu.translation_focus = distroseries
67+ sourcepackage = self.factory.makeSourcePackage(
68+ distroseries=distroseries)
69+ sourcepackage.setPackaging(self.foo_devel, self.factory.makePerson())
70+ sourcepackage.setPackaging(self.foo_stable, self.factory.makePerson())
71+ package_potemplate = self.factory.makePOTemplate(
72+ distroseries=distroseries,
73+ sourcepackagename=sourcepackage.sourcepackagename,
74+ name="messages")
75+ devel_potemplate = self.factory.makePOTemplate(
76+ productseries=self.foo_devel, name="messages")
77+ stable_potemplate = self.factory.makePOTemplate(
78+ productseries=self.foo_stable, name="messages")
79+
80+ self.assertEqual(None, devel_potemplate.getPOFileByLang('eo'))
81+ self.assertEqual(None, stable_potemplate.getPOFileByLang('eo'))
82+
83+ package_pofile = package_potemplate.newPOFile('eo')
84+
85+ devel_pofile = devel_potemplate.getPOFileByLang('eo')
86+ self.assertNotEqual(None, devel_pofile)
87+ stable_pofile = stable_potemplate.getPOFileByLang('eo')
88+ self.assertNotEqual(None, stable_pofile)
89+
90+ def test_pofile_creation_sharing_in_ubuntu(self):
91+ # When a pofile is created in a POTemplate of a project it is also
92+ # created in all sharing templates in the linked Ubuntu package.
93+ # Two POTemplates are sharing if they have the same name ('messages').
94+ ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
95+ distroseries1 = self.factory.makeDistroSeries(distribution=ubuntu)
96+ distroseries2 = self.factory.makeDistroSeries(distribution=ubuntu)
97+ packagename = self.factory.makeSourcePackageName()
98+ self.factory.makeSourcePackage(packagename, distroseries1)
99+ self.factory.makeSourcePackage(packagename, distroseries2)
100+ self.factory.makeSourcePackagePublishingHistory(
101+ sourcepackagename=packagename, distroseries=distroseries1)
102+ self.factory.makeSourcePackagePublishingHistory(
103+ sourcepackagename=packagename, distroseries=distroseries2)
104+ owner = self.factory.makePerson()
105+ self.foo_stable.setPackaging(distroseries1, packagename, owner)
106+ self.foo_stable.setPackaging(distroseries2, packagename, owner)
107+
108+ stable_potemplate = self.factory.makePOTemplate(
109+ productseries=self.foo_stable, name="messages")
110+ distroseries1_potemplate = self.factory.makePOTemplate(
111+ distroseries=distroseries1, sourcepackagename=packagename,
112+ name="messages")
113+ distroseries2_potemplate = self.factory.makePOTemplate(
114+ distroseries=distroseries2, sourcepackagename=packagename,
115+ name="messages")
116+
117+ self.assertEqual(None, distroseries1_potemplate.getPOFileByLang('eo'))
118+ self.assertEqual(None, distroseries2_potemplate.getPOFileByLang('eo'))
119+
120+ stable_pofile = stable_potemplate.newPOFile('eo')
121+
122+ distroseries1_pofile = distroseries1_potemplate.getPOFileByLang('eo')
123+ self.assertNotEqual(None, distroseries1_pofile)
124+ distroseries2_pofile = distroseries2_potemplate.getPOFileByLang('eo')
125+ self.assertNotEqual(None, distroseries2_pofile)
126+
127+ def test_pofile_creation_not_sharing(self):
128 # When a pofile is created in a POTemplate it is not created in
129- # other templates that are not shared.
130+ # other templates that are not sharing.
131 potemplate_devel_1 = self.factory.makePOTemplate(
132 productseries=self.foo_devel, name="template-1")
133 potemplate_stable_2 = self.factory.makePOTemplate(
134@@ -964,7 +1032,7 @@
135
136 def test_potemplate_creation(self):
137 # When a potemplate is created it receives a copy of all pofiles in
138- # all shared potemplates.
139+ # all sharing potemplates.
140 foo_other = self.factory.makeProductSeries(
141 name='other', product=self.foo)
142 self.factory.makePOTemplate(
143@@ -1054,7 +1122,7 @@
144 layer = ZopelessDatabaseLayer
145
146 def setUp(self):
147- # Create a product with two series and a shared POTemplate
148+ # Create a product with two series and a sharing POTemplate
149 # in different series ('devel' and 'stable').
150 super(TestTranslationPOFilePOTMsgSetOrdering, self).setUp()
151 self.foo = self.factory.makeProduct()
152@@ -1064,7 +1132,7 @@
153 name='stable', product=self.foo)
154 self.foo.official_rosetta = True
155
156- # POTemplate is 'shared' if it has the same name ('messages').
157+ # Two POTemplates are sharing if they have the same name ('messages').
158 self.devel_potemplate = self.factory.makePOTemplate(
159 productseries=self.foo_devel, name="messages")
160 self.stable_potemplate = self.factory.makePOTemplate(self.foo_stable,

Subscribers

People subscribed via source and target branches