Code review comment for lp:~henninge/launchpad/recife-pofile-creation

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,

« Back to merge proposal