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
1=== modified file 'lib/lp/translations/tests/test_potmsgset.py'
2--- lib/lp/translations/tests/test_potmsgset.py 2009-10-30 10:29:25 +0000
3+++ lib/lp/translations/tests/test_potmsgset.py 2009-10-31 08:56:18 +0000
4@@ -15,15 +15,17 @@
5 from zope.security.proxy import isinstance as zope_isinstance
6 from zope.security.proxy import removeSecurityProxy
7
8-from lp.translations.model.translationmessage import (
9- DummyTranslationMessage)
10 from lp.registry.interfaces.person import IPersonSet
11+from lp.registry.interfaces.product import IProductSet
12 from lp.services.worlddata.interfaces.language import ILanguageSet
13 from lp.translations.interfaces.potmsgset import (
14 POTMsgSetInIncompatibleTemplatesError, TranslationCreditsType)
15 from lp.translations.interfaces.translationfileformat import (
16 TranslationFileFormat)
17 from lp.translations.interfaces.translationmessage import TranslationConflict
18+from lp.translations.model.translationmessage import (
19+ DummyTranslationMessage)
20+
21 from lp.testing import TestCaseWithFactory
22 from canonical.testing import ZopelessDatabaseLayer
23
24@@ -648,21 +650,27 @@
25 def test_setTranslationCreditsToTranslated_diverged(self):
26 # Even if there's a diverged translation credits translation,
27 # we should provide an automatic shared translation instead.
28- sr_pofile = self.factory.makePOFile('sr', self.devel_potemplate)
29- credits_potmsgset = self.factory.makePOTMsgSet(
30- self.devel_potemplate, singular=u'translator-credits')
31- diverged_translation = credits_potmsgset.updateTranslation(
32- pofile=sr_pofile, submitter=sr_pofile.owner,
33- new_translations=[u'Diverged credits'], is_imported=True,
34- force_diverged=True, lock_timestamp=datetime.now(pytz.UTC),
35- allow_credits=True)
36- self.assertTrue(diverged_translation.is_current)
37- self.assertNotEqual(None, diverged_translation.potemplate)
38+ alsa_utils = getUtility(IProductSet).getByName('alsa-utils')
39+ trunk = alsa_utils.getSeries('trunk')
40+ potemplate = trunk.getPOTemplate('alsa-utils')
41+ es_pofile = potemplate.getPOFileByLang('es')
42+ credits_potmsgset = potemplate.getPOTMsgSetByMsgIDText(
43+ u'_: EMAIL OF TRANSLATORS\nYour emails')
44+
45+ es_current = credits_potmsgset.getCurrentTranslationMessage(
46+ potemplate, es_pofile.language)
47+ # Let's make sure this message is also marked as imported
48+ # and diverged.
49+ es_current.is_imported = True
50+ es_current.potemplate = potemplate
51+
52+ self.assertTrue(es_current.is_current)
53+ self.assertNotEqual(None, es_current.potemplate)
54
55 # Setting credits as translated will give us a shared translation.
56- credits_potmsgset.setTranslationCreditsToTranslated(sr_pofile)
57+ credits_potmsgset.setTranslationCreditsToTranslated(es_pofile)
58 current_shared = credits_potmsgset.getSharedTranslationMessage(
59- sr_pofile.language)
60+ es_pofile.language)
61 self.assertNotEqual(None, current_shared)
62 self.assertEqual(None, current_shared.potemplate)
63