Code review comment for lp:~henninge/launchpad/bug-595925-second-attempt
- bug-595925-second-attempt
- Merge into recife
Revision history for this message
Henning Eggers (henninge) wrote : | # |
1 | === modified file 'lib/lp/testing/factory.py' |
2 | --- lib/lp/testing/factory.py 2010-08-16 09:10:59 +0000 |
3 | +++ lib/lp/testing/factory.py 2010-08-16 15:07:24 +0000 |
4 | @@ -2057,8 +2057,7 @@ |
5 | if pofile is None: |
6 | pofile = self.makePOFile('sr') |
7 | if potmsgset is None: |
8 | - potmsgset = self.makePOTMsgSet(pofile.potemplate) |
9 | - potmsgset.setSequence(pofile.potemplate, 1) |
10 | + potmsgset = self.makePOTMsgSet(pofile.potemplate, sequence=1) |
11 | if translator is None: |
12 | translator = self.makePerson() |
13 | if translations is None: |
14 | @@ -2077,37 +2076,39 @@ |
15 | naked_translation_message.sync() |
16 | return translation_message |
17 | |
18 | - def _makeTranslationsDict(self, translations): |
19 | - """Make sure translations are in the right format (dict, not list). |
20 | + def _makeTranslationsDict(self, translations=None): |
21 | + """Make sure translations are stored in a dict, e.g. {0: "foo"}. |
22 | |
23 | - Create an arbitrary single translation if translations are None. |
24 | + If translations is already dict, it is returned unchanged. |
25 | + If translations is a sequence, it is enumerated into a dict. |
26 | + If translations is None, an arbitrary single translation is created. |
27 | """ |
28 | if translations is None: |
29 | return {0: self.getUniqueString()} |
30 | - if isinstance(translations, (tuple, list)): |
31 | - return dict(enumerate(translations)) |
32 | - assert isinstance(translations, dict) |
33 | - return translations |
34 | + if isinstance(translations, dict): |
35 | + return translations |
36 | + assert isinstance(translations, (list, tuple)), ( |
37 | + "Expecting either a dict or a sequence." ) |
38 | + return dict(enumerate(translations)) |
39 | |
40 | def makeSuggestion(self, pofile=None, potmsgset=None, translator=None, |
41 | - translations=None, date_updated=None): |
42 | + translations=None, date_created=None): |
43 | """Make a new suggested `TranslationMessage` in the given PO file.""" |
44 | if pofile is None: |
45 | pofile = self.makePOFile('sr') |
46 | if potmsgset is None: |
47 | - potmsgset = self.makePOTMsgSet(pofile.potemplate) |
48 | - potmsgset.setSequence(pofile.potemplate, 1) |
49 | + potmsgset = self.makePOTMsgSet(pofile.potemplate, sequence=1) |
50 | if translator is None: |
51 | translator = self.makePerson() |
52 | - translations=self._makeTranslationsDict(translations) |
53 | + translations = self._makeTranslationsDict(translations) |
54 | translation_message = potmsgset.submitSuggestion( |
55 | pofile, translator, translations) |
56 | assert translation_message is not None, ( |
57 | "Cannot make suggestion on translation credits POTMsgSet.") |
58 | - if date_updated is not None: |
59 | + if date_created is not None: |
60 | naked_translation_message = removeSecurityProxy( |
61 | translation_message) |
62 | - naked_translation_message.date_created = date_updated |
63 | + naked_translation_message.date_created = date_created |
64 | naked_translation_message.sync() |
65 | return translation_message |
66 | |
67 | |
68 | === modified file 'lib/lp/translations/browser/tests/test_pofile_view.py' |
69 | --- lib/lp/translations/browser/tests/test_pofile_view.py 2010-08-16 09:01:35 +0000 |
70 | +++ lib/lp/translations/browser/tests/test_pofile_view.py 2010-08-16 15:18:40 +0000 |
71 | @@ -46,7 +46,7 @@ |
72 | self.pofile, self.new_suggestion, |
73 | date_updated=self.now()) |
74 | self.factory.makeSuggestion( |
75 | - self.pofile, self.new_suggestion, date_updated=self.now()) |
76 | + self.pofile, self.new_suggestion, date_created=self.now()) |
77 | # An upstream that was changed in Ubuntu. |
78 | self.changed = self.factory.makePOTMsgSet( |
79 | self.potemplate, sequence=4) |
80 | @@ -170,7 +170,3 @@ |
81 | def setUp(self): |
82 | super(TestPOFileTranslateViewInvalidFiltering, self).setUp() |
83 | self.pofile = self.factory.makePOFile('eo') |
84 | - |
85 | - |
86 | -def test_suite(): |
87 | - return TestLoader().loadTestsFromName(__name__) |
88 | |
89 | === modified file 'lib/lp/translations/browser/tests/test_translationmessage_view.py' |
90 | --- lib/lp/translations/browser/tests/test_translationmessage_view.py 2010-08-11 10:37:59 +0000 |
91 | +++ lib/lp/translations/browser/tests/test_translationmessage_view.py 2010-08-16 15:11:30 +0000 |
92 | @@ -56,7 +56,7 @@ |
93 | self.pofile, self.potmsgset, |
94 | translations=translations, |
95 | translator=self.owner, |
96 | - date_updated=self.now()) |
97 | + date_created=self.now()) |
98 | else: |
99 | message = self.factory.makeTranslationMessage( |
100 | self.pofile, self.potmsgset, |
101 | |
102 | === modified file 'lib/lp/translations/tests/test_pofile.py' |
103 | --- lib/lp/translations/tests/test_pofile.py 2010-08-13 14:24:30 +0000 |
104 | +++ lib/lp/translations/tests/test_pofile.py 2010-08-16 15:56:36 +0000 |
105 | @@ -1,8 +1,6 @@ |
106 | # Copyright 2009-2010 Canonical Ltd. This software is licensed under the |
107 | # GNU Affero General Public License version 3 (see the file LICENSE). |
108 | |
109 | -# pylint: disable-msg=C0102 |
110 | - |
111 | __metaclass__ = type |
112 | |
113 | from datetime import datetime, timedelta |
114 | @@ -43,7 +41,8 @@ |
115 | self.foo.official_rosetta = True |
116 | self.sourcepackagename = self.factory.makeSourcePackageName() |
117 | |
118 | - # POTemplate is 'shared' if it has the same name ('messages'). |
119 | + # Two POTemplates share translations if they have the same name, |
120 | + # in this case 'messages'. |
121 | self.devel_potemplate = self.factory.makePOTemplate( |
122 | distroseries=self.foo_devel, |
123 | sourcepackagename=self.sourcepackagename, |
124 | @@ -54,41 +53,40 @@ |
125 | name="messages") |
126 | |
127 | # We'll use two PO files, one for each series. |
128 | - self.devel_sr_pofile = self.factory.makePOFile( |
129 | + self.devel_pofile = self.factory.makePOFile( |
130 | 'sr', self.devel_potemplate) |
131 | - self.stable_sr_pofile = self.factory.makePOFile( |
132 | + self.stable_pofile = self.factory.makePOFile( |
133 | 'sr', self.stable_potemplate) |
134 | |
135 | - # Create a single POTMsgSet that is used across all tests, |
136 | - # and add it to only one of the POTemplates. |
137 | - self.potmsgset = self.factory.makePOTMsgSet(self.devel_potemplate) |
138 | - self.potmsgset.setSequence(self.devel_potemplate, 1) |
139 | + # The POTMsgSet is added to only one of the POTemplates. |
140 | + self.potmsgset = self.factory.makePOTMsgSet( |
141 | + self.devel_potemplate, sequence=1) |
142 | |
143 | - def test_getPOTMsgSetWithNewSuggestions_Shared(self): |
144 | + def test_getPOTMsgSetWithNewSuggestions_shared(self): |
145 | # Test listing of suggestions for POTMsgSets with a shared |
146 | # translation. |
147 | |
148 | # A POTMsgSet has a shared, current translation created 5 days ago. |
149 | - date_created = datetime.now(pytz.UTC)-timedelta(5) |
150 | + date_created = datetime.now(pytz.UTC) - timedelta(5) |
151 | translation = self.factory.makeSuggestion( |
152 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
153 | - translations=[u"Translation"], date_updated=date_created) |
154 | - translation.is_current_ubuntu= True |
155 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
156 | + translations=[u"Translation"], date_created=date_created) |
157 | + translation.is_current_ubuntu = True |
158 | |
159 | # When there are no suggestions, nothing is returned. |
160 | found_translations = list( |
161 | - self.devel_sr_pofile.getPOTMsgSetWithNewSuggestions()) |
162 | + self.devel_pofile.getPOTMsgSetWithNewSuggestions()) |
163 | self.assertEquals(found_translations, []) |
164 | |
165 | # When a suggestion is added one day after, the potmsgset is returned. |
166 | suggestion_date = date_created + timedelta(1) |
167 | suggestion = self.factory.makeSuggestion( |
168 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
169 | - translations=[u"Suggestion"], date_updated=suggestion_date) |
170 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
171 | + translations=[u"Suggestion"], date_created=suggestion_date) |
172 | self.assertEquals(suggestion.is_current_ubuntu, False) |
173 | |
174 | found_translations = list( |
175 | - self.devel_sr_pofile.getPOTMsgSetWithNewSuggestions()) |
176 | + self.devel_pofile.getPOTMsgSetWithNewSuggestions()) |
177 | self.assertEquals(found_translations, [self.potmsgset]) |
178 | |
179 | # Setting a suggestion as current makes it have no unreviewed |
180 | @@ -96,22 +94,22 @@ |
181 | translation.is_current_ubuntu = False |
182 | suggestion.is_current_ubuntu = True |
183 | found_translations = list( |
184 | - self.devel_sr_pofile.getPOTMsgSetWithNewSuggestions()) |
185 | + self.devel_pofile.getPOTMsgSetWithNewSuggestions()) |
186 | self.assertEquals(found_translations, []) |
187 | |
188 | # And adding another suggestion 2 days later, the potmsgset is |
189 | # again returned. |
190 | suggestion_date += timedelta(2) |
191 | translation = self.factory.makeSuggestion( |
192 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
193 | - translations=[u"New suggestion"], date_updated=suggestion_date) |
194 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
195 | + translations=[u"New suggestion"], date_created=suggestion_date) |
196 | self.assertEquals(translation.is_current_ubuntu, False) |
197 | |
198 | found_translations = list( |
199 | - self.devel_sr_pofile.getPOTMsgSetWithNewSuggestions()) |
200 | + self.devel_pofile.getPOTMsgSetWithNewSuggestions()) |
201 | self.assertEquals(found_translations, [self.potmsgset]) |
202 | |
203 | - def test_getPOTMsgSetWithNewSuggestions_Diverged(self): |
204 | + def test_getPOTMsgSetWithNewSuggestions_diverged(self): |
205 | # Test listing of suggestions for POTMsgSets with a shared |
206 | # translation and a later diverged one. |
207 | |
208 | @@ -124,18 +122,18 @@ |
209 | # * Suggestion is made active (nothing). |
210 | |
211 | # A POTMsgSet has a shared, current translation created 5 days ago. |
212 | - date_created = datetime.now(pytz.UTC)-timedelta(5) |
213 | + date_created = datetime.now(pytz.UTC) - timedelta(5) |
214 | translation = self.factory.makeSuggestion( |
215 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
216 | - translations=[u"Shared translation"], date_updated=date_created) |
217 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
218 | + translations=[u"Shared translation"], date_created=date_created) |
219 | translation.is_current_ubuntu = True |
220 | |
221 | - # And we also have a diverged translation created a day after shared |
222 | + # And we also have a diverged translation created a day after a shared |
223 | # current translation. |
224 | diverged_date = date_created + timedelta(1) |
225 | diverged_translation = self.factory.makeSuggestion( |
226 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
227 | - translations=[u"Old translation"], date_updated=diverged_date) |
228 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
229 | + translations=[u"Old translation"], date_created=diverged_date) |
230 | diverged_translation.potemplate = self.devel_potemplate |
231 | diverged_translation.is_current_ubuntu = True |
232 | |
233 | @@ -143,37 +141,37 @@ |
234 | # created 2 days after the shared translation. |
235 | suggestion_date = date_created + timedelta(2) |
236 | suggestion = self.factory.makeSuggestion( |
237 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
238 | - translations=[u"Shared suggestion"], date_updated=suggestion_date) |
239 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
240 | + translations=[u"Shared suggestion"], date_created=suggestion_date) |
241 | self.assertEquals(suggestion.is_current_ubuntu, False) |
242 | |
243 | - # Shared suggestion is shown since diverged_date < suggestion_date. |
244 | + # A suggestion is shown since diverged_date < suggestion_date. |
245 | found_translations = list( |
246 | - self.devel_sr_pofile.getPOTMsgSetWithNewSuggestions()) |
247 | + self.devel_pofile.getPOTMsgSetWithNewSuggestions()) |
248 | self.assertEquals(found_translations, [self.potmsgset]) |
249 | |
250 | - # When a diverged translation is done after the shared suggestion, |
251 | + # When a diverged translation is added after the shared suggestion, |
252 | # there are no unreviewed suggestions. |
253 | diverged_date = suggestion_date + timedelta(1) |
254 | diverged_translation_2 = self.factory.makeTranslationMessage( |
255 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
256 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
257 | translations=[u"Translation"], date_updated=diverged_date) |
258 | diverged_translation.is_current_ubuntu = False |
259 | diverged_translation_2.potemplate = self.devel_potemplate |
260 | diverged_translation_2.is_current_ubuntu = True |
261 | found_translations = list( |
262 | - self.devel_sr_pofile.getPOTMsgSetWithNewSuggestions()) |
263 | + self.devel_pofile.getPOTMsgSetWithNewSuggestions()) |
264 | self.assertEquals(found_translations, []) |
265 | |
266 | # When a suggestion is added one day after, the potmsgset is returned. |
267 | suggestion_date = diverged_date + timedelta(1) |
268 | suggestion = self.factory.makeSuggestion( |
269 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
270 | - translations=[u"Suggestion"], date_updated=suggestion_date) |
271 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
272 | + translations=[u"Suggestion"], date_created=suggestion_date) |
273 | self.assertEquals(suggestion.is_current_ubuntu, False) |
274 | |
275 | found_translations = list( |
276 | - self.devel_sr_pofile.getPOTMsgSetWithNewSuggestions()) |
277 | + self.devel_pofile.getPOTMsgSetWithNewSuggestions()) |
278 | self.assertEquals(found_translations, [self.potmsgset]) |
279 | |
280 | # Setting a suggestion as current makes it have no unreviewed |
281 | @@ -181,7 +179,7 @@ |
282 | translation.is_current_ubuntu = False |
283 | suggestion.is_current_ubuntu = True |
284 | found_translations = list( |
285 | - self.devel_sr_pofile.getPOTMsgSetWithNewSuggestions()) |
286 | + self.devel_pofile.getPOTMsgSetWithNewSuggestions()) |
287 | self.assertEquals(found_translations, []) |
288 | |
289 | |
290 | @@ -201,22 +199,22 @@ |
291 | name='stable', product=self.foo) |
292 | self.foo.official_rosetta = True |
293 | |
294 | - # POTemplate is 'shared' if it has the same name ('messages'). |
295 | + # Two POTemplates share translations if they have the same name, |
296 | + # in this case 'messages'. |
297 | self.devel_potemplate = self.factory.makePOTemplate( |
298 | productseries=self.foo_devel, name="messages") |
299 | self.stable_potemplate = self.factory.makePOTemplate(self.foo_stable, |
300 | name="messages") |
301 | |
302 | # We'll use two PO files, one for each series. |
303 | - self.devel_sr_pofile = self.factory.makePOFile( |
304 | + self.devel_pofile = self.factory.makePOFile( |
305 | 'sr', self.devel_potemplate) |
306 | - self.stable_sr_pofile = self.factory.makePOFile( |
307 | + self.stable_pofile = self.factory.makePOFile( |
308 | 'sr', self.stable_potemplate) |
309 | |
310 | - # Create a single POTMsgSet that is used across all tests, |
311 | - # and add it to only one of the POTemplates. |
312 | - self.potmsgset = self.factory.makePOTMsgSet(self.devel_potemplate) |
313 | - self.potmsgset.setSequence(self.devel_potemplate, 1) |
314 | + # The POTMsgSet is added to only one of the POTemplates. |
315 | + self.potmsgset = self.factory.makePOTMsgSet( |
316 | + self.devel_potemplate, sequence=1) |
317 | |
318 | def test_findPOTMsgSetsContaining(self): |
319 | # Test that search works correctly. |
320 | @@ -227,14 +225,14 @@ |
321 | potmsgset.setSequence(self.devel_potemplate, 2) |
322 | |
323 | found_potmsgsets = list( |
324 | - self.devel_sr_pofile.findPOTMsgSetsContaining(u"wild")) |
325 | + self.devel_pofile.findPOTMsgSetsContaining(u"wild")) |
326 | self.assertEquals(found_potmsgsets, [potmsgset]) |
327 | |
328 | # Just linking an existing POTMsgSet into another POTemplate |
329 | # will make it be returned in searches. |
330 | potmsgset.setSequence(self.stable_potemplate, 2) |
331 | found_potmsgsets = list( |
332 | - self.stable_sr_pofile.findPOTMsgSetsContaining(u"wild")) |
333 | + self.stable_pofile.findPOTMsgSetsContaining(u"wild")) |
334 | self.assertEquals(found_potmsgsets, [potmsgset]) |
335 | |
336 | # Searching for singular in plural messages works as well. |
337 | @@ -244,49 +242,49 @@ |
338 | plural_potmsgset.setSequence(self.devel_potemplate, 3) |
339 | |
340 | found_potmsgsets = list( |
341 | - self.devel_sr_pofile.findPOTMsgSetsContaining(u"singular")) |
342 | + self.devel_pofile.findPOTMsgSetsContaining(u"singular")) |
343 | self.assertEquals(found_potmsgsets, [plural_potmsgset]) |
344 | |
345 | # And searching for plural text returns only the matching plural |
346 | # message. |
347 | found_potmsgsets = list( |
348 | - self.devel_sr_pofile.findPOTMsgSetsContaining(u"plural")) |
349 | + self.devel_pofile.findPOTMsgSetsContaining(u"plural")) |
350 | self.assertEquals(found_potmsgsets, [plural_potmsgset]) |
351 | |
352 | # Search translations as well. |
353 | self.factory.makeTranslationMessage( |
354 | - pofile=self.devel_sr_pofile, potmsgset=potmsgset, |
355 | + pofile=self.devel_pofile, potmsgset=potmsgset, |
356 | translations=[u"One translation message"]) |
357 | found_potmsgsets = list( |
358 | - self.devel_sr_pofile.findPOTMsgSetsContaining(u"translation")) |
359 | + self.devel_pofile.findPOTMsgSetsContaining(u"translation")) |
360 | self.assertEquals(found_potmsgsets, [potmsgset]) |
361 | |
362 | # Search matches all plural forms. |
363 | self.factory.makeTranslationMessage( |
364 | - pofile=self.devel_sr_pofile, potmsgset=plural_potmsgset, |
365 | + pofile=self.devel_pofile, potmsgset=plural_potmsgset, |
366 | translations=[u"One translation message", |
367 | u"Plural translation message", |
368 | u"Third translation message"]) |
369 | found_potmsgsets = list( |
370 | - self.devel_sr_pofile.findPOTMsgSetsContaining( |
371 | + self.devel_pofile.findPOTMsgSetsContaining( |
372 | u"Plural translation")) |
373 | self.assertEquals(found_potmsgsets, [plural_potmsgset]) |
374 | |
375 | # Search works case insensitively for English strings. |
376 | found_potmsgsets = list( |
377 | - self.devel_sr_pofile.findPOTMsgSetsContaining(u"WiLd")) |
378 | + self.devel_pofile.findPOTMsgSetsContaining(u"WiLd")) |
379 | self.assertEquals(found_potmsgsets, [potmsgset]) |
380 | # ...English plural forms. |
381 | found_potmsgsets = list( |
382 | - self.devel_sr_pofile.findPOTMsgSetsContaining(u"PLurAl")) |
383 | + self.devel_pofile.findPOTMsgSetsContaining(u"PLurAl")) |
384 | self.assertEquals(found_potmsgsets, [plural_potmsgset]) |
385 | # ...translations. |
386 | found_potmsgsets = list( |
387 | - self.devel_sr_pofile.findPOTMsgSetsContaining(u"tRANSlaTIon")) |
388 | + self.devel_pofile.findPOTMsgSetsContaining(u"tRANSlaTIon")) |
389 | self.assertEquals(found_potmsgsets, [potmsgset, plural_potmsgset]) |
390 | # ...and translated plurals. |
391 | found_potmsgsets = list( |
392 | - self.devel_sr_pofile.findPOTMsgSetsContaining(u"THIRD")) |
393 | + self.devel_pofile.findPOTMsgSetsContaining(u"THIRD")) |
394 | self.assertEquals(found_potmsgsets, [plural_potmsgset]) |
395 | |
396 | def test_getTranslationsFilteredBy(self): |
397 | @@ -299,27 +297,27 @@ |
398 | |
399 | # When there are no translations, empty list is returned. |
400 | found_translations = list( |
401 | - self.devel_sr_pofile.getTranslationsFilteredBy(submitter)) |
402 | + self.devel_pofile.getTranslationsFilteredBy(submitter)) |
403 | self.assertEquals(found_translations, []) |
404 | |
405 | # If 'submitter' provides a translation, it's returned in a list. |
406 | translation = self.factory.makeTranslationMessage( |
407 | - pofile=self.devel_sr_pofile, potmsgset=potmsgset, |
408 | + pofile=self.devel_pofile, potmsgset=potmsgset, |
409 | translations=[u"Translation message"], |
410 | translator=submitter) |
411 | found_translations = list( |
412 | - self.devel_sr_pofile.getTranslationsFilteredBy(submitter)) |
413 | + self.devel_pofile.getTranslationsFilteredBy(submitter)) |
414 | self.assertEquals(found_translations, [translation]) |
415 | |
416 | # If somebody else provides a translation, it's not added to the |
417 | # list of submitter's translations. |
418 | someone_else = self.factory.makePerson() |
419 | self.factory.makeTranslationMessage( |
420 | - pofile=self.devel_sr_pofile, potmsgset=potmsgset, |
421 | + pofile=self.devel_pofile, potmsgset=potmsgset, |
422 | translations=[u"Another translation"], |
423 | translator=someone_else) |
424 | found_translations = list( |
425 | - self.devel_sr_pofile.getTranslationsFilteredBy(submitter)) |
426 | + self.devel_pofile.getTranslationsFilteredBy(submitter)) |
427 | self.assertEquals(found_translations, [translation]) |
428 | |
429 | # Adding a translation for same POTMsgSet, but to a different |
430 | @@ -332,17 +330,17 @@ |
431 | translations=[u"Yet another translation"], |
432 | translator=submitter) |
433 | found_translations = list( |
434 | - self.devel_sr_pofile.getTranslationsFilteredBy(submitter)) |
435 | + self.devel_pofile.getTranslationsFilteredBy(submitter)) |
436 | self.assertEquals(found_translations, [translation]) |
437 | |
438 | # If a POTMsgSet is shared between two templates, a |
439 | # translation is listed on both. |
440 | potmsgset.setSequence(self.stable_potemplate, 1) |
441 | found_translations = list( |
442 | - self.stable_sr_pofile.getTranslationsFilteredBy(submitter)) |
443 | + self.stable_pofile.getTranslationsFilteredBy(submitter)) |
444 | self.assertEquals(found_translations, [translation]) |
445 | found_translations = list( |
446 | - self.devel_sr_pofile.getTranslationsFilteredBy(submitter)) |
447 | + self.devel_pofile.getTranslationsFilteredBy(submitter)) |
448 | self.assertEquals(found_translations, [translation]) |
449 | |
450 | def test_getPOTMsgSetTranslated_NoShared(self): |
451 | @@ -351,23 +349,23 @@ |
452 | |
453 | # When there is no diverged translation either, nothing is returned. |
454 | found_translations = list( |
455 | - self.devel_sr_pofile.getPOTMsgSetTranslated()) |
456 | + self.devel_pofile.getPOTMsgSetTranslated()) |
457 | self.assertEquals(found_translations, []) |
458 | |
459 | # When a diverged translation is added, the potmsgset is returned. |
460 | self.factory.makeTranslationMessage( |
461 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
462 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
463 | translations=[u"Translation"]) |
464 | found_translations = list( |
465 | - self.devel_sr_pofile.getPOTMsgSetTranslated()) |
466 | + self.devel_pofile.getPOTMsgSetTranslated()) |
467 | self.assertEquals(found_translations, [self.potmsgset]) |
468 | |
469 | # If diverged translation is empty, POTMsgSet is not listed. |
470 | self.factory.makeTranslationMessage( |
471 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
472 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
473 | translations=[u""]) |
474 | found_translations = list( |
475 | - self.devel_sr_pofile.getPOTMsgSetTranslated()) |
476 | + self.devel_pofile.getPOTMsgSetTranslated()) |
477 | self.assertEquals(found_translations, []) |
478 | |
479 | def test_getPOTMsgSetTranslated_Shared(self): |
480 | @@ -376,28 +374,28 @@ |
481 | |
482 | # We create a shared translation first. |
483 | self.factory.makeSharedTranslationMessage( |
484 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
485 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
486 | translations=[u"Shared translation"]) |
487 | |
488 | # When there is no diverged translation, shared one is returned. |
489 | found_translations = list( |
490 | - self.devel_sr_pofile.getPOTMsgSetTranslated()) |
491 | + self.devel_pofile.getPOTMsgSetTranslated()) |
492 | self.assertEquals(found_translations, [self.potmsgset]) |
493 | |
494 | # When an empty diverged translation is added, nothing is listed. |
495 | self.factory.makeTranslationMessage( |
496 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
497 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
498 | translations=[u""]) |
499 | found_translations = list( |
500 | - self.devel_sr_pofile.getPOTMsgSetTranslated()) |
501 | + self.devel_pofile.getPOTMsgSetTranslated()) |
502 | self.assertEquals(found_translations, []) |
503 | |
504 | # If diverged translation is non-empty, POTMsgSet is listed. |
505 | self.factory.makeTranslationMessage( |
506 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
507 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
508 | translations=[u"Translation"]) |
509 | found_translations = list( |
510 | - self.devel_sr_pofile.getPOTMsgSetTranslated()) |
511 | + self.devel_pofile.getPOTMsgSetTranslated()) |
512 | self.assertEquals(found_translations, [self.potmsgset]) |
513 | |
514 | def test_getPOTMsgSetTranslated_EmptyShared(self): |
515 | @@ -406,29 +404,29 @@ |
516 | |
517 | # We create an empty shared translation first. |
518 | self.factory.makeSharedTranslationMessage( |
519 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
520 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
521 | translations=[u""]) |
522 | |
523 | # When there is no diverged translation, shared one is returned, |
524 | # but since it's empty, there are no results. |
525 | found_translations = list( |
526 | - self.devel_sr_pofile.getPOTMsgSetTranslated()) |
527 | + self.devel_pofile.getPOTMsgSetTranslated()) |
528 | self.assertEquals(found_translations, []) |
529 | |
530 | # When an empty diverged translation is added, nothing is listed. |
531 | self.factory.makeTranslationMessage( |
532 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
533 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
534 | translations=[u""]) |
535 | found_translations = list( |
536 | - self.devel_sr_pofile.getPOTMsgSetTranslated()) |
537 | + self.devel_pofile.getPOTMsgSetTranslated()) |
538 | self.assertEquals(found_translations, []) |
539 | |
540 | # If diverged translation is non-empty, POTMsgSet is listed. |
541 | self.factory.makeTranslationMessage( |
542 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
543 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
544 | translations=[u"Translation"]) |
545 | found_translations = list( |
546 | - self.devel_sr_pofile.getPOTMsgSetTranslated()) |
547 | + self.devel_pofile.getPOTMsgSetTranslated()) |
548 | self.assertEquals(found_translations, [self.potmsgset]) |
549 | |
550 | def test_getPOTMsgSetTranslated_Multiple(self): |
551 | @@ -437,7 +435,7 @@ |
552 | |
553 | # Add a diverged translation on the included POTMsgSet... |
554 | self.factory.makeTranslationMessage( |
555 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
556 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
557 | translations=[u"Diverged translation"]) |
558 | |
559 | # and a shared translation on newly added POTMsgSet... |
560 | @@ -446,12 +444,12 @@ |
561 | potmsgset.setSequence(self.devel_potemplate, 2) |
562 | |
563 | self.factory.makeSharedTranslationMessage( |
564 | - pofile=self.devel_sr_pofile, potmsgset=potmsgset, |
565 | + pofile=self.devel_pofile, potmsgset=potmsgset, |
566 | translations=[u"Shared translation"]) |
567 | |
568 | # Both POTMsgSets are listed. |
569 | found_translations = list( |
570 | - self.devel_sr_pofile.getPOTMsgSetTranslated()) |
571 | + self.devel_pofile.getPOTMsgSetTranslated()) |
572 | self.assertEquals(found_translations, [self.potmsgset, potmsgset]) |
573 | |
574 | def test_getPOTMsgSetUntranslated_NoShared(self): |
575 | @@ -460,23 +458,23 @@ |
576 | |
577 | # When there is no diverged translation either, nothing is returned. |
578 | found_translations = list( |
579 | - self.devel_sr_pofile.getPOTMsgSetUntranslated()) |
580 | + self.devel_pofile.getPOTMsgSetUntranslated()) |
581 | self.assertEquals(found_translations, [self.potmsgset]) |
582 | |
583 | # When a diverged translation is added, the potmsgset is returned. |
584 | self.factory.makeTranslationMessage( |
585 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
586 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
587 | translations=[u"Translation"]) |
588 | found_translations = list( |
589 | - self.devel_sr_pofile.getPOTMsgSetUntranslated()) |
590 | + self.devel_pofile.getPOTMsgSetUntranslated()) |
591 | self.assertEquals(found_translations, []) |
592 | |
593 | # If diverged translation is empty, POTMsgSet is not listed. |
594 | self.factory.makeTranslationMessage( |
595 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
596 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
597 | translations=[u""]) |
598 | found_translations = list( |
599 | - self.devel_sr_pofile.getPOTMsgSetUntranslated()) |
600 | + self.devel_pofile.getPOTMsgSetUntranslated()) |
601 | self.assertEquals(found_translations, [self.potmsgset]) |
602 | |
603 | def test_getPOTMsgSetUntranslated_Shared(self): |
604 | @@ -485,28 +483,28 @@ |
605 | |
606 | # We create a shared translation first. |
607 | self.factory.makeSharedTranslationMessage( |
608 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
609 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
610 | translations=[u"Shared translation"]) |
611 | |
612 | # When there is no diverged translation, shared one is returned. |
613 | found_translations = list( |
614 | - self.devel_sr_pofile.getPOTMsgSetUntranslated()) |
615 | + self.devel_pofile.getPOTMsgSetUntranslated()) |
616 | self.assertEquals(found_translations, []) |
617 | |
618 | # When an empty diverged translation is added, nothing is listed. |
619 | self.factory.makeTranslationMessage( |
620 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
621 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
622 | translations=[u""]) |
623 | found_translations = list( |
624 | - self.devel_sr_pofile.getPOTMsgSetUntranslated()) |
625 | + self.devel_pofile.getPOTMsgSetUntranslated()) |
626 | self.assertEquals(found_translations, [self.potmsgset]) |
627 | |
628 | # If diverged translation is non-empty, POTMsgSet is listed. |
629 | self.factory.makeTranslationMessage( |
630 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
631 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
632 | translations=[u"Translation"]) |
633 | found_translations = list( |
634 | - self.devel_sr_pofile.getPOTMsgSetUntranslated()) |
635 | + self.devel_pofile.getPOTMsgSetUntranslated()) |
636 | self.assertEquals(found_translations, []) |
637 | |
638 | def test_getPOTMsgSetUntranslated_EmptyShared(self): |
639 | @@ -515,29 +513,29 @@ |
640 | |
641 | # We create an empty shared translation first. |
642 | self.factory.makeSharedTranslationMessage( |
643 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
644 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
645 | translations=[u""]) |
646 | |
647 | # When there is no diverged translation, shared one is returned, |
648 | # but since it's empty, there are no results. |
649 | found_translations = list( |
650 | - self.devel_sr_pofile.getPOTMsgSetUntranslated()) |
651 | + self.devel_pofile.getPOTMsgSetUntranslated()) |
652 | self.assertEquals(found_translations, [self.potmsgset]) |
653 | |
654 | # When an empty diverged translation is added, nothing is listed. |
655 | self.factory.makeTranslationMessage( |
656 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
657 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
658 | translations=[u""]) |
659 | found_translations = list( |
660 | - self.devel_sr_pofile.getPOTMsgSetUntranslated()) |
661 | + self.devel_pofile.getPOTMsgSetUntranslated()) |
662 | self.assertEquals(found_translations, [self.potmsgset]) |
663 | |
664 | # If diverged translation is non-empty, POTMsgSet is listed. |
665 | self.factory.makeTranslationMessage( |
666 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
667 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
668 | translations=[u"Translation"]) |
669 | found_translations = list( |
670 | - self.devel_sr_pofile.getPOTMsgSetUntranslated()) |
671 | + self.devel_pofile.getPOTMsgSetUntranslated()) |
672 | self.assertEquals(found_translations, []) |
673 | |
674 | def test_getPOTMsgSetUntranslated_Multiple(self): |
675 | @@ -546,7 +544,7 @@ |
676 | |
677 | # Add an empty translation to the included POTMsgSet... |
678 | self.factory.makeTranslationMessage( |
679 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
680 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
681 | translations=[u""]) |
682 | |
683 | # ...and a new untranslated POTMsgSet. |
684 | @@ -556,7 +554,7 @@ |
685 | |
686 | # Both POTMsgSets are listed. |
687 | found_translations = list( |
688 | - self.devel_sr_pofile.getPOTMsgSetUntranslated()) |
689 | + self.devel_pofile.getPOTMsgSetUntranslated()) |
690 | self.assertEquals(found_translations, [self.potmsgset, potmsgset]) |
691 | |
692 | def test_getPOTMsgSetWithNewSuggestions(self): |
693 | @@ -564,17 +562,17 @@ |
694 | |
695 | # When there are no suggestions, nothing is returned. |
696 | found_translations = list( |
697 | - self.devel_sr_pofile.getPOTMsgSetWithNewSuggestions()) |
698 | + self.devel_pofile.getPOTMsgSetWithNewSuggestions()) |
699 | self.assertEquals(found_translations, []) |
700 | |
701 | # When a suggestion is added, the potmsgset is returned. |
702 | translation = self.factory.makeSuggestion( |
703 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
704 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
705 | translations=[u"Suggestion"]) |
706 | self.assertEquals(translation.is_current_ubuntu, False) |
707 | |
708 | found_translations = list( |
709 | - self.devel_sr_pofile.getPOTMsgSetWithNewSuggestions()) |
710 | + self.devel_pofile.getPOTMsgSetWithNewSuggestions()) |
711 | self.assertEquals(found_translations, [self.potmsgset]) |
712 | |
713 | def test_getPOTMsgSetWithNewSuggestions_multiple(self): |
714 | @@ -582,7 +580,7 @@ |
715 | |
716 | # One POTMsgSet has no translations, but only a suggestion. |
717 | self.factory.makeSuggestion( |
718 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
719 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
720 | translations=[u"New suggestion"]) |
721 | |
722 | # Another POTMsgSet has both a translation and a suggestion. |
723 | @@ -591,36 +589,36 @@ |
724 | potmsgset.setSequence(self.devel_potemplate, 2) |
725 | date_created = datetime.now(pytz.UTC) - timedelta(5) |
726 | self.factory.makeTranslationMessage( |
727 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
728 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
729 | translations=[u"Translation"], date_updated=date_created) |
730 | suggestion_date = date_created + timedelta(1) |
731 | self.factory.makeSuggestion( |
732 | - pofile=self.devel_sr_pofile, potmsgset=potmsgset, |
733 | - translations=[u"New suggestion"], date_updated=suggestion_date) |
734 | + pofile=self.devel_pofile, potmsgset=potmsgset, |
735 | + translations=[u"New suggestion"], date_created=suggestion_date) |
736 | |
737 | # Both POTMsgSets are listed. |
738 | found_translations = list( |
739 | - self.devel_sr_pofile.getPOTMsgSetWithNewSuggestions()) |
740 | + self.devel_pofile.getPOTMsgSetWithNewSuggestions()) |
741 | self.assertEquals(found_translations, [self.potmsgset, potmsgset]) |
742 | |
743 | def test_getPOTMsgSetWithNewSuggestions_distinct(self): |
744 | # Provide two suggestions on a single message and make sure |
745 | # a POTMsgSet is returned only once. |
746 | self.factory.makeSuggestion( |
747 | - pofile=self.devel_sr_pofile, |
748 | + pofile=self.devel_pofile, |
749 | potmsgset=self.potmsgset, |
750 | translations=["A suggestion"]) |
751 | self.factory.makeSuggestion( |
752 | - pofile=self.devel_sr_pofile, |
753 | + pofile=self.devel_pofile, |
754 | potmsgset=self.potmsgset, |
755 | translations=["Another suggestion"]) |
756 | |
757 | potmsgsets = list( |
758 | - self.devel_sr_pofile.getPOTMsgSetWithNewSuggestions()) |
759 | + self.devel_pofile.getPOTMsgSetWithNewSuggestions()) |
760 | self.assertEquals(potmsgsets, |
761 | [self.potmsgset]) |
762 | self.assertEquals( |
763 | - self.devel_sr_pofile.getPOTMsgSetWithNewSuggestions().count(), |
764 | + self.devel_pofile.getPOTMsgSetWithNewSuggestions().count(), |
765 | 1) |
766 | |
767 | def test_getPOTMsgSetWithNewSuggestions_empty(self): |
768 | @@ -628,12 +626,12 @@ |
769 | |
770 | # When an empty suggestion is added, the potmsgset is NOT returned. |
771 | translation = self.factory.makeSuggestion( |
772 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
773 | - translations=[None]) |
774 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
775 | + translations=[]) |
776 | self.assertEquals(False, translation.is_current_ubuntu) |
777 | |
778 | found_translations = list( |
779 | - self.devel_sr_pofile.getPOTMsgSetWithNewSuggestions()) |
780 | + self.devel_pofile.getPOTMsgSetWithNewSuggestions()) |
781 | self.assertEquals([], found_translations) |
782 | |
783 | def test_getPOTMsgSetChangedInUbuntu(self): |
784 | @@ -641,72 +639,72 @@ |
785 | |
786 | # If there are no translations in Ubuntu, nothing is listed. |
787 | found_translations = list( |
788 | - self.devel_sr_pofile.getPOTMsgSetChangedInUbuntu()) |
789 | + self.devel_pofile.getPOTMsgSetChangedInUbuntu()) |
790 | self.assertEquals(found_translations, []) |
791 | |
792 | # Adding a non-imported current translation doesn't change anything. |
793 | translation = self.factory.makeSharedTranslationMessage( |
794 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
795 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
796 | translations=[u"Non-imported translation"]) |
797 | self.assertEquals(translation.is_current_upstream, False) |
798 | found_translations = list( |
799 | - self.devel_sr_pofile.getPOTMsgSetChangedInUbuntu()) |
800 | + self.devel_pofile.getPOTMsgSetChangedInUbuntu()) |
801 | self.assertEquals(found_translations, []) |
802 | |
803 | # Adding an imported translation which is also current indicates |
804 | # that there are no changes. |
805 | translation = self.factory.makeSharedTranslationMessage( |
806 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
807 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
808 | translations=[u"Imported translation"], is_current_upstream=True) |
809 | self.assertEquals(translation.is_current_upstream, True) |
810 | self.assertEquals(translation.is_current_ubuntu, True) |
811 | found_translations = list( |
812 | - self.devel_sr_pofile.getPOTMsgSetChangedInUbuntu()) |
813 | + self.devel_pofile.getPOTMsgSetChangedInUbuntu()) |
814 | self.assertEquals(found_translations, []) |
815 | |
816 | # However, changing current translation to a non-imported one |
817 | # makes this a changed in Ubuntu translation. |
818 | translation = self.factory.makeSharedTranslationMessage( |
819 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
820 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
821 | translations=[u"Changed translation"], is_current_upstream=False) |
822 | self.assertEquals(translation.is_current_upstream, False) |
823 | self.assertEquals(translation.is_current_ubuntu, True) |
824 | found_translations = list( |
825 | - self.devel_sr_pofile.getPOTMsgSetChangedInUbuntu()) |
826 | + self.devel_pofile.getPOTMsgSetChangedInUbuntu()) |
827 | self.assertEquals(found_translations, [self.potmsgset]) |
828 | |
829 | # Adding a diverged, non-imported translation, still lists |
830 | # it as a changed translation. |
831 | translation = self.factory.makeTranslationMessage( |
832 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
833 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
834 | translations=[u"Diverged translation"], is_current_upstream=False) |
835 | self.assertEquals(translation.is_current_upstream, False) |
836 | self.assertEquals(translation.is_current_ubuntu, True) |
837 | found_translations = list( |
838 | - self.devel_sr_pofile.getPOTMsgSetChangedInUbuntu()) |
839 | + self.devel_pofile.getPOTMsgSetChangedInUbuntu()) |
840 | self.assertEquals(found_translations, [self.potmsgset]) |
841 | |
842 | # But adding a diverged current and imported translation means |
843 | # that it's not changed anymore. |
844 | translation = self.factory.makeTranslationMessage( |
845 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
846 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
847 | translations=[u"Diverged imported"], is_current_upstream=True, |
848 | force_diverged=True) |
849 | self.assertEquals(translation.is_current_upstream, True) |
850 | self.assertEquals(translation.is_current_ubuntu, True) |
851 | found_translations = list( |
852 | - self.devel_sr_pofile.getPOTMsgSetChangedInUbuntu()) |
853 | + self.devel_pofile.getPOTMsgSetChangedInUbuntu()) |
854 | self.assertEquals(found_translations, []) |
855 | |
856 | # Changing from a diverged, imported translation is correctly |
857 | # detected. |
858 | translation = self.factory.makeTranslationMessage( |
859 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
860 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
861 | translations=[u"Diverged changed"], is_current_upstream=False) |
862 | self.assertEquals(translation.is_current_upstream, False) |
863 | self.assertEquals(translation.is_current_ubuntu, True) |
864 | found_translations = list( |
865 | - self.devel_sr_pofile.getPOTMsgSetChangedInUbuntu()) |
866 | + self.devel_pofile.getPOTMsgSetChangedInUbuntu()) |
867 | self.assertEquals(found_translations, [self.potmsgset]) |
868 | |
869 | def test_getPOTMsgSetChangedInUbuntu_diverged_imported(self): |
870 | @@ -720,11 +718,11 @@ |
871 | # 1) Shared imported and current translation. |
872 | # 2) Diverged, imported, non-current message. |
873 | shared = self.factory.makeSharedTranslationMessage( |
874 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
875 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
876 | translations=[u"Shared imported current"], |
877 | is_current_upstream=True) |
878 | diverged = self.factory.makeTranslationMessage( |
879 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
880 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
881 | translations=[u"Diverged imported non-current"], |
882 | is_current_upstream=True, force_diverged=True) |
883 | # As we can't come to this situation using existing code, |
884 | @@ -740,7 +738,7 @@ |
885 | |
886 | # Such POTMsgSet is not considered changed in this PO file. |
887 | found_translations = list( |
888 | - self.devel_sr_pofile.getPOTMsgSetChangedInUbuntu()) |
889 | + self.devel_pofile.getPOTMsgSetChangedInUbuntu()) |
890 | self.assertEquals(found_translations, []) |
891 | |
892 | def test_getPOTMsgSetChangedInUbuntu_SharedDiverged(self): |
893 | @@ -749,34 +747,34 @@ |
894 | # Adding an imported translation which is also current indicates |
895 | # that there are no changes. |
896 | translation = self.factory.makeSharedTranslationMessage( |
897 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
898 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
899 | translations=[u"Imported translation"], is_current_upstream=True) |
900 | self.assertEquals(translation.is_current_upstream, True) |
901 | self.assertEquals(translation.is_current_ubuntu, True) |
902 | found_translations = list( |
903 | - self.devel_sr_pofile.getPOTMsgSetChangedInUbuntu()) |
904 | + self.devel_pofile.getPOTMsgSetChangedInUbuntu()) |
905 | self.assertEquals(found_translations, []) |
906 | |
907 | # Adding a diverged, non-imported translation makes it appear |
908 | # as changed. |
909 | translation = self.factory.makeTranslationMessage( |
910 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
911 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
912 | translations=[u"Changed translation"], is_current_upstream=False) |
913 | self.assertEquals(translation.is_current_upstream, False) |
914 | self.assertEquals(translation.is_current_ubuntu, True) |
915 | found_translations = list( |
916 | - self.devel_sr_pofile.getPOTMsgSetChangedInUbuntu()) |
917 | + self.devel_pofile.getPOTMsgSetChangedInUbuntu()) |
918 | self.assertEquals(found_translations, [self.potmsgset]) |
919 | |
920 | def test_getPOTMsgSetWithErrors(self): |
921 | # Test listing of POTMsgSets with errors in translations. |
922 | translation = self.factory.makeSharedTranslationMessage( |
923 | - pofile=self.devel_sr_pofile, potmsgset=self.potmsgset, |
924 | + pofile=self.devel_pofile, potmsgset=self.potmsgset, |
925 | translations=[u"Imported translation"], is_current_upstream=True) |
926 | removeSecurityProxy(translation).validation_status = ( |
927 | TranslationValidationStatus.UNKNOWNERROR) |
928 | found_translations = list( |
929 | - self.devel_sr_pofile.getPOTMsgSetWithErrors()) |
930 | + self.devel_pofile.getPOTMsgSetWithErrors()) |
931 | self.assertEquals(found_translations, [self.potmsgset]) |
932 | |
933 | def test_updateStatistics(self): |
934 | @@ -796,71 +794,71 @@ |
935 | potmsgset = self.factory.makePOTMsgSet(self.devel_potemplate) |
936 | potmsgset.setSequence(self.devel_potemplate, 2) |
937 | self.factory.makeSuggestion( |
938 | - pofile=self.devel_sr_pofile, potmsgset=potmsgset, |
939 | + pofile=self.devel_pofile, potmsgset=potmsgset, |
940 | translations=[u"Unreviewed suggestion"]) |
941 | |
942 | # Third POTMsgSet is translated, and with a suggestion. |
943 | potmsgset = self.factory.makePOTMsgSet(self.devel_potemplate) |
944 | potmsgset.setSequence(self.devel_potemplate, 3) |
945 | self.factory.makeTranslationMessage( |
946 | - pofile=self.devel_sr_pofile, potmsgset=potmsgset, |
947 | + pofile=self.devel_pofile, potmsgset=potmsgset, |
948 | translations=[u"Translation"], |
949 | date_updated=datetime.now(pytz.UTC)-timedelta(1)) |
950 | self.factory.makeSuggestion( |
951 | - pofile=self.devel_sr_pofile, potmsgset=potmsgset, |
952 | + pofile=self.devel_pofile, potmsgset=potmsgset, |
953 | translations=[u"Another suggestion"]) |
954 | |
955 | # Fourth POTMsgSet is translated in import. |
956 | potmsgset = self.factory.makePOTMsgSet(self.devel_potemplate) |
957 | potmsgset.setSequence(self.devel_potemplate, 4) |
958 | self.factory.makeTranslationMessage( |
959 | - pofile=self.devel_sr_pofile, potmsgset=potmsgset, |
960 | + pofile=self.devel_pofile, potmsgset=potmsgset, |
961 | translations=[u"Imported translation"], is_current_upstream=True) |
962 | |
963 | # Fifth POTMsgSet is translated in import, but changed in Ubuntu. |
964 | potmsgset = self.factory.makePOTMsgSet(self.devel_potemplate) |
965 | potmsgset.setSequence(self.devel_potemplate, 5) |
966 | self.factory.makeTranslationMessage( |
967 | - pofile=self.devel_sr_pofile, potmsgset=potmsgset, |
968 | + pofile=self.devel_pofile, potmsgset=potmsgset, |
969 | translations=[u"Imported translation"], is_current_upstream=True) |
970 | translation = self.factory.makeTranslationMessage( |
971 | - pofile=self.devel_sr_pofile, potmsgset=potmsgset, |
972 | + pofile=self.devel_pofile, potmsgset=potmsgset, |
973 | translations=[u"LP translation"], is_current_upstream=False) |
974 | |
975 | # Sixth POTMsgSet is translated in LP only. |
976 | potmsgset = self.factory.makePOTMsgSet(self.devel_potemplate) |
977 | potmsgset.setSequence(self.devel_potemplate, 6) |
978 | self.factory.makeTranslationMessage( |
979 | - pofile=self.devel_sr_pofile, potmsgset=potmsgset, |
980 | + pofile=self.devel_pofile, potmsgset=potmsgset, |
981 | translations=[u"New translation"], is_current_upstream=False) |
982 | |
983 | removeSecurityProxy(self.devel_potemplate).messagecount = ( |
984 | self.devel_potemplate.getPOTMsgSetsCount()) |
985 | |
986 | # Returns current, updates, rosetta, unreviewed counts. |
987 | - stats = self.devel_sr_pofile.updateStatistics() |
988 | + stats = self.devel_pofile.updateStatistics() |
989 | self.assertEquals((1, 1, 3, 2), stats) |
990 | |
991 | - self.assertEquals(6, self.devel_sr_pofile.messageCount()) |
992 | - self.assertEquals(4, self.devel_sr_pofile.translatedCount()) |
993 | - self.assertEquals(2, self.devel_sr_pofile.untranslatedCount()) |
994 | - self.assertEquals(1, self.devel_sr_pofile.currentCount()) |
995 | - self.assertEquals(3, self.devel_sr_pofile.rosettaCount()) |
996 | - self.assertEquals(1, self.devel_sr_pofile.updatesCount()) |
997 | - self.assertEquals(2, self.devel_sr_pofile.unreviewedCount()) |
998 | + self.assertEquals(6, self.devel_pofile.messageCount()) |
999 | + self.assertEquals(4, self.devel_pofile.translatedCount()) |
1000 | + self.assertEquals(2, self.devel_pofile.untranslatedCount()) |
1001 | + self.assertEquals(1, self.devel_pofile.currentCount()) |
1002 | + self.assertEquals(3, self.devel_pofile.rosettaCount()) |
1003 | + self.assertEquals(1, self.devel_pofile.updatesCount()) |
1004 | + self.assertEquals(2, self.devel_pofile.unreviewedCount()) |
1005 | |
1006 | def test_TranslationFileData_adapter(self): |
1007 | # Test that exporting works correctly with shared and diverged |
1008 | # messages. |
1009 | self.factory.makeSharedTranslationMessage( |
1010 | - pofile=self.devel_sr_pofile, |
1011 | + pofile=self.devel_pofile, |
1012 | potmsgset=self.potmsgset, |
1013 | translations=["Shared translation"]) |
1014 | |
1015 | # Get the adapter and extract only English singular and |
1016 | # first translation form from all messages. |
1017 | translation_file_data = getAdapter( |
1018 | - self.devel_sr_pofile, ITranslationFileData, 'all_messages') |
1019 | + self.devel_pofile, ITranslationFileData, 'all_messages') |
1020 | exported_messages = [ |
1021 | (msg.singular_text, msg.translations[0]) |
1022 | for msg in translation_file_data.messages] |
1023 | @@ -870,7 +868,7 @@ |
1024 | |
1025 | # When we add a diverged translation, only that is exported. |
1026 | self.factory.makeTranslationMessage( |
1027 | - pofile=self.devel_sr_pofile, |
1028 | + pofile=self.devel_pofile, |
1029 | potmsgset=self.potmsgset, |
1030 | translations=["Diverged translation"], |
1031 | force_diverged=True) |
1032 | @@ -878,7 +876,7 @@ |
1033 | # Get the adapter and extract only English singular and |
1034 | # first translation form from all messages. |
1035 | translation_file_data = getAdapter( |
1036 | - self.devel_sr_pofile, ITranslationFileData, 'all_messages') |
1037 | + self.devel_pofile, ITranslationFileData, 'all_messages') |
1038 | exported_messages = [ |
1039 | (msg.singular_text, msg.translations[0]) |
1040 | for msg in translation_file_data.messages] |
1041 | @@ -1041,9 +1039,9 @@ |
1042 | name="messages") |
1043 | |
1044 | # We'll use two PO files, one for each series. |
1045 | - self.devel_sr_pofile = self.factory.makePOFile( |
1046 | + self.devel_pofile = self.factory.makePOFile( |
1047 | 'sr', self.devel_potemplate) |
1048 | - self.stable_sr_pofile = self.factory.makePOFile( |
1049 | + self.stable_pofile = self.factory.makePOFile( |
1050 | 'sr', self.stable_potemplate) |
1051 | |
1052 | # Create two POTMsgSets that can be used to test in what order |
1053 | @@ -1054,19 +1052,19 @@ |
1054 | self.potmsgset2.setSequence(self.devel_potemplate, 2) |
1055 | |
1056 | def test_getPOTMsgSetTranslated_ordering(self): |
1057 | - # Translate both POTMsgSets in devel_sr_pofile, so |
1058 | + # Translate both POTMsgSets in devel_pofile, so |
1059 | # they are returned with getPOTMsgSetTranslated() call. |
1060 | self.factory.makeSharedTranslationMessage( |
1061 | - pofile=self.devel_sr_pofile, |
1062 | + pofile=self.devel_pofile, |
1063 | potmsgset=self.potmsgset1, |
1064 | translations=["Shared translation"]) |
1065 | self.factory.makeSharedTranslationMessage( |
1066 | - pofile=self.devel_sr_pofile, |
1067 | + pofile=self.devel_pofile, |
1068 | potmsgset=self.potmsgset2, |
1069 | translations=["Another shared translation"]) |
1070 | |
1071 | translated_potmsgsets = list( |
1072 | - self.devel_sr_pofile.getPOTMsgSetTranslated()) |
1073 | + self.devel_pofile.getPOTMsgSetTranslated()) |
1074 | self.assertEquals( |
1075 | [self.potmsgset1, self.potmsgset2], translated_potmsgsets) |
1076 | |
1077 | @@ -1077,20 +1075,20 @@ |
1078 | |
1079 | # And they are returned in the new order as desired. |
1080 | translated_potmsgsets = list( |
1081 | - self.stable_sr_pofile.getPOTMsgSetTranslated()) |
1082 | + self.stable_pofile.getPOTMsgSetTranslated()) |
1083 | self.assertEquals( |
1084 | [self.potmsgset2, self.potmsgset1], translated_potmsgsets) |
1085 | |
1086 | # Order is unchanged for the previous template. |
1087 | translated_potmsgsets = list( |
1088 | - self.devel_sr_pofile.getPOTMsgSetTranslated()) |
1089 | + self.devel_pofile.getPOTMsgSetTranslated()) |
1090 | self.assertEquals( |
1091 | [self.potmsgset1, self.potmsgset2], translated_potmsgsets) |
1092 | |
1093 | def test_getPOTMsgSetUntranslated_ordering(self): |
1094 | - # Both POTMsgSets in devel_sr_pofile are untranslated. |
1095 | + # Both POTMsgSets in devel_pofile are untranslated. |
1096 | untranslated_potmsgsets = list( |
1097 | - self.devel_sr_pofile.getPOTMsgSetUntranslated()) |
1098 | + self.devel_pofile.getPOTMsgSetUntranslated()) |
1099 | self.assertEquals( |
1100 | [self.potmsgset1, self.potmsgset2], untranslated_potmsgsets) |
1101 | |
1102 | @@ -1101,42 +1099,42 @@ |
1103 | |
1104 | # And they are returned in the new order as desired. |
1105 | untranslated_potmsgsets = list( |
1106 | - self.stable_sr_pofile.getPOTMsgSetUntranslated()) |
1107 | + self.stable_pofile.getPOTMsgSetUntranslated()) |
1108 | self.assertEquals( |
1109 | [self.potmsgset2, self.potmsgset1], untranslated_potmsgsets) |
1110 | |
1111 | # Order is unchanged for the previous template. |
1112 | untranslated_potmsgsets = list( |
1113 | - self.devel_sr_pofile.getPOTMsgSetUntranslated()) |
1114 | + self.devel_pofile.getPOTMsgSetUntranslated()) |
1115 | self.assertEquals( |
1116 | [self.potmsgset1, self.potmsgset2], untranslated_potmsgsets) |
1117 | |
1118 | def test_getPOTMsgSetChangedInUbuntu_ordering(self): |
1119 | - # Suggest a translation on both POTMsgSets in devel_sr_pofile, |
1120 | + # Suggest a translation on both POTMsgSets in devel_pofile, |
1121 | # so they are returned with getPOTMsgSetWithNewSuggestions() call. |
1122 | self.factory.makeSharedTranslationMessage( |
1123 | - pofile=self.devel_sr_pofile, |
1124 | + pofile=self.devel_pofile, |
1125 | potmsgset=self.potmsgset1, |
1126 | translations=["Imported"], |
1127 | is_current_upstream=True) |
1128 | self.factory.makeSharedTranslationMessage( |
1129 | - pofile=self.devel_sr_pofile, |
1130 | + pofile=self.devel_pofile, |
1131 | potmsgset=self.potmsgset1, |
1132 | translations=["Changed"], |
1133 | is_current_upstream=False) |
1134 | self.factory.makeSharedTranslationMessage( |
1135 | - pofile=self.devel_sr_pofile, |
1136 | + pofile=self.devel_pofile, |
1137 | potmsgset=self.potmsgset2, |
1138 | translations=["Another imported"], |
1139 | is_current_upstream=True) |
1140 | self.factory.makeSharedTranslationMessage( |
1141 | - pofile=self.devel_sr_pofile, |
1142 | + pofile=self.devel_pofile, |
1143 | potmsgset=self.potmsgset2, |
1144 | translations=["Another changed"], |
1145 | is_current_upstream=False) |
1146 | |
1147 | potmsgsets = list( |
1148 | - self.devel_sr_pofile.getPOTMsgSetChangedInUbuntu()) |
1149 | + self.devel_pofile.getPOTMsgSetChangedInUbuntu()) |
1150 | self.assertEquals( |
1151 | [self.potmsgset1, self.potmsgset2], potmsgsets) |
1152 | |
1153 | @@ -1147,28 +1145,28 @@ |
1154 | |
1155 | # And they are returned in the new order as desired. |
1156 | potmsgsets = list( |
1157 | - self.stable_sr_pofile.getPOTMsgSetChangedInUbuntu()) |
1158 | + self.stable_pofile.getPOTMsgSetChangedInUbuntu()) |
1159 | self.assertEquals( |
1160 | [self.potmsgset2, self.potmsgset1], potmsgsets) |
1161 | |
1162 | # Order is unchanged for the previous template. |
1163 | potmsgsets = list( |
1164 | - self.devel_sr_pofile.getPOTMsgSetChangedInUbuntu()) |
1165 | + self.devel_pofile.getPOTMsgSetChangedInUbuntu()) |
1166 | self.assertEquals( |
1167 | [self.potmsgset1, self.potmsgset2], potmsgsets) |
1168 | |
1169 | def test_getPOTMsgSetWithErrors_ordering(self): |
1170 | - # Suggest a translation on both POTMsgSets in devel_sr_pofile, |
1171 | + # Suggest a translation on both POTMsgSets in devel_pofile, |
1172 | # so they are returned with getPOTMsgSetWithNewSuggestions() call. |
1173 | imported1 = self.factory.makeSharedTranslationMessage( |
1174 | - pofile=self.devel_sr_pofile, |
1175 | + pofile=self.devel_pofile, |
1176 | potmsgset=self.potmsgset1, |
1177 | translations=["Imported"], |
1178 | is_current_upstream=True) |
1179 | removeSecurityProxy(imported1).validation_status = ( |
1180 | TranslationValidationStatus.UNKNOWNERROR) |
1181 | imported2 = self.factory.makeSharedTranslationMessage( |
1182 | - pofile=self.devel_sr_pofile, |
1183 | + pofile=self.devel_pofile, |
1184 | potmsgset=self.potmsgset2, |
1185 | translations=["Another imported"], |
1186 | is_current_upstream=True) |
1187 | @@ -1176,7 +1174,7 @@ |
1188 | TranslationValidationStatus.UNKNOWNERROR) |
1189 | |
1190 | potmsgsets = list( |
1191 | - self.devel_sr_pofile.getPOTMsgSetWithErrors()) |
1192 | + self.devel_pofile.getPOTMsgSetWithErrors()) |
1193 | self.assertEquals( |
1194 | [self.potmsgset1, self.potmsgset2], potmsgsets) |
1195 | |
1196 | @@ -1187,13 +1185,13 @@ |
1197 | |
1198 | # And they are returned in the new order as desired. |
1199 | potmsgsets = list( |
1200 | - self.stable_sr_pofile.getPOTMsgSetWithErrors()) |
1201 | + self.stable_pofile.getPOTMsgSetWithErrors()) |
1202 | self.assertEquals( |
1203 | [self.potmsgset2, self.potmsgset1], potmsgsets) |
1204 | |
1205 | # Order is unchanged for the previous template. |
1206 | potmsgsets = list( |
1207 | - self.devel_sr_pofile.getPOTMsgSetWithErrors()) |
1208 | + self.devel_pofile.getPOTMsgSetWithErrors()) |
1209 | self.assertEquals( |
1210 | [self.potmsgset1, self.potmsgset2], potmsgsets) |
1211 | |
1212 | @@ -1228,11 +1226,11 @@ |
1213 | |
1214 | # Give the method something to search for. |
1215 | self.factory.makeSharedTranslationMessage( |
1216 | - pofile=self.devel_sr_pofile, |
1217 | + pofile=self.devel_pofile, |
1218 | potmsgset=self.potmsgset1, |
1219 | translations=["Shared translation"]) |
1220 | self.factory.makeSharedTranslationMessage( |
1221 | - pofile=self.devel_sr_pofile, |
1222 | + pofile=self.devel_pofile, |
1223 | potmsgset=self.potmsgset2, |
1224 | translations=["Another shared translation"]) |
1225 | |
1226 | @@ -1241,7 +1239,7 @@ |
1227 | removeSecurityProxy(self.potmsgset2).sequence = 1 |
1228 | |
1229 | potmsgsets = list( |
1230 | - self.devel_sr_pofile.findPOTMsgSetsContaining("translation")) |
1231 | + self.devel_pofile.findPOTMsgSetsContaining("translation")) |
1232 | |
1233 | # Order ignores potmsgset.sequence. |
1234 | self.assertEquals( |
1235 | |
1236 | === modified file 'lib/lp/translations/tests/test_translatablemessage.py' |
1237 | --- lib/lp/translations/tests/test_translatablemessage.py 2010-08-16 09:01:35 +0000 |
1238 | +++ lib/lp/translations/tests/test_translatablemessage.py 2010-08-16 15:11:45 +0000 |
1239 | @@ -47,7 +47,7 @@ |
1240 | if is_suggestion: |
1241 | return self.factory.makeSuggestion( |
1242 | pofile=self.pofile, potmsgset=self.potmsgset, |
1243 | - translations=translation, date_updated=date_updated) |
1244 | + translations=translation, date_created=date_updated) |
1245 | else: |
1246 | return self.factory.makeTranslationMessage( |
1247 | pofile=self.pofile, potmsgset=self.potmsgset, |
1248 | |
1249 | === modified file 'lib/lp/translations/tests/test_translations_to_review.py' |
1250 | --- lib/lp/translations/tests/test_translations_to_review.py 2010-08-16 09:01:35 +0000 |
1251 | +++ lib/lp/translations/tests/test_translations_to_review.py 2010-08-16 15:11:55 +0000 |
1252 | @@ -86,7 +86,7 @@ |
1253 | self.factory.makeSuggestion( |
1254 | potmsgset=self.potmsgset, pofile=self.pofile, |
1255 | translator=self.factory.makePerson(), translations=['wi'], |
1256 | - date_updated=later_time)) |
1257 | + date_created=later_time)) |
1258 | |
1259 | self.assertTrue(self.translation.is_current_ubuntu) |
1260 | self.pofile.updateStatistics() |
Am 16.08.2010 16:37, schrieb Jeroen T. Vermeulen: testing/ factory. py === nsDict default to None. nsDict goes "Make sure translations are in the right format." That's a bit ambiguous as to what happens when the translations are not in the right format. Consider saying something like "Convert translations" (and adding a note saying that it returns the original translations if they are already in the desired format). translations, dict) / else" (where the "else" part returns dict(enumerate( translations) )).
> Wow, big branch. I know it wasn't easy. Lots of goodness here, including lint cleanups all over the place. But you also inherited some uglier things, and it seems to me that your "make lint" run was incomplete somehow. I hope we can make some more headway with that, but in the interest of getting the branch in it's not as important as cleaning up the new bits.
>
> We discussed some of these on IRC, but most we didn't.
>
>
> === lib/lp/
>
> Might as well make the "translations" parameter to _makeTranslatio
>
> The docstring for _makeTranslatio
>
> In the same docstring, don't lead with "the right format"--name the format! An example like '{0: "foo"}' may say it most effectively.
>
> Naming all types of sequence that might make up a non-dict translations list is probably a losing game: is it really necessary to accept tuples? What about ResultSets? If it's really needed, consider rearranging the conditions: "if translations is None / elif isinstance(
I fixed all this as per our IRC discussion.
>
> In makeSuggestion: it's no longer necessary to setSequence on a POTMsgSet you get from makePOTMsgSet. Just pass a sequence number to makePOTMsgSet.
Ah yes, I copied and pasted makeSuggestion from makeTranslation Message. I
added fixed it there, too. Funny enough, it was me who introduced the
parameter to the factory method in the first place. ;)
> self._makeTrans lationsDict( translations)
> In makeSuggestion, this line lacks spaces around the assignment operator:
>
> translations=
Yes, I had it directly in the function call at first. Thanks.
> on_message. date_created to date_updated? I'd expect date_updated to set date_updated, not date_created.
> And why does it set naked_translati
>
Again, copied from makeTranslation Message where it is a bit more approriate
although it sets "date_created" and "date_reviewed" there. I renamed the
parameter in makeSuggestion to date_created and update all call sites.
> translations/ browser/ tests/test_ pofile_ view.py ==
> == lib/lp/
>
> Thanks for cleaning up the lint! While you're at it, could you chuck the entire test_suite function? We no longer need those, so they're just cruft now.
Ah yes, right. I am always happy to remove cruft! ;-)
> translations/ browser/ translationmess age.py ==
>
> == lib/lp/
>
> More lint cleanups. Good show.
Thank you for the applause! ;)
> translations/ tests/test_ pofile. py ==
>
> == lib/lp/
>
> There's a lot of code here that you clearly only moved, so you're probably more a victim than a perpetrator. But still I hope you can fix some of this, if it doesn't mean too much extra work.
Well, let's see .. ;-)
>
> In setUp, this comment:
>
> # POTemplate is 'shared' if it has the same name ('messages').
>
> ...is rather confusing. I'd rather say that two POTemplates share if they have the same name. And separately, that these particular two templates both have "messages" for a name.
Easy. Changed. In both test cases ;-)
>
> In the names devel_sr_pofile and stable_sr_pofile, unless the "sr" part is actually relevant to the tests, I'd leave it out of the names.
Find & Replace but it makes the branch a whole lot bigger...
>
> This comment:
>
> # Create a single POTMsgSet that is used across all tests,
> # and add it to only one of the POTemplates.
>
> ...commits the standard mistake of repeating what the code does. That's useless. The only interesting part is that the potmsgset is only added to one of the templates... *Why* is that?
I find the "why" hard to explain. "To demonstrate message sharing."? I did not
try to explain, they will have to read the tests ... ;-)
> setSequence. Just pass the sequence number to makePOTMsgSet.
> And right below that, once again: no need to self.potmsgset.
Yes, yes. Fixed.
> etWithNewSugges tions_Shared, is Shared supposed to be capitalized?
> In test_getPOTMsgS
Probably not.
>
> This test method, by the way, tests 4 separate situations. That's a lot for one test, and risks sliding back into bad old doctest practice. Could you break it down a bit?
No. Sorry. That would have to be an extra tech debt branch. I guess the whole
file could use some updating in this respect.
> now(pytz. UTC)-timedelta( 5)
> In line 203 of the diff, this line again lacks spaces around an operator and I don't see how "make lint" could have accepted it:
>
> date_created = datetime.
True, it is really strange that it missed that.
> is_current_ ubuntu= True
> In line 207, this line has space only on side of an operator:
>
> translation.
Strange, too. Well spotted.
> ls(found_ translations, []) ls(suggestion. is_current_ ubuntu, False)
> This assertion in line 212 has the expected and actual values switched around:
>
> self.assertEqua
>
> The same goes for line 219, where we might as well use assertFalse:
>
> self.assertEqua
>
> ...And so on for all other assertions I see in the test.
Yes, I did fix that in some places but stopped because it would have gotten
out of hand. I am not going to start again now, sorry.
> etWithNewSugges tions_Diverged. Again, why the capitalized word at the end? And again, could you break this 4-stage scenario down into smaller tests?
> Then, test_getPOTMsgS
Changed. And "No".
>
> There's another pair of missing spaces in line 258, but I'm tired of playing human linter. Please re-run "make lint" and fix!
I'd say the linter is broken. There was nothing relevant disabled, either.
>
> The comment in line 264 is missing an article before "shared current translation."
My guess: Serbian or Spanish speaker, which ever language does not use
indistinct articles. I don't always fix these even if I see them because it
gives our code this international, personal touch. Does it not? ;-)
>
> The comment in line 281 (again missing an article) talks about "Shared suggestion." I think what is meant is just "The suggestion."
Or "A suggestion"?
>
> The comment in line 286 says "When a diverged translation is done after the shared suggestion." Can you find a more descriptive verb than "done"?
added.
>
> In line 310, this comment surprises me:
>
> # Setting a suggestion as current makes it have no unreviewed
> # suggestions.
>
> As far as I know, that only happens if the review date is also updated. (The creation or last-update date may be used as a fallback if the review date is not set; I don't recall off the top of my head). In that case, the new current translation is presumably newer than all suggestions and so leaves no new suggestions. But the test code there only sets the flag. I think this passes more or less by accident; what if there's another suggestion that's newer than the suggestion that's being made current?
Didn't the old validators do all that? I agree though, that this most likely
passes by accident now and I am pretty sure there may be more tests that do.
This branch was meant as a mechanical replacement, though, so I think trying
to check and fix all tests is beyond the scope.
> translations/ tests/test_ potmsgset. py.
> In line 519 of the diff, you pass translations=[None] to makeSuggestion. Is that None actually needed? Or would a simple [] be enough? The same goes for line 675, in lib/lp/
Well, let's try .... Yes, you are right! Thanks!
> translations/ utilities/ sanitize. py == nsDict. Is there no good way of sharing it between the usees? translations, (list, tuple)): translations) )
>
> == lib/lp/
>
> In line 874 of the diff I see code that's also in the new _makeTranslatio
>
> if isinstance(
> translations = dict(enumerate(
Not anymore now. ;-) Also, I think the overhead would not be justified and
dict(enumerate()) is a simple enough (only uses builtin functions) to stand on
its own.
> translations/ utilities/ tests/test_ sanitize. py == translations_ not_in_ dict. Very easy to read.
>
> == lib/lp/
>
> Love test_sanitize_
>
I am happy to bring you joy!
Thank you for your thorough review. I am sorry that I flat our refused some
requests but I really want to get this branch out the door now ...
Cheers,
Henning