Merge lp:~danilo/launchpad/bug-459132 into lp:launchpad

Proposed by Данило Шеган
Status: Merged
Merge reported by: Данило Шеган
Merged at revision: not available
Proposed branch: lp:~danilo/launchpad/bug-459132
Merge into: lp:launchpad
Diff against target: 62 lines
1 file modified
lib/lp/translations/tests/test_potmsgset.py (+22/-14)
To merge this branch: bzr merge lp:~danilo/launchpad/bug-459132
Reviewer Review Type Date Requested Status
Henning Eggers (community) code Approve
Review via email: mp+14210@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Данило Шеган (danilo) wrote :

= Bug #459132 =

This provides scripts/rosetta/fix_translation_credits.py which marks all
existing untranslated credits messages as translated by calling
setTranslationCreditsToTranslated() on each POTMsgSet.

== Implementation details ==

It collects a full list of POFiles and relevant POTMsgSets through
POFileSet.getPOFilesWithTranslationCredits, and doesn't exclude those
which are already translated, though, because of the way
setTranslationCreditsToTranslated is implemented (first check for a
shared message), it works much faster over already translated ones
(tested and confirmed in practice :).

There is a minor change to setTranslationCreditsToTranslated to include
force_shared (so we don't mess up imported diverged and current
translations by accident), along with a new test in test_potmsgset.

The collection method in POFileSet is tested in test_pofile.

Also, full test suite run has completed and there are no test failures.

Script itself is not tested in an automated way, because it mostly
integrates all of the above. Perhaps a small "it runs" test should be
added to make sure privileges are fine.

= Demo & QA =

Run it. Run it on staging.

  scripts/rosetta/fix_translation_credits.py -vvv

= Tests =

  bin/test -vvt test_potmsgset -t test_pofile -t doc.potmsgset.txt

= Lint =

Lint is fine.

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

Thank you for getting this done. The branch looks good to me, apart from the few things which we discussed on IRC:

- Use the Storm In operator in potemplate.py
- Fix the docstring for CreditsFixer
- Rewrite the test for getPOFilesWithTranslationCredits to use sample data that does not have dummy translation credits messages set as makePOTMsgSet will only create POTMsgSets wich already have them.

Thank you. ;)

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/translations/tests/test_potmsgset.py'
--- lib/lp/translations/tests/test_potmsgset.py 2009-10-30 10:29:25 +0000
+++ lib/lp/translations/tests/test_potmsgset.py 2009-10-31 08:56:18 +0000
@@ -15,15 +15,17 @@
15from zope.security.proxy import isinstance as zope_isinstance15from zope.security.proxy import isinstance as zope_isinstance
16from zope.security.proxy import removeSecurityProxy16from zope.security.proxy import removeSecurityProxy
1717
18from lp.translations.model.translationmessage import (
19 DummyTranslationMessage)
20from lp.registry.interfaces.person import IPersonSet18from lp.registry.interfaces.person import IPersonSet
19from lp.registry.interfaces.product import IProductSet
21from lp.services.worlddata.interfaces.language import ILanguageSet20from lp.services.worlddata.interfaces.language import ILanguageSet
22from lp.translations.interfaces.potmsgset import (21from lp.translations.interfaces.potmsgset import (
23 POTMsgSetInIncompatibleTemplatesError, TranslationCreditsType)22 POTMsgSetInIncompatibleTemplatesError, TranslationCreditsType)
24from lp.translations.interfaces.translationfileformat import (23from lp.translations.interfaces.translationfileformat import (
25 TranslationFileFormat)24 TranslationFileFormat)
26from lp.translations.interfaces.translationmessage import TranslationConflict25from lp.translations.interfaces.translationmessage import TranslationConflict
26from lp.translations.model.translationmessage import (
27 DummyTranslationMessage)
28
27from lp.testing import TestCaseWithFactory29from lp.testing import TestCaseWithFactory
28from canonical.testing import ZopelessDatabaseLayer30from canonical.testing import ZopelessDatabaseLayer
2931
@@ -648,21 +650,27 @@
648 def test_setTranslationCreditsToTranslated_diverged(self):650 def test_setTranslationCreditsToTranslated_diverged(self):
649 # Even if there's a diverged translation credits translation,651 # Even if there's a diverged translation credits translation,
650 # we should provide an automatic shared translation instead.652 # we should provide an automatic shared translation instead.
651 sr_pofile = self.factory.makePOFile('sr', self.devel_potemplate)653 alsa_utils = getUtility(IProductSet).getByName('alsa-utils')
652 credits_potmsgset = self.factory.makePOTMsgSet(654 trunk = alsa_utils.getSeries('trunk')
653 self.devel_potemplate, singular=u'translator-credits')655 potemplate = trunk.getPOTemplate('alsa-utils')
654 diverged_translation = credits_potmsgset.updateTranslation(656 es_pofile = potemplate.getPOFileByLang('es')
655 pofile=sr_pofile, submitter=sr_pofile.owner,657 credits_potmsgset = potemplate.getPOTMsgSetByMsgIDText(
656 new_translations=[u'Diverged credits'], is_imported=True,658 u'_: EMAIL OF TRANSLATORS\nYour emails')
657 force_diverged=True, lock_timestamp=datetime.now(pytz.UTC),659
658 allow_credits=True)660 es_current = credits_potmsgset.getCurrentTranslationMessage(
659 self.assertTrue(diverged_translation.is_current)661 potemplate, es_pofile.language)
660 self.assertNotEqual(None, diverged_translation.potemplate)662 # Let's make sure this message is also marked as imported
663 # and diverged.
664 es_current.is_imported = True
665 es_current.potemplate = potemplate
666
667 self.assertTrue(es_current.is_current)
668 self.assertNotEqual(None, es_current.potemplate)
661669
662 # Setting credits as translated will give us a shared translation.670 # Setting credits as translated will give us a shared translation.
663 credits_potmsgset.setTranslationCreditsToTranslated(sr_pofile)671 credits_potmsgset.setTranslationCreditsToTranslated(es_pofile)
664 current_shared = credits_potmsgset.getSharedTranslationMessage(672 current_shared = credits_potmsgset.getSharedTranslationMessage(
665 sr_pofile.language)673 es_pofile.language)
666 self.assertNotEqual(None, current_shared)674 self.assertNotEqual(None, current_shared)
667 self.assertEqual(None, current_shared.potemplate)675 self.assertEqual(None, current_shared.potemplate)
668676