Merge lp:~danilo/launchpad/bug-553093 into lp:launchpad
| Status: | Merged |
|---|---|
| Approved by: | Данило Шеган on 2010-04-15 |
| Approved revision: | no longer in the source branch. |
| Merged at revision: | not available |
| Proposed branch: | lp:~danilo/launchpad/bug-553093 |
| Merge into: | lp:launchpad |
| Diff against target: |
172 lines (+79/-33) 5 files modified
lib/lp/services/worlddata/doc/language.txt (+33/-1) lib/lp/services/worlddata/interfaces/language.py (+3/-2) lib/lp/services/worlddata/tests/test_doc.py (+12/-1) lib/lp/services/worlddata/tests/test_language.py (+21/-0) lib/lp/translations/templates/language-index.pt (+10/-29) |
| To merge this branch: | bzr merge lp:~danilo/launchpad/bug-553093 |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Michael Nelson (community) | code ui | 2010-04-15 | Approve on 2010-04-15 |
|
Review via email:
|
|||
Commit Message
Do not include translators list in the snapshot of the object, to avoid OOPSing when administering languages.
Description of the Change
= Bug 553093 =
This fixes an OOPS which happens because we are snapshoting a full object with the exported API, and when translators property has more than 1000 entries, a shortlist in the snapshot implementation fails.
Fix is simple: just encapsulate doNotSnapshot().
I am struggling with the test, though. I tried making a unit test, but uncommitted it: it was too slow (creating 1001 persons with some karma), and didn't really work (switching DB users to create karma and persons, and then coming back to the regular test user made it impossible to also construct views). I did do this in my local launchpad-dev DB and tested that the fix works correctly.
Along the way, I've fixed a bunch of formatting problems on the page.
See https:/
| Данило Шеган (danilo) wrote : | # |
| Данило Шеган (danilo) wrote : | # |
Oh, and btw, generic tests have passed for the language page: bin/test -vvt lp.translations
| Michael Nelson (michael.nelson) wrote : | # |
Hi Danilo,
You mentioned that the test reproducing the actual failure takes way too long, and is not worthwhile.
The only ways I can see to get around this are:
Somehow provide a different adapter via zcml (replacing canonical.
Simply test the interface, that the translators field provides IDoNotSnapshot - this is not as good, but still ensures that the fix is documented and won't regress.
Regarding the template changes, nice simplification!
| Данило Шеган (danilo) wrote : | # |
I've went with IDoNotSnapshot after all: that's what also test_bugs_
=== modified file 'lib/lp/
--- lib/lp/
+++ lib/lp/
@@ -260,8 +260,40 @@ English name for a language including op
Serbian ("Latn" variant)
+translators
+===========
+
+Property `translators` contains the list of `Person`s who are considered
+translators for this language.
+
+ >>> sr = language_
+ >>> list(sr.
+ []
+
+To be considered a translator, they must have done some translations and
+have the language among their preferred languages.
+
+ >>> translator = factory.
+ >>> translator.
+ >>> from canonical.testing import LaunchpadZopele
+ >>> LaunchpadZopele
+
+ # We need to fake some Karma.
+ >>> from lp.registry.
+ >>> LaunchpadZopele
+ >>> translations_
+ ... KarmaCategory.
+ >>> karma = KarmaCache(
+ ... category=
+ ... karmavalue=1)
+ >>> LaunchpadZopele
+ >>> LaunchpadZopele
+ >>> [translator.name for translator in sr.translators]
+ [u'serbian-
+
+
=========
-countries
+Countries
=========
Property holding a list of countries a language is spoken in, and allowing
=== modified file 'lib/lp/
--- lib/lp/
+++ lib/lp/
@@ -6,9 +6,20 @@ Run the doctests and pagetests.
"""
import os
+
+from canonical.
+ LayeredDocFileS
+from canonical.testing import LaunchpadZopele
+
from lp.services.testing import build_test_suite
here = os.path.
+special = {
+ 'language.txt': LayeredDocFileS
+ '../doc/
+ layer=Launchpad
+ setUp=setUp, tearDown=tearDown),
+ }
def test_suite():
- return build_test_
+ return build_test_
=== added file 'lib/lp/
--- lib/lp/
+++ lib/lp/
@@ -0,0 +1,21 @@
+# Copyright 2010 Canonical Ltd. This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+__metaclass__ = type
+
+from canonical.testing import FunctionalLayer
+from lazr.lifecycle.
+from lp.services.
+from lp.testing import TestCaseWithFactory
+
+
+class TestLanguageWeb
| Michael Nelson (michael.nelson) wrote : | # |
Thanks Danilo, code=me.
And running your branch compared with trunk shows that the table=>div changes don't modify the layout of the translation teams (other than adding the needed comma, and proper icon spacing for the person/team icon), so ui=me too.

=== removed file 'lib/lp/ translations/ browser/ tests/test_ language_ views.py' translations/ browser/ tests/test_ language_ views.py 2010-04-13 11:58:43 +0000 translations/ browser/ tests/test_ language_ views.py 1970-01-01 00:00:00 +0000 launchpad. webapp. servers import LaunchpadTestRe quest ssLayer model.karma import KarmaCategory, KarmaCache worlddata. interfaces. language import ILanguageSet .browser. language import LanguageAdminView inView( TestCaseWithFac tory): ssLayer minView( self, language): anslators( self, language, total=2): makePerson( ) addLanguage( language) append( person) category = KarmaCategory. selectOne( name==' translations' ) ssLayer. switchDbUser( 'karma' ) person= person, translations_ category, ssLayer. commit( ) ILanguageSet) .getLanguageByC ode('sr' ) ageTranslators( serbian, 1001) ssLayer. switchDbUser( 'launchpad' ) ew(serbian, LaunchpadTestRe quest(form= form)) extFromData( form)
--- lib/lp/
+++ lib/lp/
@@ -1,54 +0,0 @@
-# Copyright 2010 Canonical Ltd. This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-__metaclass__ = type
-
-import unittest
-
-from zope.component import getUtility
-from zope.security.proxy import removeSecurityProxy
-
-from canonical.
-from canonical.testing import LaunchpadZopele
-from lp.registry.
-from lp.services.
-from lp.testing import TestCaseWithFactory
-from lp.translations
-
-
-class TestLanguageAdm
- """Test Language web service API."""
-
- layer = LaunchpadZopele
-
- def setUpLanguageAd
- return view
-
- def setUpLanguageTr
- people = []
-
- for count in range(total):
- person = self.factory.
- person.
- people.
-
- translations_
- KarmaCategory.
- LaunchpadZopele
- for person in people:
- # Fake some translations Karma for these Serbian people.
- karma = KarmaCache(
- category=
- karmavalue=1)
- LaunchpadZopele
-
- def test_post(self):
- serbian = getUtility(
- self.setUpLangu
-
- LaunchpadZopele
- form = {}
- view = LanguageAdminVi
- view.initialize()
- view.updateCont
-