Merge lp://staging/~jtv/launchpad/recife-add-suggestion into lp://staging/~launchpad/launchpad/recife
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Данило Шеган | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | not available | ||||
Proposed branch: | lp://staging/~jtv/launchpad/recife-add-suggestion | ||||
Merge into: | lp://staging/~launchpad/launchpad/recife | ||||
Diff against target: |
814 lines (+437/-80) 19 files modified
lib/canonical/launchpad/ftests/__init__.py (+0/-41) lib/lp/answers/doc/karma.txt (+1/-1) lib/lp/archiveuploader/tests/upload-karma.txt (+1/-3) lib/lp/bugs/doc/externalbugtracker-comment-imports.txt (+1/-1) lib/lp/bugs/doc/malone-karma.txt (+1/-1) lib/lp/code/doc/branch-karma.txt (+1/-1) lib/lp/registry/doc/person-karma.txt (+1/-1) lib/lp/registry/stories/object/xx-object-branding.txt (+2/-5) lib/lp/registry/stories/person/xx-person-edit-profile-picture.txt (+1/-1) lib/lp/registry/stories/person/xx-person-rdf.txt (+1/-1) lib/lp/registry/stories/teammembership/xx-private-membership.txt (+1/-1) lib/lp/testing/__init__.py (+12/-0) lib/lp/testing/branding.py (+48/-0) lib/lp/testing/factory.py (+17/-0) lib/lp/testing/karma.py (+88/-19) lib/lp/translations/doc/rosetta-karma.txt (+1/-1) lib/lp/translations/interfaces/potmsgset.py (+11/-1) lib/lp/translations/model/potmsgset.py (+31/-1) lib/lp/translations/tests/test_potmsgset.py (+218/-1) |
||||
To merge this branch: | bzr merge lp://staging/~jtv/launchpad/recife-add-suggestion | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Данило Шеган (community) | code | Approve | |
Review via email:
|
Commit message
POTMsgSet.
Description of the change
= Bug 546521 =
This introduces a new method POTMsgSet.
At the head of the diff you may notice an unrelated added line in the interface that was missing for some reason. Henning noticed this earlier today.
I tried giving submitSuggestion language/variant parameters instead of a pofile, but it turned out we also needed the context of the pofile's template in order to assign karma.
Speaking of karma, the test introduces a helper class called KarmaListener that we can turn into a reusable helper and incorporate into our TestCase class as needed. It records selected karma events. There's nothing translations-
No lint.
To test,
{{{
./bin/test -vv -t TestPOTMsgSet_
}}}
No lint.
Jeroen
> === modified file 'lib/lp/ translations/ model/potmsgset .py' translations/ model/potmsgset .py 2010-03-23 15:39:12 translations/ model/potmsgset .py 2010-03-25 00:11:17 message. sync() n(self, pofile, submitter, new_translations): translation_ credit: nslations( new_translation s) lationMessage( plural_ forms)
> --- lib/lp/
+0000
> +++ lib/lp/
+0000
> @@ -888,6 +888,36 @@
> matching_
> return matching_message
>
> + def submitSuggestio
> + """See `IPOTMsgSet`."""
> + if self.is_
> + # We don't support suggestions on credits messages.
> + return None
> +
> + potranslations = self._findPOTra
> +
> + existing_message = self._findTrans
> + pofile, potranslations, pofile.
> + if existing_message is not None:
> + return existing_message
In the end you still included this logic as part of submitSuggestion? I
guess we can move it out later if it turns out that's what we want.
> === modified file 'lib/lp/ translations/ tests/test_ potmsgset. py' l(credits_ type, translation_ credits_ type)
> @@ -1267,5 +1271,274 @@
> self.assertEqua
credits.
>
>
> +class KarmaListener:
Any reason not to put this inside lib/lp/ registry/ tests/karma. py?
> +class TestPOTMsgSet_ submitSuggestio n(TestCaseWithF actory) : submitSuggestio n`.""" eLayer OTMsgSet( self, msgid=None, with_plural=False):
> + """Test `POTMsgSet.
> +
> + layer = ZopelessDatabas
> +
> + def _makePOFileAndP
In general, if you find that you need such a method, we might probably
need it in other cases as well. So, why not put it into the factory?
> + """Set up a `POFile` with `POTMsgSet`.""" makePOFile( 'nl') getUniqueString () getUniqueString () makePOTMsgSet( singular_ text,
> + pofile = self.factory.
> + if msgid is None:
> + singular_text = self.factory.
> + else:
> + singular_text = msgid
> + if with_plural:
> + plural_text = self.factory.
> + else:
> + plural_text = None
> + potmsgset = self.factory.
> + pofile.potemplate, singular=
plural=plural_text)
> +
Some extra whitespace here.
> + return pofile, potmsgset n.""" submitSuggestio n( potemplate. owner, translations)
> +
> + def _suggest(self, pofile, potmsgset, translations):
> + """Convenience shorthand for submitSuggestio
> + return potmsgset.
> + pofile, pofile.
I believe this reduced the usefulness of these tests as a documentation
for submitSuggestion() method. And yet, you have added no documentation
whatsoever.
> + def test_plural_ forms(self) : eAndPOTMsgSet( with_plural= True) getUniqueString (), getUniqueString (), pofile, potmsgset, translations) iteritems( ): tants.MAX_ PLUR...
> + pofile, potmsgset =
self._makePOFil
> + translations = {
> + 0: self.factory.
> + 1: self.factory.
> + }
> +
> + suggestion = self._suggest(
> + for form, translation in translations.
> + self.assertEqual(
> + translation,
> + getattr(suggestion, 'msgstr%d' % form).translation)
> + for form in xrange(2, TranslationCons