Merge lp:~henninge/launchpad/db-devel-bug-611668-filtermethods-2 into lp:launchpad/db-devel

Proposed by Henning Eggers
Status: Merged
Approved by: Henning Eggers
Approved revision: no longer in the source branch.
Merged at revision: 10047
Proposed branch: lp:~henninge/launchpad/db-devel-bug-611668-filtermethods-2
Merge into: lp:launchpad/db-devel
Prerequisite: lp:~henninge/launchpad/db-devel-bug-611668-filtermethods-1
Diff against target: 1133 lines (+590/-22) (has conflicts)
5 files modified
lib/lp/translations/browser/pofile.py (+10/-0)
lib/lp/translations/doc/pofile.txt (+4/-0)
lib/lp/translations/interfaces/pofile.py (+5/-0)
lib/lp/translations/model/pofile.py (+70/-5)
lib/lp/translations/tests/test_pofile.py (+501/-17)
Text conflict in lib/lp/translations/browser/pofile.py
Text conflict in lib/lp/translations/browser/tests/test_pofile_view.py
Text conflict in lib/lp/translations/doc/pofile.txt
Text conflict in lib/lp/translations/interfaces/pofile.py
Text conflict in lib/lp/translations/model/pofile.py
Text conflict in lib/lp/translations/tests/test_pofile.py
Text conflict in lib/lp/translations/tests/test_translations_to_review.py
To merge this branch: bzr merge lp:~henninge/launchpad/db-devel-bug-611668-filtermethods-2
Reviewer Review Type Date Requested Status
Leonard Richardson (community) Approve
Review via email: mp+42293@code.launchpad.net

Description of the change

== Details ==

This branch continues the quest for the transformation of the messsage filter methods to the new translations model. It contains the following changes:

 * Create TestUpstreamFilters and TestUbuntuFilters from
   the scenario created in the previous branch.
 * Rename getPOTMsgSetChangedInUbuntu to
   getPOTMsgSetDifferentTranslations because the old name
   was specific to the old model.
 * Make the getPOTMsgSet* methods side-aware,
   i.e. convert them to the new model.
 * Convert all of test_pofile.py to the new model (i.e.
   use makeCurrentTranslationMessage). Part of this was
   needed to make the tests pass again.

== Tests ==

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

pofile.txt ist still failng that will be fixed in the next branch.

To post a comment you must log in.
Revision history for this message
Leonard Richardson (leonardr) wrote :

I approve with what are hopefully minor changes. Specifically, I found test_getPOTMsgSetDifferentTranslations very confusing. The comments and sample code are talking about "one side" and "both sides"--it would be easier for me to understand if you specified "upstream side but not Ubuntu side" and "both upstream and ubuntu sides", especially since the things you're testing are .is_current_ubuntu and .is_current_upstream.

You also use "diverged" vs. "changed" in that test without explaining the difference. I can almost figure out what you mean by looking at the test, but not quite because a) you never explained what "changed" means (on IRC you said it was an old term, so why still use it?)--what has changed? And it's not clear why setting diverged=True makes is_current_upstream True and is_current_ubuntu False, instead of vice versa.

This is the change that might not be minor: what would happen if I passed in both current_other=True and diverged=True? Would I get an error, or would one of those arguments win? It seems like there should be a single 'status' argument which can take on different values like (just making these up) 'current', 'ubuntu_diverged' or 'upstream_diverged'. Maybe it's too late to change the method signature like this, but that would make this whole system a lot more comprehensible.

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

Thank you for the review. I did not get to work on this any further because we reverted the recife branch from db-devel again, so this change got less urgent. I am finishing this now but will merge it into the recife branch (which will soon be merged into db-devel again, I expect).

> I approve with what are hopefully minor changes. Specifically, I found
> test_getPOTMsgSetDifferentTranslations very confusing. The comments and sample
> code are talking about "one side" and "both sides"--it would be easier for me
> to understand if you specified "upstream side but not Ubuntu side" and "both
> upstream and ubuntu sides", especially since the things you're testing are
> .is_current_ubuntu and .is_current_upstream.

I can see how this is confusing. I did two things: I added a note explaining about the situation in this test and I also added method that pick the right flag for "this side" and "other side" so that the whole test only uses those terms.

>
> You also use "diverged" vs. "changed" in that test without explaining the
> difference. I can almost figure out what you mean by looking at the test, but
> not quite because a) you never explained what "changed" means (on IRC you said
> it was an old term, so why still use it?)--what has changed?

I removed the term "changed" from the code, so this should be less confusing now.

> And it's not
> clear why setting diverged=True makes is_current_upstream True and
> is_current_ubuntu False, instead of vice versa.

Diverging a translation makes it the current translation on "this side" which in this case is "upstream". As mentioned earlier I made that clearer by removing direct references to "is_current_upstream" and "is_current_ubuntu".

> This is the change that might not be minor: what would happen if I passed in
> both current_other=True and diverged=True? Would I get an error, or would one
> of those arguments win?

No, that combination makes no sense and the factory method has an assertion for it.

> It seems like there should be a single 'status'
> argument which can take on different values like (just making these up)
> 'current', 'ubuntu_diverged' or 'upstream_diverged'. Maybe it's too late to
> change the method signature like this, but that would make this whole system a
> lot more comprehensible.

Well, maybe not too late but certainly not for this branch. Changing the factory signature would mean also changing a lot of tests that use it. Maybe we are missing some good documentation that explains the different states and such? This may be a Good Thing to improve in light of what is coming...

