Merge lp://staging/~danilo/launchpad/bug-428440 into lp://staging/launchpad

Proposed by Данило Шеган
Status: Merged
Merged at revision: not available
Proposed branch: lp://staging/~danilo/launchpad/bug-428440
Merge into: lp://staging/launchpad
Diff against target: None lines
To merge this branch: bzr merge lp://staging/~danilo/launchpad/bug-428440
Reviewer Review Type Date Requested Status
Eleanor Berger (community) Approve
Review via email: mp+11688@code.staging.launchpad.net
To post a comment you must log in.
Revision history for this message
Данило Шеган (danilo) wrote :

= Bug #428440 =

In the process of migrating pages, I've managed to break
ProductSeriesLanguage object when there are no pofiles attached (i.e. no
translations yet for that language).

= Proposed fix =

The problem is that recalculateCounts might keep None values for bits of
implementation that RosettaStats interface uses to construct other
values (i.e. translatedCount = rosettacount + currentcount).

We should turn all of them into 0s if any of the values is None.

= Tests =

bin/test -vvt productserieslanguage

= Demo & QA =

Demo:
 https://translations.launchpad.dev/evolution/trunk/+lang/sr

QA:
 https://translations.edge.launchpad.net/b2evolution/trunk/+lang/sr

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/lp/translations/model/productserieslanguage.py
  lib/lp/translations/tests/test_productserieslanguage.py

Revision history for this message
Eleanor Berger (intellectronica) wrote :

(12:20:28) intellectronica: danilos: please add a comment between the condition and the then-clause of the if statement to distinguish them
(12:20:52) danilos: intellectronica, sure
(12:21:53) intellectronica: danilos: the indentation on line 27/28 is a bit off
(12:22:22) intellectronica: danilos: other than that it's all nice and good and r=me

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/model/productserieslanguage.py'
2--- lib/lp/translations/model/productserieslanguage.py 2009-09-10 10:50:55 +0000
3+++ lib/lp/translations/model/productserieslanguage.py 2009-09-12 16:07:05 +0000
4@@ -76,6 +76,9 @@
5 POTemplate.productseries==self.productseries,
6 POTemplate.iscurrent==True)
7 imported, changed, new, unreviewed = query[0]
8+ if (imported is None or changed is None or
9+ new is None or unreviewed is None):
10+ imported = changed = new = unreviewed = 0
11 self.setCounts(self._getMessageCount(), imported, changed,
12 new, unreviewed)
13
14
15=== modified file 'lib/lp/translations/tests/test_productserieslanguage.py'
16--- lib/lp/translations/tests/test_productserieslanguage.py 2009-09-10 10:50:55 +0000
17+++ lib/lp/translations/tests/test_productserieslanguage.py 2009-09-12 16:07:05 +0000
18@@ -226,6 +226,17 @@
19 # which adds up as (1+3)+(1+1).
20 self.assertPSLStatistics(psl, (30, 6, 2, 4, 3, 5))
21
22+ def test_recalculateCounts_no_pofiles(self):
23+ # Test that recalculateCounts works correctly even when there
24+ # are no POFiles returned.
25+ potemplate1 = self.createPOTemplateWithPOTMsgSets(1)
26+ potemplate2 = self.createPOTemplateWithPOTMsgSets(2)
27+ psl = self.psl_set.getProductSeriesLanguage(self.productseries,
28+ self.language)
29+ psl.recalculateCounts()
30+ # And all the counts are zero.
31+ self.assertPSLStatistics(psl, (3, 0, 0, 0, 0, 0))
32+
33
34 def test_suite():
35 return unittest.TestLoader().loadTestsFromName(__name__)
36