← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~adeuring/launchpad/bug-681434 into lp:launchpad

 

Abel Deuring has proposed merging lp:~adeuring/launchpad/bug-681434 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  #681434 Update use of statistics in doctests to new model
  https://bugs.launchpad.net/bugs/681434

For more details, see:
https://code.launchpad.net/~adeuring/launchpad/bug-681434/+merge/52071

This branch fixes bug 681434, Update use of statistics
in doctests to new model. I've looked through all uses
of POFile.updateStatistics() and of methods like
POFile.currentCount() in tests, and it seems that
other tests whhich might have used these methods in a
way which is no longer appropriate way have already
been cleaned up,  with the exception of the one doc
test mentioned in the bug report (poimport.txt).

So I simply removed the odd looking check that the
statistical data does not change after a second POFile
import.

I found it a bit hard to see why the first import in the
test yielded exactly three valid translations, so the
test now explicitly lists all known translations.

test: ./bin/test translations -vvt poimport.txt

no lint

-- 
https://code.launchpad.net/~adeuring/launchpad/bug-681434/+merge/52071
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~adeuring/launchpad/bug-681434 into lp:launchpad.
=== modified file 'lib/lp/translations/doc/poimport.txt'
--- lib/lp/translations/doc/poimport.txt	2011-01-24 15:51:18 +0000
+++ lib/lp/translations/doc/poimport.txt	2011-03-03 14:05:27 +0000
@@ -304,7 +304,28 @@
     >>> print entry.status.name
     IMPORTED
 
-And the statistics reflect it.
+Three translations have been properly imported. Note that the translation
+"balloon" -> "blah" is considered as current, even though "balloon" does
+not appear in the POTemplate.
+
+    >>> def show_translation_details(translationmessage, pofile):
+    ...     print translationmessage.potmsgset.singular_text,
+    ...     print translationmessage.translations,
+    ...     print translationmessage.potmsgset.getSequence(pofile.potemplate)
+    >>> for translationmessage in pofile.translation_messages:
+    ...     if translationmessage.is_current_ubuntu:
+    ...         show_translation_details(translationmessage, pofile)
+    translator-credits
+        [u'This is a dummy translation so that the credits
+         are counted as translated.'] 6
+    foo [u'blah'] 1
+    balloon [u'blah'] 0
+    Singular %d
+        [u'Foos %d', u'Bars %d', u'Welsh power! %d', u'We have four! %d'] 5
+
+And the statistics reflect it. (Note that only translations with a
+sequence number greater than 0 are counted, hence the translation
+"balloon" -> "blah" does not appear in currentCount().)
 
     >>> pofile.currentCount()
     3
@@ -460,7 +481,8 @@
 Import Without Errors
 .....................
 
-Now, let's import one without errors.
+Now, let's import one without errors. This file changes one translation
+and adds another one.
 
     >>> pofile_without_errors = r'''
     ... msgid ""
@@ -473,7 +495,10 @@
     ... "X-Rosetta-Export-Date: %s\n"
     ...
     ... msgid "foo"
-    ... msgstr "blah"
+    ... msgstr "new translation"
+    ...
+    ... msgid "baz"
+    ... msgstr "zab"
     ...
     ... msgid "translator-credits"
     ... msgstr "helpful@xxxxxxxxxxx"
@@ -502,20 +527,6 @@
 
     >>> entry.setStatus(RosettaImportStatus.APPROVED, rosetta_experts)
 
-At this point, the statistics note that we have 3 translations coming
-from imported files (currentCount), and none updated in Launchpad
-Translations. The translation credits message is counted as translated
-in rosetta.
-
-    >>> pofile.currentCount()
-    3
-
-    >>> pofile.updatesCount()
-    0
-
-    >>> pofile.rosettaCount()
-    0
-
 We do the import.
 
     >>> (subject, body) = pofile.importFromQueue(entry, FakeLogger())
@@ -525,24 +536,21 @@
     >>> print entry.status.name
     IMPORTED
 
-# XXX JeroenVermeulen 2010-11-24, bug=681434: This no longer makes sense.
-# We'll have to re-think what this should do once the statistics have been
-# updated for the Recife model.
-
-Now, the statistics note that we have two translations coming from
-imported files (currentCount), which is the translation we just
-imported, and the other two translation that was coming from imported
-files are now counted as coming from Launchpad translations
-(rosettaCount) because latest imported file doesn't have them anymore.
-
+Since the translations from the older imports are still present,
+we now have four current translations.
+
+    >>> for translationmessage in pofile.translation_messages.order_by('id'):
+    ...     if (translationmessage.is_current_ubuntu and
+    ...         translationmessage.potmsgset.getSequence(pofile.potemplate)
+    ...         > 0):
+    ...         show_translation_details(translationmessage, pofile)
+    Singular %d
+        [u'Foos %d', u'Bars %d', u'Welsh power! %d', u'We have four! %d'] 5
+    foo [u'new translation'] 1
+    baz [u'zab'] 3
+    translator-credits [u'helpful@xxxxxxxxxxx'] 6
     >>> pofile.currentCount()
-    3
-
-    >>> pofile.updatesCount()
-    0
-
-#    >>> pofile.rosettaCount()
-#    1
+    4
 
 This time, our notification email reports complete success, except
 that nothing is emailed out (subject is None) because this is an upstream
@@ -569,7 +577,7 @@
 
     >>> message = get_pofile_translation_message(pofile, 'foo')
     >>> message.msgstr0.translation
-    u'blah'
+    u'new translation'
 
     >>> message = get_pofile_translation_message(pofile, 'translator-credits')
     >>> message.msgstr0.translation