Cheers,
Henning

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/translations/browser/pofile.py'
2--- lib/lp/translations/browser/pofile.py 2010-12-01 11:26:57 +0000
3+++ lib/lp/translations/browser/pofile.py 2010-12-07 19:31:29 +0000
4@@ -436,8 +436,13 @@
5 'translated': self.context.getPOTMsgSetTranslated,
6 'untranslated': self.context.getPOTMsgSetUntranslated,
7 'new_suggestions': self.context.getPOTMsgSetWithNewSuggestions,
8+<<<<<<< TREE
9 'changed_in_launchpad':
10 self.context.getPOTMsgSetChangedInLaunchpad,
11+=======
12+ 'changed_in_ubuntu':
13+ self.context.getPOTMsgSetDifferentTranslations,
14+>>>>>>> MERGE-SOURCE
15 }
16
17 if self.show not in get_functions:
18@@ -964,8 +969,13 @@
19 'translated': self.context.getPOTMsgSetTranslated,
20 'untranslated': self.context.getPOTMsgSetUntranslated,
21 'new_suggestions': self.context.getPOTMsgSetWithNewSuggestions,
22+<<<<<<< TREE
23 'changed_in_launchpad':
24 self.context.getPOTMsgSetChangedInLaunchpad,
25+=======
26+ 'changed_in_ubuntu':
27+ self.context.getPOTMsgSetDifferentTranslations,
28+>>>>>>> MERGE-SOURCE
29 }
30
31 if self.show not in get_functions:
32
33=== modified file 'lib/lp/translations/doc/pofile.txt'
34--- lib/lp/translations/doc/pofile.txt 2010-12-07 19:31:22 +0000
35+++ lib/lp/translations/doc/pofile.txt 2010-12-07 19:31:29 +0000
36@@ -46,7 +46,11 @@
37 >>> dummy_pofile.getPOTMsgSetTranslated().count()
38 0
39
40+<<<<<<< TREE
41 >>> dummy_pofile.getPOTMsgSetChangedInLaunchpad().count()
42+=======
43+ >>> dummy_pofile.getPOTMsgSetDifferentTranslations().count()
44+>>>>>>> MERGE-SOURCE
45 0
46
47 >>> dummy_pofile.getPOTMsgSetWithNewSuggestions().count()
48
49=== modified file 'lib/lp/translations/interfaces/pofile.py'
50--- lib/lp/translations/interfaces/pofile.py 2010-12-01 11:26:57 +0000
51+++ lib/lp/translations/interfaces/pofile.py 2010-12-07 19:31:29 +0000
52@@ -181,11 +181,16 @@
53 """Get pot message sets with suggestions submitted after last review.
54 """
55
56+<<<<<<< TREE
57 def getPOTMsgSetChangedInLaunchpad():
58 """Get pot message sets changed through Launchpad in this PO file.
59
60 'Changed in Launchpad' are only those which were translated when
61 initially imported, but then got overridden in Launchpad.
62+=======
63+ def getPOTMsgSetDifferentTranslations():
64+ """Get pot message sets with different translations on both sides.
65+>>>>>>> MERGE-SOURCE
66 """
67
68 def getPOTMsgSetWithErrors():
69
70=== modified file 'lib/lp/translations/model/pofile.py'
71--- lib/lp/translations/model/pofile.py 2010-12-07 19:31:22 +0000
72+++ lib/lp/translations/model/pofile.py 2010-12-07 19:31:29 +0000
73@@ -691,9 +691,15 @@
74 Return a tuple of SQL (clauses, clause_tables) to be used with
75 POTMsgSet.select().
76 """
77+ flag_name = getUtility(ITranslationSideTraitsSet).getForTemplate(
78+ self.potemplate).flag_name
79 clause_tables = ['TranslationTemplateItem', 'TranslationMessage']
80 clauses = self._getClausesForPOFileMessages()
81+<<<<<<< TREE
82 clauses.append('TranslationMessage.is_current IS TRUE')
83+=======
84+ clauses.append('TranslationMessage.%s IS TRUE' % flag_name)
85+>>>>>>> MERGE-SOURCE
86 self._appendCompletePluralFormsConditions(clauses)
87
88 # A message is current in this pofile if:
89@@ -712,11 +718,19 @@
90 SELECT * FROM TranslationMessage AS diverged
91 WHERE
92 diverged.potemplate=%(potemplate)s AND
93+<<<<<<< TREE
94 diverged.is_current IS TRUE AND
95+=======
96+ diverged.%(flag_name)s IS TRUE AND
97+>>>>>>> MERGE-SOURCE
98 diverged.language = %(language)s AND
99 diverged.potmsgset=TranslationMessage.potmsgset)''' % (
100- dict(language=quote(self.language),
101- potemplate=quote(self.potemplate))),
102+ dict(
103+ flag_name=flag_name,
104+ language=quote(self.language),
105+ potemplate=quote(self.potemplate),
106+ )
107+ ),
108 ]
109 shared_translation_query = ' AND '.join(shared_translation_clauses)
110
111@@ -768,23 +782,35 @@
112
113 def getPOTMsgSetWithNewSuggestions(self):
114 """See `IPOFile`."""
115+ flag_name = getUtility(ITranslationSideTraitsSet).getForTemplate(
116+ self.potemplate).flag_name
117 clauses = self._getClausesForPOFileMessages()
118 msgstr_clause = make_plurals_sql_fragment(
119 "TranslationMessage.msgstr%(form)d IS NOT NULL", "OR")
120 clauses.extend([
121 'TranslationTemplateItem.potmsgset = POTMsgSet.id',
122+<<<<<<< TREE
123 'TranslationMessage.is_current IS NOT TRUE',
124 "(%s)" % msgstr_clause,
125+=======
126+ 'TranslationMessage.%s IS NOT TRUE' % flag_name,
127+ "(%s)" % msgstr_clause
128+>>>>>>> MERGE-SOURCE
129 ])
130
131 diverged_translation_query = (
132 '''(SELECT COALESCE(diverged.date_reviewed, diverged.date_created)
133 FROM TranslationMessage AS diverged
134 WHERE
135+<<<<<<< TREE
136 diverged.is_current IS TRUE AND
137+=======
138+ diverged.%(flag_name)s IS TRUE AND
139+>>>>>>> MERGE-SOURCE
140 diverged.potemplate = %(potemplate)s AND
141 diverged.language = %(language)s AND
142 diverged.potmsgset=POTMsgSet.id)''' % dict(
143+ flag_name=flag_name,
144 potemplate=quote(self.potemplate),
145 language=quote(self.language)))
146
147@@ -792,10 +818,15 @@
148 '''(SELECT COALESCE(shared.date_reviewed, shared.date_created)
149 FROM TranslationMessage AS shared
150 WHERE
151+<<<<<<< TREE
152 shared.is_current IS TRUE AND
153+=======
154+ shared.%(flag_name)s IS TRUE AND
155+>>>>>>> MERGE-SOURCE
156 shared.potemplate IS NULL AND
157 shared.language = %(language)s AND
158 shared.potmsgset=POTMsgSet.id)''' % dict(
159+ flag_name=flag_name,
160 language=quote(self.language)))
161 beginning_of_time = "TIMESTAMP '1970-01-01 00:00:00'"
162 newer_than_query = (
163@@ -818,41 +849,71 @@
164 return self._getOrderedPOTMsgSets(
165 [POTMsgSet, TranslationTemplateItem], query)
166
167+<<<<<<< TREE
168 def getPOTMsgSetChangedInLaunchpad(self):
169+=======
170+ def getPOTMsgSetDifferentTranslations(self):
171+>>>>>>> MERGE-SOURCE
172 """See `IPOFile`."""
173+<<<<<<< TREE
174 # POT set has been changed in Launchpad if it contains active
175 # translation which didn't come from a published package
176 # (iow, it's different from a published translation: this only
177 # lists translations which have actually changed in LP, not
178 # translations which are 'new' and only exist in LP).
179+=======
180+ # A `POTMsgSet` has different translations if both sides have a
181+ # translation. If one of them is empty, the POTMsgSet is not included
182+ # in this list.
183+>>>>>>> MERGE-SOURCE
184
185+<<<<<<< TREE
186 # TranslationMessage is changed if:
187 # is_current IS TRUE, is_imported IS FALSE,
188 # (diverged AND not empty) OR (shared AND not empty AND no diverged)
189 # exists imported (is_imported AND not empty AND (diverged OR shared))
190+=======
191+>>>>>>> MERGE-SOURCE
192 clauses, clause_tables = self._getTranslatedMessagesQuery()
193+ other_side_flag_name = getUtility(
194+ ITranslationSideTraitsSet).getForTemplate(
195+ self.potemplate).other_side_traits.flag_name
196 clauses.extend([
197 'TranslationTemplateItem.potmsgset = POTMsgSet.id',
198+<<<<<<< TREE
199 'TranslationMessage.is_imported IS FALSE',
200+=======
201+ 'TranslationMessage.%s IS FALSE' % other_side_flag_name,
202+>>>>>>> MERGE-SOURCE
203 ])
204
205 imported_no_diverged = (
206 '''NOT EXISTS (
207 SELECT * FROM TranslationMessage AS diverged
208 WHERE
209+<<<<<<< TREE
210 diverged.is_imported IS TRUE AND
211+=======
212+ diverged.%(flag_name)s IS TRUE AND
213+>>>>>>> MERGE-SOURCE
214 diverged.id <> imported.id AND
215 diverged.potemplate = %(potemplate)s AND
216 diverged.language = %(language)s AND
217 diverged.potmsgset=TranslationMessage.potmsgset)''' % (
218- dict(potemplate=quote(self.potemplate),
219- language=quote(self.language))))
220-
221+ dict(
222+ flag_name=other_side_flag_name,
223+ potemplate=quote(self.potemplate),
224+ language=quote(self.language))
225+ ))
226 imported_clauses = [
227 'imported.id <> TranslationMessage.id',
228 'imported.potmsgset = POTMsgSet.id',
229 'imported.language = %s' % sqlvalues(self.language),
230+<<<<<<< TREE
231 'imported.is_imported IS TRUE',
232+=======
233+ 'imported.%s IS TRUE' % other_side_flag_name,
234+>>>>>>> MERGE-SOURCE
235 '(imported.potemplate=%s OR ' % sqlvalues(self.potemplate) +
236 ' (imported.potemplate IS NULL AND ' + imported_no_diverged
237 + ' ))',
238@@ -1506,11 +1567,15 @@
239 """See `IPOFile`."""
240 return EmptyResultSet()
241
242+<<<<<<< TREE
243 def getPOTMsgSetChangedInLaunchpad(self):
244 """See `IPOFile`."""
245 return EmptyResultSet()
246
247 def getPOTMsgSetWithErrors(self):
248+=======
249+ def getPOTMsgSetDifferentTranslations(self):
250+>>>>>>> MERGE-SOURCE
251 """See `IPOFile`."""
252 return EmptyResultSet()
253
254
255=== modified file 'lib/lp/translations/tests/test_pofile.py'
256--- lib/lp/translations/tests/test_pofile.py 2010-12-07 19:31:22 +0000
257+++ lib/lp/translations/tests/test_pofile.py 2010-12-07 19:31:29 +0000
258@@ -54,6 +54,175 @@
259 ITranslationsPerson(person).translations_relicensing_agreement = choice
260
261
262+<<<<<<< TREE
263+=======
264+class TestTranslationSharedPOFileSourcePackage(TestCaseWithFactory):
265+ """Test behavior of PO files with shared POTMsgSets on a source package.
266+ """
267+
268+ layer = ZopelessDatabaseLayer
269+
270+ def setUp(self):
271+ # Create a product with two series and a shared POTemplate
272+ # in different series ('devel' and 'stable').
273+ super(TestTranslationSharedPOFileSourcePackage, self).setUp()
274+ self.foo = self.factory.makeDistribution()
275+ self.foo_devel = self.factory.makeDistroSeries(
276+ name='devel', distribution=self.foo)
277+ self.foo_stable = self.factory.makeDistroSeries(
278+ name='stable', distribution=self.foo)
279+ self.foo.official_rosetta = True
280+ self.sourcepackagename = self.factory.makeSourcePackageName()
281+
282+ # Two POTemplates share translations if they have the same name,
283+ # in this case 'messages'.
284+ self.devel_potemplate = self.factory.makePOTemplate(
285+ distroseries=self.foo_devel,
286+ sourcepackagename=self.sourcepackagename,
287+ name="messages")
288+ self.stable_potemplate = self.factory.makePOTemplate(
289+ distroseries=self.foo_stable,
290+ sourcepackagename=self.sourcepackagename,
291+ name="messages")
292+
293+ # We'll use two PO files, one for each series.
294+ self.devel_pofile = self.factory.makePOFile(
295+ 'sr', self.devel_potemplate)
296+ self.stable_pofile = self.factory.makePOFile(
297+ 'sr', self.stable_potemplate)
298+
299+ # The POTMsgSet is added to only one of the POTemplates.
300+ self.potmsgset = self.factory.makePOTMsgSet(
301+ self.devel_potemplate, sequence=1)
302+
303+ def test_getPOTMsgSetWithNewSuggestions_shared(self):
304+ # Test listing of suggestions for POTMsgSets with a shared
305+ # translation.
306+
307+ # A POTMsgSet has a shared, current translation created 5 days ago.
308+ date_created = datetime.now(pytz.UTC) - timedelta(5)
309+ translation = self.factory.makeSuggestion(
310+ pofile=self.devel_pofile, potmsgset=self.potmsgset,
311+ translations=[u"Translation"], date_created=date_created)
312+ translation.is_current_ubuntu = True
313+
314+ # When there are no suggestions, nothing is returned.
315+ found_translations = list(
316+ self.devel_pofile.getPOTMsgSetWithNewSuggestions())
317+ self.assertEquals(found_translations, [])
318+
319+ # When a suggestion is added one day after, the potmsgset is returned.
320+ suggestion_date = date_created + timedelta(1)
321+ suggestion = self.factory.makeSuggestion(
322+ pofile=self.devel_pofile, potmsgset=self.potmsgset,
323+ translations=[u"Suggestion"], date_created=suggestion_date)
324+ self.assertEquals(suggestion.is_current_ubuntu, False)
325+
326+ found_translations = list(
327+ self.devel_pofile.getPOTMsgSetWithNewSuggestions())
328+ self.assertEquals(found_translations, [self.potmsgset])
329+
330+ # Setting a suggestion as current makes it have no unreviewed
331+ # suggestions.
332+ # XXX henninge 2010-08-17: It looks like this test passes by
333+ # accident as the suggestion already is the newest translation
334+ # available. Other tests may be passing just by accident, too.
335+ # This will have to be investigated when all bits and pieces are in
336+ # place.
337+ translation.is_current_ubuntu = False
338+ suggestion.is_current_ubuntu = True
339+ found_translations = list(
340+ self.devel_pofile.getPOTMsgSetWithNewSuggestions())
341+ self.assertEquals(found_translations, [])
342+
343+ # And adding another suggestion 2 days later, the potmsgset is
344+ # again returned.
345+ suggestion_date += timedelta(2)
346+ translation = self.factory.makeSuggestion(
347+ pofile=self.devel_pofile, potmsgset=self.potmsgset,
348+ translations=[u"New suggestion"], date_created=suggestion_date)
349+ self.assertEquals(translation.is_current_ubuntu, False)
350+
351+ found_translations = list(
352+ self.devel_pofile.getPOTMsgSetWithNewSuggestions())
353+ self.assertEquals(found_translations, [self.potmsgset])
354+
355+ def test_getPOTMsgSetWithNewSuggestions_diverged(self):
356+ # Test listing of suggestions for POTMsgSets with a shared
357+ # translation and a later diverged one.
358+
359+ # First we create a shared translation (5 days old), a diverged
360+ # translation 1 day later.
361+ # Then we make sure that getting unreviewed messages works when:
362+ # * A suggestion is added 1 day after (shows as unreviewed).
363+ # * A new diverged translation is added another day later (nothing).
364+ # * A new suggestion is added after another day (shows).
365+ # * Suggestion is made active (nothing).
366+
367+ # A POTMsgSet has a shared, current translation created 5 days ago.
368+ date_created = datetime.now(pytz.UTC) - timedelta(5)
369+ translation = self.factory.makeSuggestion(
370+ pofile=self.devel_pofile, potmsgset=self.potmsgset,
371+ translations=[u"Shared translation"], date_created=date_created)
372+ translation.is_current_ubuntu = True
373+
374+ # And we also have a diverged translation created a day after a shared
375+ # current translation.
376+ diverged_date = date_created + timedelta(1)
377+ diverged_translation = self.factory.makeSuggestion(
378+ pofile=self.devel_pofile, potmsgset=self.potmsgset,
379+ translations=[u"Old translation"], date_created=diverged_date)
380+ diverged_translation.potemplate = self.devel_potemplate
381+ diverged_translation.is_current_ubuntu = True
382+
383+ # There is also a suggestion against the shared translation
384+ # created 2 days after the shared translation.
385+ suggestion_date = date_created + timedelta(2)
386+ suggestion = self.factory.makeSuggestion(
387+ pofile=self.devel_pofile, potmsgset=self.potmsgset,
388+ translations=[u"Shared suggestion"], date_created=suggestion_date)
389+ self.assertEquals(suggestion.is_current_ubuntu, False)
390+
391+ # A suggestion is shown since diverged_date < suggestion_date.
392+ found_translations = list(
393+ self.devel_pofile.getPOTMsgSetWithNewSuggestions())
394+ self.assertEquals(found_translations, [self.potmsgset])
395+
396+ # When a diverged translation is added after the shared suggestion,
397+ # there are no unreviewed suggestions.
398+ diverged_date = suggestion_date + timedelta(1)
399+ diverged_translation_2 = self.factory.makeCurrentTranslationMessage(
400+ pofile=self.devel_pofile, potmsgset=self.potmsgset,
401+ translations=[u"Translation"], date_created=diverged_date,
402+ date_reviewed=diverged_date, diverged=True)
403+ diverged_translation.is_current_ubuntu = False
404+ diverged_translation_2.potemplate = self.devel_potemplate
405+ diverged_translation_2.is_current_ubuntu = True
406+ found_translations = list(
407+ self.devel_pofile.getPOTMsgSetWithNewSuggestions())
408+ self.assertEquals(found_translations, [])
409+
410+ # When a suggestion is added one day after, the potmsgset is returned.
411+ suggestion_date = diverged_date + timedelta(1)
412+ suggestion = self.factory.makeSuggestion(
413+ pofile=self.devel_pofile, potmsgset=self.potmsgset,
414+ translations=[u"Suggestion"], date_created=suggestion_date)
415+ self.assertEquals(suggestion.is_current_ubuntu, False)
416+
417+ found_translations = list(
418+ self.devel_pofile.getPOTMsgSetWithNewSuggestions())
419+ self.assertEquals(found_translations, [self.potmsgset])
420+
421+ # Setting a suggestion as current makes it have no unreviewed
422+ # suggestions.
423+ translation.is_current_ubuntu = False
424+ suggestion.is_current_ubuntu = True
425+ found_translations = list(
426+ self.devel_pofile.getPOTMsgSetWithNewSuggestions())
427+ self.assertEquals(found_translations, [])
428+
429+
430+>>>>>>> MERGE-SOURCE
431 class TestTranslationSharedPOFile(TestCaseWithFactory):
432 """Test behaviour of PO files with shared POTMsgSets."""
433
434@@ -134,16 +303,26 @@
435 self.assertEquals(found_potmsgsets, [plural_potmsgset])
436
437 # Search translations as well.
438+<<<<<<< TREE
439 self.factory.makeTranslationMessage(
440 pofile=self.devel_sr_pofile, potmsgset=potmsgset,
441+=======
442+ self.factory.makeCurrentTranslationMessage(
443+ pofile=self.devel_pofile, potmsgset=potmsgset,
444+>>>>>>> MERGE-SOURCE
445 translations=[u"One translation message"])
446 found_potmsgsets = list(
447 self.devel_sr_pofile.findPOTMsgSetsContaining(u"translation"))
448 self.assertEquals(found_potmsgsets, [potmsgset])
449
450 # Search matches all plural forms.
451+<<<<<<< TREE
452 self.factory.makeTranslationMessage(
453 pofile=self.devel_sr_pofile, potmsgset=plural_potmsgset,
454+=======
455+ self.factory.makeCurrentTranslationMessage(
456+ pofile=self.devel_pofile, potmsgset=plural_potmsgset,
457+>>>>>>> MERGE-SOURCE
458 translations=[u"One translation message",
459 u"Plural translation message",
460 u"Third translation message"])
461@@ -183,8 +362,13 @@
462 self.assertEquals(found_translations, [])
463
464 # If 'submitter' provides a translation, it's returned in a list.
465+<<<<<<< TREE
466 translation = self.factory.makeTranslationMessage(
467 pofile=self.devel_sr_pofile, potmsgset=potmsgset,
468+=======
469+ translation = self.factory.makeCurrentTranslationMessage(
470+ pofile=self.devel_pofile, potmsgset=potmsgset,
471+>>>>>>> MERGE-SOURCE
472 translations=[u"Translation message"],
473 translator=submitter)
474 found_translations = list(
475@@ -194,8 +378,13 @@
476 # If somebody else provides a translation, it's not added to the
477 # list of submitter's translations.
478 someone_else = self.factory.makePerson()
479+<<<<<<< TREE
480 self.factory.makeTranslationMessage(
481 pofile=self.devel_sr_pofile, potmsgset=potmsgset,
482+=======
483+ self.factory.makeCurrentTranslationMessage(
484+ pofile=self.devel_pofile, potmsgset=potmsgset,
485+>>>>>>> MERGE-SOURCE
486 translations=[u"Another translation"],
487 translator=someone_else)
488 found_translations = list(
489@@ -210,7 +399,7 @@
490
491 self.devel_sr_latin_pofile = self.factory.makePOFile(
492 'sr@latin', potemplate=self.devel_potemplate)
493- self.factory.makeTranslationMessage(
494+ self.factory.makeCurrentTranslationMessage(
495 pofile=self.devel_sr_latin_pofile, potmsgset=potmsgset,
496 translations=[u"Yet another translation"],
497 translator=submitter)
498@@ -238,17 +427,29 @@
499 self.assertEquals(found_translations, [])
500
501 # When a diverged translation is added, the potmsgset is returned.
502+<<<<<<< TREE
503 self.factory.makeTranslationMessage(
504 pofile=self.devel_sr_pofile, potmsgset=self.potmsgset,
505 translations=[u"Translation"])
506+=======
507+ self.factory.makeCurrentTranslationMessage(
508+ pofile=self.devel_pofile, potmsgset=self.potmsgset,
509+ translations=[u"Translation"], diverged=True)
510+>>>>>>> MERGE-SOURCE
511 found_translations = list(
512 self.devel_sr_pofile.getPOTMsgSetTranslated())
513 self.assertEquals(found_translations, [self.potmsgset])
514
515 # If diverged translation is empty, POTMsgSet is not listed.
516+<<<<<<< TREE
517 self.factory.makeTranslationMessage(
518 pofile=self.devel_sr_pofile, potmsgset=self.potmsgset,
519 translations=[u""])
520+=======
521+ self.factory.makeCurrentTranslationMessage(
522+ pofile=self.devel_pofile, potmsgset=self.potmsgset,
523+ translations=[u""], diverged=True)
524+>>>>>>> MERGE-SOURCE
525 found_translations = list(
526 self.devel_sr_pofile.getPOTMsgSetTranslated())
527 self.assertEquals(found_translations, [])
528@@ -258,8 +459,13 @@
529 # translation for the POTMsgSet as well.
530
531 # We create a shared translation first.
532+<<<<<<< TREE
533 self.factory.makeSharedTranslationMessage(
534 pofile=self.devel_sr_pofile, potmsgset=self.potmsgset,
535+=======
536+ self.factory.makeCurrentTranslationMessage(
537+ pofile=self.devel_pofile, potmsgset=self.potmsgset,
538+>>>>>>> MERGE-SOURCE
539 translations=[u"Shared translation"])
540
541 # When there is no diverged translation, shared one is returned.
542@@ -268,17 +474,29 @@
543 self.assertEquals(found_translations, [self.potmsgset])
544
545 # When an empty diverged translation is added, nothing is listed.
546+<<<<<<< TREE
547 self.factory.makeTranslationMessage(
548 pofile=self.devel_sr_pofile, potmsgset=self.potmsgset,
549 translations=[u""])
550+=======
551+ self.factory.makeCurrentTranslationMessage(
552+ pofile=self.devel_pofile, potmsgset=self.potmsgset,
553+ translations=[u""], diverged=True)
554+>>>>>>> MERGE-SOURCE
555 found_translations = list(
556 self.devel_sr_pofile.getPOTMsgSetTranslated())
557 self.assertEquals(found_translations, [])
558
559 # If diverged translation is non-empty, POTMsgSet is listed.
560+<<<<<<< TREE
561 self.factory.makeTranslationMessage(
562 pofile=self.devel_sr_pofile, potmsgset=self.potmsgset,
563 translations=[u"Translation"])
564+=======
565+ self.factory.makeCurrentTranslationMessage(
566+ pofile=self.devel_pofile, potmsgset=self.potmsgset,
567+ translations=[u"Translation"], diverged=True)
568+>>>>>>> MERGE-SOURCE
569 found_translations = list(
570 self.devel_sr_pofile.getPOTMsgSetTranslated())
571 self.assertEquals(found_translations, [self.potmsgset])
572@@ -288,8 +506,13 @@
573 # empty shared translation for the POTMsgSet as well.
574
575 # We create an empty shared translation first.
576+<<<<<<< TREE
577 self.factory.makeSharedTranslationMessage(
578 pofile=self.devel_sr_pofile, potmsgset=self.potmsgset,
579+=======
580+ self.factory.makeCurrentTranslationMessage(
581+ pofile=self.devel_pofile, potmsgset=self.potmsgset,
582+>>>>>>> MERGE-SOURCE
583 translations=[u""])
584
585 # When there is no diverged translation, shared one is returned,
586@@ -299,17 +522,29 @@
587 self.assertEquals(found_translations, [])
588
589 # When an empty diverged translation is added, nothing is listed.
590+<<<<<<< TREE
591 self.factory.makeTranslationMessage(
592 pofile=self.devel_sr_pofile, potmsgset=self.potmsgset,
593 translations=[u""])
594+=======
595+ self.factory.makeCurrentTranslationMessage(
596+ pofile=self.devel_pofile, potmsgset=self.potmsgset,
597+ translations=[u""], diverged=True)
598+>>>>>>> MERGE-SOURCE
599 found_translations = list(
600 self.devel_sr_pofile.getPOTMsgSetTranslated())
601 self.assertEquals(found_translations, [])
602
603 # If diverged translation is non-empty, POTMsgSet is listed.
604+<<<<<<< TREE
605 self.factory.makeTranslationMessage(
606 pofile=self.devel_sr_pofile, potmsgset=self.potmsgset,
607 translations=[u"Translation"])
608+=======
609+ self.factory.makeCurrentTranslationMessage(
610+ pofile=self.devel_pofile, potmsgset=self.potmsgset,
611+ translations=[u"Translation"], diverged=True)
612+>>>>>>> MERGE-SOURCE
613 found_translations = list(
614 self.devel_sr_pofile.getPOTMsgSetTranslated())
615 self.assertEquals(found_translations, [self.potmsgset])
616@@ -319,17 +554,28 @@
617 # translated message.
618
619 # Add a diverged translation on the included POTMsgSet...
620+<<<<<<< TREE
621 self.factory.makeTranslationMessage(
622 pofile=self.devel_sr_pofile, potmsgset=self.potmsgset,
623 translations=[u"Diverged translation"])
624+=======
625+ self.factory.makeCurrentTranslationMessage(
626+ pofile=self.devel_pofile, potmsgset=self.potmsgset,
627+ translations=[u"Diverged translation"], diverged=True)
628+>>>>>>> MERGE-SOURCE
629
630 # and a shared translation on newly added POTMsgSet...
631 potmsgset = self.factory.makePOTMsgSet(self.devel_potemplate,
632 u"Translated text")
633 potmsgset.setSequence(self.devel_potemplate, 2)
634
635+<<<<<<< TREE
636 self.factory.makeSharedTranslationMessage(
637 pofile=self.devel_sr_pofile, potmsgset=potmsgset,
638+=======
639+ self.factory.makeCurrentTranslationMessage(
640+ pofile=self.devel_pofile, potmsgset=potmsgset,
641+>>>>>>> MERGE-SOURCE
642 translations=[u"Shared translation"])
643
644 # Both POTMsgSets are listed.
645@@ -347,17 +593,29 @@
646 self.assertEquals(found_translations, [self.potmsgset])
647
648 # When a diverged translation is added, the potmsgset is returned.
649+<<<<<<< TREE
650 self.factory.makeTranslationMessage(
651 pofile=self.devel_sr_pofile, potmsgset=self.potmsgset,
652 translations=[u"Translation"])
653+=======
654+ self.factory.makeCurrentTranslationMessage(
655+ pofile=self.devel_pofile, potmsgset=self.potmsgset,
656+ translations=[u"Translation"], diverged=True)
657+>>>>>>> MERGE-SOURCE
658 found_translations = list(
659 self.devel_sr_pofile.getPOTMsgSetUntranslated())
660 self.assertEquals(found_translations, [])
661
662 # If diverged translation is empty, POTMsgSet is not listed.
663+<<<<<<< TREE
664 self.factory.makeTranslationMessage(
665 pofile=self.devel_sr_pofile, potmsgset=self.potmsgset,
666 translations=[u""])
667+=======
668+ self.factory.makeCurrentTranslationMessage(
669+ pofile=self.devel_pofile, potmsgset=self.potmsgset,
670+ translations=[u""], diverged=True)
671+>>>>>>> MERGE-SOURCE
672 found_translations = list(
673 self.devel_sr_pofile.getPOTMsgSetUntranslated())
674 self.assertEquals(found_translations, [self.potmsgset])
675@@ -367,8 +625,13 @@
676 # translation for the POTMsgSet as well.
677
678 # We create a shared translation first.
679+<<<<<<< TREE
680 self.factory.makeSharedTranslationMessage(
681 pofile=self.devel_sr_pofile, potmsgset=self.potmsgset,
682+=======
683+ self.factory.makeCurrentTranslationMessage(
684+ pofile=self.devel_pofile, potmsgset=self.potmsgset,
685+>>>>>>> MERGE-SOURCE
686 translations=[u"Shared translation"])
687
688 # When there is no diverged translation, shared one is returned.
689@@ -377,17 +640,29 @@
690 self.assertEquals(found_translations, [])
691
692 # When an empty diverged translation is added, nothing is listed.
693+<<<<<<< TREE
694 self.factory.makeTranslationMessage(
695 pofile=self.devel_sr_pofile, potmsgset=self.potmsgset,
696 translations=[u""])
697+=======
698+ self.factory.makeCurrentTranslationMessage(
699+ pofile=self.devel_pofile, potmsgset=self.potmsgset,
700+ translations=[u""], diverged=True)
701+>>>>>>> MERGE-SOURCE
702 found_translations = list(
703 self.devel_sr_pofile.getPOTMsgSetUntranslated())
704 self.assertEquals(found_translations, [self.potmsgset])
705
706 # If diverged translation is non-empty, POTMsgSet is listed.
707+<<<<<<< TREE
708 self.factory.makeTranslationMessage(
709 pofile=self.devel_sr_pofile, potmsgset=self.potmsgset,
710 translations=[u"Translation"])
711+=======
712+ self.factory.makeCurrentTranslationMessage(
713+ pofile=self.devel_pofile, potmsgset=self.potmsgset,
714+ translations=[u"Translation"], diverged=True)
715+>>>>>>> MERGE-SOURCE
716 found_translations = list(
717 self.devel_sr_pofile.getPOTMsgSetUntranslated())
718 self.assertEquals(found_translations, [])
719@@ -397,8 +672,13 @@
720 # empty shared translation for the POTMsgSet as well.
721
722 # We create an empty shared translation first.
723+<<<<<<< TREE
724 self.factory.makeSharedTranslationMessage(
725 pofile=self.devel_sr_pofile, potmsgset=self.potmsgset,
726+=======
727+ self.factory.makeCurrentTranslationMessage(
728+ pofile=self.devel_pofile, potmsgset=self.potmsgset,
729+>>>>>>> MERGE-SOURCE
730 translations=[u""])
731
732 # When there is no diverged translation, shared one is returned,
733@@ -408,17 +688,29 @@
734 self.assertEquals(found_translations, [self.potmsgset])
735
736 # When an empty diverged translation is added, nothing is listed.
737+<<<<<<< TREE
738 self.factory.makeTranslationMessage(
739 pofile=self.devel_sr_pofile, potmsgset=self.potmsgset,
740 translations=[u""])
741+=======
742+ self.factory.makeCurrentTranslationMessage(
743+ pofile=self.devel_pofile, potmsgset=self.potmsgset,
744+ translations=[u""], diverged=True)
745+>>>>>>> MERGE-SOURCE
746 found_translations = list(
747 self.devel_sr_pofile.getPOTMsgSetUntranslated())
748 self.assertEquals(found_translations, [self.potmsgset])
749
750 # If diverged translation is non-empty, POTMsgSet is listed.
751+<<<<<<< TREE
752 self.factory.makeTranslationMessage(
753 pofile=self.devel_sr_pofile, potmsgset=self.potmsgset,
754 translations=[u"Translation"])
755+=======
756+ self.factory.makeCurrentTranslationMessage(
757+ pofile=self.devel_pofile, potmsgset=self.potmsgset,
758+ translations=[u"Translation"], diverged=True)
759+>>>>>>> MERGE-SOURCE
760 found_translations = list(
761 self.devel_sr_pofile.getPOTMsgSetUntranslated())
762 self.assertEquals(found_translations, [])
763@@ -428,8 +720,13 @@
764 # untranslated message.
765
766 # Add an empty translation to the included POTMsgSet...
767+<<<<<<< TREE
768 self.factory.makeTranslationMessage(
769 pofile=self.devel_sr_pofile, potmsgset=self.potmsgset,
770+=======
771+ self.factory.makeCurrentTranslationMessage(
772+ pofile=self.devel_pofile, potmsgset=self.potmsgset,
773+>>>>>>> MERGE-SOURCE
774 translations=[u""])
775
776 # ...and a new untranslated POTMsgSet.
777@@ -589,9 +886,16 @@
778 u"Translated text")
779 potmsgset.setSequence(self.devel_potemplate, 2)
780 date_created = datetime.now(pytz.UTC) - timedelta(5)
781+<<<<<<< TREE
782 self.factory.makeTranslationMessage(
783 pofile=self.devel_sr_pofile, potmsgset=self.potmsgset,
784 translations=[u"Translation"], date_updated=date_created)
785+=======
786+ self.factory.makeCurrentTranslationMessage(
787+ pofile=self.devel_pofile, potmsgset=self.potmsgset,
788+ translations=[u"Translation"],
789+ date_created=date_created, date_reviewed=date_created)
790+>>>>>>> MERGE-SOURCE
791 suggestion_date = date_created + timedelta(1)
792 self.factory.makeTranslationMessage(
793 pofile=self.devel_sr_pofile, potmsgset=potmsgset,
794@@ -638,6 +942,7 @@
795 self.devel_sr_pofile.getPOTMsgSetWithNewSuggestions())
796 self.assertEquals([], found_translations)
797
798+<<<<<<< TREE
799 def test_getPOTMsgSetChangedInLaunchpad(self):
800 # Test listing of POTMsgSets which contain changes from imports.
801
802@@ -779,6 +1084,73 @@
803 found_translations = list(
804 self.devel_sr_pofile.getPOTMsgSetWithErrors())
805 self.assertEquals(found_translations, [self.potmsgset])
806+=======
807+ def _getThisSideFlag(self, translation_message):
808+ """Return the value of the "is_current_*" flag on this side."""
809+ traits = getUtility(ITranslationSideTraitsSet).getForTemplate(
810+ self.devel_potemplate)
811+ return traits.getFlag(translation_message)
812+
813+ def _getOtherSideFlag(self, translation_message):
814+ """Return the value of the "is_current_*" flag on the other side."""
815+ traits = getUtility(ITranslationSideTraitsSet).getForTemplate(
816+ self.devel_potemplate).other_side_traits
817+ return traits.getFlag(translation_message)
818+
819+ def test_getPOTMsgSetDifferentTranslations(self):
820+ # Test listing of POTMsgSets which have different translations on
821+ # both sides.
822+ # This test case is set up with templates and pofiles linked to
823+ # product series, therefore they are "upstream" files. As a
824+ # consequence "this side" in this test refers to "upstream" and
825+ # "other side" refers to "ubuntu" translations. We keep the generic
826+ # terms, though, because the behavior is symmetrical.
827+
828+ # If there are no translations on either side, nothing is listed.
829+ found_translations = list(
830+ self.devel_pofile.getPOTMsgSetDifferentTranslations())
831+ self.assertEquals(found_translations, [])
832+
833+ # Adding a current translation on one side doesn't change anything.
834+ translation = self.factory.makeCurrentTranslationMessage(
835+ pofile=self.devel_pofile, potmsgset=self.potmsgset,
836+ translations=[u"This side translation"])
837+ self.assertEquals(self._getThisSideFlag(translation), True)
838+ self.assertEquals(self._getOtherSideFlag(translation), False)
839+ found_translations = list(
840+ self.devel_pofile.getPOTMsgSetDifferentTranslations())
841+ self.assertEquals(found_translations, [])
842+
843+ # Adding a translation on both sides does not introduce a difference.
844+ translation = self.factory.makeCurrentTranslationMessage(
845+ pofile=self.devel_pofile, potmsgset=self.potmsgset,
846+ translations=[u"Both sides translation"], current_other=True)
847+ self.assertEquals(self._getThisSideFlag(translation), True)
848+ self.assertEquals(self._getOtherSideFlag(translation), True)
849+ found_translations = list(
850+ self.devel_pofile.getPOTMsgSetDifferentTranslations())
851+ self.assertEquals(found_translations, [])
852+
853+ # Adding a different translation on one side to creates a difference
854+ # between this side and the other side.
855+ translation = self.factory.makeCurrentTranslationMessage(
856+ pofile=self.devel_pofile, potmsgset=self.potmsgset,
857+ translations=[u"Different translation"])
858+ self.assertEquals(self._getThisSideFlag(translation), True)
859+ self.assertEquals(self._getOtherSideFlag(translation), False)
860+ found_translations = list(
861+ self.devel_pofile.getPOTMsgSetDifferentTranslations())
862+ self.assertEquals(found_translations, [self.potmsgset])
863+
864+ # A diverged translation is different, too.
865+ translation = self.factory.makeCurrentTranslationMessage(
866+ pofile=self.devel_pofile, potmsgset=self.potmsgset,
867+ translations=[u"Diverged translation"], diverged=True)
868+ self.assertEquals(self._getThisSideFlag(translation), True)
869+ self.assertEquals(self._getOtherSideFlag(translation), False)
870+ found_translations = list(
871+ self.devel_pofile.getPOTMsgSetDifferentTranslations())
872+ self.assertEquals(found_translations, [self.potmsgset])
873
874 def test_messageCount(self):
875 # POFile.messageCount just forwards to POTmeplate.messageCount.
876@@ -789,6 +1161,7 @@
877 def test_initial_statistics_consistency(self):
878 # A `POFile` starts out with consistent statistics.
879 self.assertTrue(self.factory.makePOFile().testStatistics())
880+>>>>>>> MERGE-SOURCE
881
882 def test_updateStatistics(self):
883 # Test that updating statistics keeps working.
884@@ -1107,12 +1480,22 @@
885 def test_getPOTMsgSetTranslated_ordering(self):
886 # Translate both POTMsgSets in devel_sr_pofile, so
887 # they are returned with getPOTMsgSetTranslated() call.
888+<<<<<<< TREE
889 self.factory.makeSharedTranslationMessage(
890 pofile=self.devel_sr_pofile,
891+=======
892+ self.factory.makeCurrentTranslationMessage(
893+ pofile=self.devel_pofile,
894+>>>>>>> MERGE-SOURCE
895 potmsgset=self.potmsgset1,
896 translations=["Shared translation"])
897+<<<<<<< TREE
898 self.factory.makeSharedTranslationMessage(
899 pofile=self.devel_sr_pofile,
900+=======
901+ self.factory.makeCurrentTranslationMessage(
902+ pofile=self.devel_pofile,
903+>>>>>>> MERGE-SOURCE
904 potmsgset=self.potmsgset2,
905 translations=["Another shared translation"])
906
907@@ -1162,6 +1545,7 @@
908 self.assertEquals(untranslated_potmsgsets,
909 [self.potmsgset1, self.potmsgset2])
910
911+<<<<<<< TREE
912 def test_getPOTMsgSetChangedInLaunchpad_ordering(self):
913 # Suggest a translation on both POTMsgSets in devel_sr_pofile,
914 # so they are returned with getPOTMsgSetWithNewSuggestions() call.
915@@ -1247,6 +1631,51 @@
916 self.devel_sr_pofile.getPOTMsgSetWithErrors())
917 self.assertEquals(potmsgsets,
918 [self.potmsgset1, self.potmsgset2])
919+=======
920+ def test_getPOTMsgSetDifferentTranslations_ordering(self):
921+ # Suggest a translation on both POTMsgSets in devel_pofile,
922+ # so they are returned with getPOTMsgSetDifferentTranslations() call.
923+ self.factory.makeCurrentTranslationMessage(
924+ pofile=self.devel_pofile,
925+ potmsgset=self.potmsgset1,
926+ translations=["Both sides"],
927+ current_other=True)
928+ self.factory.makeCurrentTranslationMessage(
929+ pofile=self.devel_pofile,
930+ potmsgset=self.potmsgset1,
931+ translations=["This side"])
932+ self.factory.makeCurrentTranslationMessage(
933+ pofile=self.devel_pofile,
934+ potmsgset=self.potmsgset2,
935+ translations=["Both sides 2"],
936+ current_other=True)
937+ self.factory.makeCurrentTranslationMessage(
938+ pofile=self.devel_pofile,
939+ potmsgset=self.potmsgset2,
940+ translations=["This side 2"])
941+
942+ potmsgsets = list(
943+ self.devel_pofile.getPOTMsgSetDifferentTranslations())
944+ self.assertEquals(
945+ [self.potmsgset1, self.potmsgset2], potmsgsets)
946+
947+ # Insert these two POTMsgSets into self.stable_potemplate in reverse
948+ # order.
949+ self.potmsgset2.setSequence(self.stable_potemplate, 1)
950+ self.potmsgset1.setSequence(self.stable_potemplate, 2)
951+
952+ # And they are returned in the new order as desired.
953+ potmsgsets = list(
954+ self.stable_pofile.getPOTMsgSetDifferentTranslations())
955+ self.assertEquals(
956+ [self.potmsgset2, self.potmsgset1], potmsgsets)
957+
958+ # Order is unchanged for the previous template.
959+ potmsgsets = list(
960+ self.devel_pofile.getPOTMsgSetDifferentTranslations())
961+ self.assertEquals(
962+ [self.potmsgset1, self.potmsgset2], potmsgsets)
963+>>>>>>> MERGE-SOURCE
964
965 def test_getPOTMsgSets_ordering(self):
966 # Both POTMsgSets in devel_potemplate are untranslated.
967@@ -1278,12 +1707,22 @@
968 # This test will go away when potmsgset.sequence goes away.
969
970 # Give the method something to search for.
971+<<<<<<< TREE
972 self.factory.makeSharedTranslationMessage(
973 pofile=self.devel_sr_pofile,
974+=======
975+ self.factory.makeCurrentTranslationMessage(
976+ pofile=self.devel_pofile,
977+>>>>>>> MERGE-SOURCE
978 potmsgset=self.potmsgset1,
979 translations=["Shared translation"])
980+<<<<<<< TREE
981 self.factory.makeSharedTranslationMessage(
982 pofile=self.devel_sr_pofile,
983+=======
984+ self.factory.makeCurrentTranslationMessage(
985+ pofile=self.devel_pofile,
986+>>>>>>> MERGE-SOURCE
987 potmsgset=self.potmsgset2,
988 translations=["Another shared translation"])
989
990@@ -1854,23 +2293,23 @@
991
992 def test_getTranslationMessages_current_shared(self):
993 # A shared message is included in this POFile's messages.
994- message = self.factory.makeTranslationMessage(
995- potmsgset=self.potmsgset, pofile=self.pofile, force_shared=True)
996+ message = self.factory.makeCurrentTranslationMessage(
997+ potmsgset=self.potmsgset, pofile=self.pofile)
998
999 self.assertEqual(
1000 [message], list(self.pofile.getTranslationMessages()))
1001
1002 def test_getTranslationMessages_current_diverged(self):
1003 # A diverged message is included in this POFile's messages.
1004- message = self.factory.makeTranslationMessage(
1005- potmsgset=self.potmsgset, pofile=self.pofile, force_diverged=True)
1006+ message = self.factory.makeCurrentTranslationMessage(
1007+ potmsgset=self.potmsgset, pofile=self.pofile, diverged=True)
1008
1009 self.assertEqual(
1010 [message], list(self.pofile.getTranslationMessages()))
1011
1012 def test_getTranslationMessages_suggestion(self):
1013 # A suggestion is included in this POFile's messages.
1014- message = self.factory.makeTranslationMessage(
1015+ message = self.factory.makeSuggestion(
1016 potmsgset=self.potmsgset, pofile=self.pofile)
1017
1018 self.assertEqual(
1019@@ -1880,8 +2319,8 @@
1020 # A message on an obsolete POTMsgSEt is included in this
1021 # POFile's messages.
1022 potmsgset = self.factory.makePOTMsgSet(self.potemplate, sequence=0)
1023- message = self.factory.makeTranslationMessage(
1024- potmsgset=potmsgset, pofile=self.pofile, force_shared=True)
1025+ message = self.factory.makeCurrentTranslationMessage(
1026+ potmsgset=potmsgset, pofile=self.pofile)
1027
1028 self.assertEqual(
1029 [message], list(self.pofile.getTranslationMessages()))
1030@@ -1889,7 +2328,7 @@
1031 def test_getTranslationMessages_other_pofile(self):
1032 # A message from another POFiles is not included.
1033 other_pofile = self.factory.makePOFile('de')
1034- self.factory.makeTranslationMessage(
1035+ self.factory.makeCurrentTranslationMessage(
1036 potmsgset=self.potmsgset, pofile=other_pofile)
1037
1038 self.assertEqual([], list(self.pofile.getTranslationMessages()))
1039@@ -1897,8 +2336,8 @@
1040 def test_getTranslationMessages_condition_matches(self):
1041 # A message matching the given condition is included.
1042 # Diverged messages are linked to a specific POTemplate.
1043- message = self.factory.makeTranslationMessage(
1044- potmsgset=self.potmsgset, pofile=self.pofile, force_diverged=True)
1045+ message = self.factory.makeCurrentTranslationMessage(
1046+ potmsgset=self.potmsgset, pofile=self.pofile, diverged=True)
1047
1048 self.assertContentEqual(
1049 [message],
1050@@ -1908,8 +2347,8 @@
1051 def test_getTranslationMessages_condition_matches_not(self):
1052 # A message not matching the given condition is excluded.
1053 # Shared messages are not linked to a POTemplate.
1054- self.factory.makeTranslationMessage(
1055- potmsgset=self.potmsgset, pofile=self.pofile, force_shared=True)
1056+ self.factory.makeCurrentTranslationMessage(
1057+ potmsgset=self.potmsgset, pofile=self.pofile)
1058
1059 self.assertContentEqual(
1060 [],
1061@@ -1920,9 +2359,9 @@
1062 # A message matching given condition but located in another POFile
1063 # is not included.
1064 other_pofile = self.factory.makePOFile('de')
1065- self.factory.makeTranslationMessage(
1066+ self.factory.makeCurrentTranslationMessage(
1067 potmsgset=self.potmsgset, pofile=other_pofile,
1068- force_diverged=True)
1069+ diverged=True)
1070
1071 self.assertContentEqual(
1072 [],
1073@@ -1940,9 +2379,9 @@
1074 other_pofile = other_template.getPOFileByLang(
1075 self.pofile.language.code)
1076 self.potmsgset.setSequence(other_template, 1)
1077- self.factory.makeTranslationMessage(
1078+ self.factory.makeCurrentTranslationMessage(
1079 potmsgset=self.potmsgset, pofile=other_pofile,
1080- force_diverged=True)
1081+ diverged=True)
1082
1083 self.assertEqual([], list(self.pofile.getTranslationMessages()))
1084
1085@@ -2687,3 +3126,48 @@
1086 potemplate=self.factory.makePOTemplate(
1087 distroseries=package.distroseries,
1088 sourcepackagename=package.sourcepackagename))
1089+
1090+
1091+class StatistcsFiltersTestScenario(StatisticsTestScenario):
1092+ """Test the filter functions in `POFile`s compared to statistics."""
1093+
1094+ def exerciseFunction(self, pofile):
1095+ """Run the function under test."""
1096+ pofile.updateStatistics()
1097+
1098+ def getCurrentCount(self, pofile):
1099+ return pofile.currentCount()
1100+
1101+ def getRosettaCount(self, pofile):
1102+ return pofile.rosettaCount()
1103+
1104+ def getTranslatedCount(self, pofile):
1105+ return pofile.getPOTMsgSetTranslated().count()
1106+
1107+ def getUnreviewedCount(self, pofile):
1108+ return pofile.getPOTMsgSetWithNewSuggestions().count()
1109+
1110+ def getUntranslatedCount(self, pofile):
1111+ return pofile.getPOTMsgSetUntranslated().count()
1112+
1113+ def getUpdatesCount(self, pofile):
1114+ return pofile.getPOTMsgSetDifferentTranslations().count()
1115+
1116+
1117+class TestUpstreamFilters(StatistcsFiltersTestScenario, TestCaseWithFactory):
1118+ """Test filters on upstream `POFile`s."""
1119+
1120+ def makePOFile(self):
1121+ return self.factory.makePOFile()
1122+
1123+
1124+class TestUbuntuFilters(StatistcsFiltersTestScenario, TestCaseWithFactory):
1125+ """Test filters on Ubuntu `POFile`s."""
1126+
1127+ def makePOFile(self):
1128+ package = self.factory.makeSourcePackage()
1129+ return self.factory.makePOFile(
1130+ potemplate=self.factory.makePOTemplate(
1131+ distroseries=package.distroseries,
1132+ sourcepackagename=package.sourcepackagename))
1133+

Subscribers

People subscribed via source and target branches

to status/vote changes: