Merge lp:~danilo/launchpad/invalid-messages into lp:~launchpad/launchpad/recife

Proposed by Данило Шеган on 2010-11-18
Status: Merged
Approved by: Aaron Bentley on 2010-11-18
Approved revision: no longer in the source branch.
Merged at revision: 9202
Proposed branch: lp:~danilo/launchpad/invalid-messages
Merge into: lp:~launchpad/launchpad/recife
Diff against target: 192 lines (+0/-99)
6 files modified
lib/lp/translations/doc/pofile.txt (+0/-3)
lib/lp/translations/doc/poimport.txt (+0/-15)
lib/lp/translations/interfaces/pofile.py (+0/-3)
lib/lp/translations/model/pofile.py (+0/-19)
lib/lp/translations/tests/test_pofile.py (+0/-52)
lib/lp/translations/utilities/translation_import.py (+0/-7)
To merge this branch: bzr merge lp:~danilo/launchpad/invalid-messages
Reviewer Review Type Date Requested Status
Aaron Bentley (community) 2010-11-18 Approve on 2010-11-18
Review via email: mp+41209@code.launchpad.net

Description of the Change

= Get rid of getPOTMsgSetWithErrors =

This branch initially started as an effort to port it to the new data
model we are introducing in our integration branch (branch this is
proposed for merge to).

However, it turned out that this method is not used anywhere except in
tests, so I decided to do a better thing: get rid of altogether.

There was one mention of a work-around in the code in the integration
branch as-is due to this method not being ported, but I just removed the
work-around and the tests for getPOTMsgSetWithErrors, and we were all
good (ran the full translations test suite).

Lint reports a few issues that I am not touching right now because
they'd mean serious refactoring of doc/pofile.txt test (it uses long
string comparisons over multiple lines, and lint complains if a single
string goes over 78 characters, regardless of whether it's on a single
line: no lines go over 78 though).

== Tests ==

Basically, all translation tests:

  bin/test -m lp.translations

To post a comment you must log in.
Aaron Bentley (abentley) wrote :

Hard to find style errors with the removal of code :-)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/translations/doc/pofile.txt'
2--- lib/lp/translations/doc/pofile.txt 2010-11-18 11:55:23 +0000
3+++ lib/lp/translations/doc/pofile.txt 2010-11-18 18:24:11 +0000
4@@ -52,9 +52,6 @@
5 >>> dummy_pofile.getPOTMsgSetWithNewSuggestions().count()
6 0
7
8- >>> dummy_pofile.getPOTMsgSetWithErrors().count()
9- 0
10-
11 >>> dummy_pofile.getPOTMsgSetUntranslated().count()
12 22
13
14
15=== modified file 'lib/lp/translations/doc/poimport.txt'
16--- lib/lp/translations/doc/poimport.txt 2010-11-18 14:00:48 +0000
17+++ lib/lp/translations/doc/poimport.txt 2010-11-18 18:24:11 +0000
18@@ -333,21 +333,6 @@
19 >>> print message
20 None
21
22-We can also get the ones that have validation errors.
23-
24- >>> potmsgsets = pofile.getPOTMsgSetWithErrors()
25- >>> potmsgsets.count()
26- 1
27-
28- >>> for potmsgset in potmsgsets:
29- ... translationmessages = potmsgset.getLocalTranslationMessages(
30- ... pofile.potemplate, pofile.language)
31- ... for translationmessage in translationmessages:
32- ... assert (
33- ... translationmessage.validation_status ==
34- ... TranslationValidationStatus.UNKNOWNERROR), (
35- ... "Doesn't have a validation error")
36-
37 Check that the plural form was imported correctly.
38
39 >>> potmsgset = pofile.potemplate.getPOTMsgSetByMsgIDText(
40
41=== modified file 'lib/lp/translations/interfaces/pofile.py'
42--- lib/lp/translations/interfaces/pofile.py 2010-11-09 06:55:07 +0000
43+++ lib/lp/translations/interfaces/pofile.py 2010-11-18 18:24:11 +0000
44@@ -195,9 +195,6 @@
45 through Launchpad.
46 """
47
48- def getPOTMsgSetWithErrors():
49- """Get message sets that have translations imported with errors."""
50-
51 def getTranslationsFilteredBy(person):
52 """Get TranslationMessages in this `IPOFile` contributed by `person`.
53
54
55=== modified file 'lib/lp/translations/model/pofile.py'
56--- lib/lp/translations/model/pofile.py 2010-11-17 15:19:31 +0000
57+++ lib/lp/translations/model/pofile.py 2010-11-18 18:24:11 +0000
58@@ -94,7 +94,6 @@
59 )
60 from lp.translations.interfaces.translationmessage import (
61 RosettaTranslationOrigin,
62- TranslationValidationStatus,
63 )
64 from lp.translations.interfaces.translations import TranslationConstants
65 from lp.translations.model.pomsgid import POMsgID
66@@ -738,20 +737,6 @@
67 query = ' AND '.join(clauses)
68 return self._getOrderedPOTMsgSets(clause_tables, query)
69
70- def getPOTMsgSetWithErrors(self):
71- """See `IPOFile`."""
72- clauses = self._getClausesForPOFileMessages()
73- clauses.extend([
74- 'TranslationTemplateItem.potmsgset = POTMsgSet.id',
75- 'TranslationMessage.is_current_upstream IS TRUE',
76- 'TranslationMessage.validation_status <> %s' % sqlvalues(
77- TranslationValidationStatus.OK),
78- ])
79-
80- query = ' AND '.join(clauses)
81- origin = [POTMsgSet, TranslationMessage, TranslationTemplateItem]
82- return self._getOrderedPOTMsgSets(origin, query)
83-
84 def messageCount(self):
85 """See `IRosettaStats`."""
86 return self.potemplate.messageCount()
87@@ -1255,10 +1240,6 @@
88 """See `IPOFile`."""
89 return EmptyResultSet()
90
91- def getPOTMsgSetWithErrors(self):
92- """See `IPOFile`."""
93- return EmptyResultSet()
94-
95 def getTranslationMessages(self, condition=None):
96 """See `IPOFile`."""
97 return EmptyResultSet()
98
99=== modified file 'lib/lp/translations/tests/test_pofile.py'
100--- lib/lp/translations/tests/test_pofile.py 2010-11-18 12:01:49 +0000
101+++ lib/lp/translations/tests/test_pofile.py 2010-11-18 18:24:11 +0000
102@@ -36,7 +36,6 @@
103 from lp.translations.interfaces.translationgroup import TranslationPermission
104 from lp.translations.interfaces.translationmessage import (
105 RosettaTranslationOrigin,
106- TranslationValidationStatus,
107 )
108 from lp.translations.interfaces.translationsperson import ITranslationsPerson
109
110@@ -815,17 +814,6 @@
111 self.devel_pofile.getPOTMsgSetChangedInUbuntu())
112 self.assertEquals(found_translations, [self.potmsgset])
113
114- def test_getPOTMsgSetWithErrors(self):
115- # Test listing of POTMsgSets with errors in translations.
116- translation = self.factory.makeSharedTranslationMessage(
117- pofile=self.devel_pofile, potmsgset=self.potmsgset,
118- translations=[u"Imported translation"], is_current_upstream=True)
119- removeSecurityProxy(translation).validation_status = (
120- TranslationValidationStatus.UNKNOWNERROR)
121- found_translations = list(
122- self.devel_pofile.getPOTMsgSetWithErrors())
123- self.assertEquals(found_translations, [self.potmsgset])
124-
125 def test_updateStatistics(self):
126 # Test that updating statistics keeps working.
127
128@@ -1363,46 +1351,6 @@
129 self.assertEquals(
130 [self.potmsgset1, self.potmsgset2], potmsgsets)
131
132- def test_getPOTMsgSetWithErrors_ordering(self):
133- # Suggest a translation on both POTMsgSets in devel_pofile,
134- # so they are returned with getPOTMsgSetWithNewSuggestions() call.
135- imported1 = self.factory.makeSharedTranslationMessage(
136- pofile=self.devel_pofile,
137- potmsgset=self.potmsgset1,
138- translations=["Imported"],
139- is_current_upstream=True)
140- removeSecurityProxy(imported1).validation_status = (
141- TranslationValidationStatus.UNKNOWNERROR)
142- imported2 = self.factory.makeSharedTranslationMessage(
143- pofile=self.devel_pofile,
144- potmsgset=self.potmsgset2,
145- translations=["Another imported"],
146- is_current_upstream=True)
147- removeSecurityProxy(imported2).validation_status = (
148- TranslationValidationStatus.UNKNOWNERROR)
149-
150- potmsgsets = list(
151- self.devel_pofile.getPOTMsgSetWithErrors())
152- self.assertEquals(
153- [self.potmsgset1, self.potmsgset2], potmsgsets)
154-
155- # Insert these two POTMsgSets into self.stable_potemplate in reverse
156- # order.
157- self.potmsgset2.setSequence(self.stable_potemplate, 1)
158- self.potmsgset1.setSequence(self.stable_potemplate, 2)
159-
160- # And they are returned in the new order as desired.
161- potmsgsets = list(
162- self.stable_pofile.getPOTMsgSetWithErrors())
163- self.assertEquals(
164- [self.potmsgset2, self.potmsgset1], potmsgsets)
165-
166- # Order is unchanged for the previous template.
167- potmsgsets = list(
168- self.devel_pofile.getPOTMsgSetWithErrors())
169- self.assertEquals(
170- [self.potmsgset1, self.potmsgset2], potmsgsets)
171-
172 def test_getPOTMsgSets_ordering(self):
173 # Both POTMsgSets in devel_potemplate are untranslated.
174 potmsgsets = list(
175
176=== modified file 'lib/lp/translations/utilities/translation_import.py'
177--- lib/lp/translations/utilities/translation_import.py 2010-11-18 12:04:42 +0000
178+++ lib/lp/translations/utilities/translation_import.py 2010-11-18 18:24:11 +0000
179@@ -564,13 +564,6 @@
180 if validation_ok and self.is_editor:
181 return self._approveMessage(potmsgset, new_message, message_data)
182
183- if self.translation_import_queue_entry.by_maintainer:
184- # XXX: henninge 2010-09-21: Mixed models!
185- # This is mimicking the old behavior to still mark these messages
186- # as "imported". Will have to be removed when
187- # getPOTMsgSetsWithErrors is updated to the new model.
188- new_message.makeCurrentUpstream(True)
189-
190 return new_message
191
192 def importMessage(self, message):

Subscribers

People subscribed via source and target branches

to all changes: