[damned-lies] Fixed a regression with language sorting in stat lists
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Fixed a regression with language sorting in stat lists
- Date: Sat, 5 Mar 2016 15:14:47 +0000 (UTC)
commit f6b888e34abdfaf42533ef590054607ac3753816
Author: Claude Paroz <claude 2xlibre net>
Date: Sat Mar 5 16:12:47 2016 +0100
Fixed a regression with language sorting in stat lists
The regression was introduced in 643f1d79fbf when refactoring sort functions.
Fixes bug #762970.
stats/models.py | 2 +-
stats/tests/tests.py | 13 +++++++++++--
2 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/stats/models.py b/stats/models.py
index de79c35..f992259 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -409,7 +409,7 @@ class Branch(models.Model):
# Sort
for key, doms in stats.items():
#Sort stats, pot first, then translated (desc), then language name
- doms.sort(key=lambda st:(int(st.language_id is not None), -st.translated(), st.get_lang()))
+ doms.sort(key=lambda st:(int(st.language is not None), -st.translated(), st.get_lang()))
return stats
def get_doc_stats(self, mandatory_langs=[]):
diff --git a/stats/tests/tests.py b/stats/tests/tests.py
index f9c616c..1b9d89b 100644
--- a/stats/tests/tests.py
+++ b/stats/tests/tests.py
@@ -170,7 +170,14 @@ class ModuleTestCase(TestCase):
self.assertEqual(fr_po_stat.po_url(), u"/POT/gnome-hello.master/gnome-hello.master.fr.po")
self.assertEqual(fr_po_stat.pot_url(), u"/POT/gnome-hello.master/gnome-hello.master.pot")
self.assertEqual(fr_doc_stat.po_url(), u"/POT/gnome-hello.master/docs/gnome-hello-help.master.fr.po")
- self.assertRaises(Statistics.DoesNotExist, Statistics.objects.get, pk=ghost_stat.pk)
+ with self.assertRaises(Statistics.DoesNotExist):
+ Statistics.objects.get(pk=ghost_stat.pk)
+
+ stats = self.branch.get_stats('doc', mandatory_langs=[lang])
+ self.assertIn('help', stats)
+ self.assertTrue(stats['help'][0].is_pot_stats()) # POT first
+ self.assertEqual(stats['help'][-1].language.locale, 'xxx') # Fake stat last
+
if utils.has_toolkit:
self.assertEqual(fr_po_stat.po_url(reduced=True),
u"/POT/gnome-hello.master/gnome-hello.master.fr.reduced.po")
self.assertEqual(fr_po_stat.translated(scope='part'), 44)
@@ -242,9 +249,11 @@ class ModuleTestCase(TestCase):
b3.save(update_statistics=False)
b4 = Branch(name='gnome-3-10', module=self.mod)
b4.save(update_statistics=False)
+ b5 = Branch(name='gnome-3-20', module=self.mod)
+ b5.save(update_statistics=False)
self.assertEqual(
[b.name for b in sorted(self.mod.branch_set.all())],
- ['master', 'a-branch', 'p-branch', 'gnome-3-10', 'gnome-3-2']
+ ['master', 'a-branch', 'p-branch', 'gnome-3-20', 'gnome-3-10', 'gnome-3-2']
)
@test_scratchdir
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]