1
|
|
|
# -*- coding: utf-8 -*- |
2
|
|
|
|
3
|
|
|
from __future__ import unicode_literals |
4
|
|
|
|
5
|
|
|
from django.test import TestCase |
6
|
|
|
|
7
|
|
|
from parler.utils import get_parler_languages_from_django_cms |
8
|
|
|
|
9
|
|
|
|
10
|
|
|
class UtilTestCase(TestCase): |
11
|
|
|
def test_get_parler_languages_from_django_cms(self): |
12
|
|
|
cms = { |
13
|
|
|
1: [ |
14
|
|
|
{ |
15
|
|
|
'code': 'en', |
16
|
|
|
'fallbacks': ['es'], |
17
|
|
|
'hide_untranslated': True, |
18
|
|
|
'name': 'English', |
19
|
|
|
'public': True, |
20
|
|
|
'redirect_on_fallback': True |
21
|
|
|
}, |
22
|
|
|
{ |
23
|
|
|
'code': 'es', |
24
|
|
|
'fallbacks': ['en'], |
25
|
|
|
'hide_untranslated': True, |
26
|
|
|
'name': 'Spanish', |
27
|
|
|
'public': True, |
28
|
|
|
'redirect_on_fallback': True |
29
|
|
|
}, |
30
|
|
|
{ |
31
|
|
|
'code': 'fr', |
32
|
|
|
'fallbacks': ['en'], |
33
|
|
|
'hide_untranslated': True, |
34
|
|
|
'name': 'French', |
35
|
|
|
'public': True, |
36
|
|
|
'redirect_on_fallback': True |
37
|
|
|
} |
38
|
|
|
], |
39
|
|
|
'default': { |
40
|
|
|
'fallbacks': ['en', ], |
41
|
|
|
'hide_untranslated': True, |
42
|
|
|
'public': True, |
43
|
|
|
'redirect_on_fallback': True |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
parler = { |
48
|
|
|
1: [ |
49
|
|
|
{ |
50
|
|
|
'code': 'en', |
51
|
|
|
'fallbacks': ['es'], |
52
|
|
|
'hide_untranslated': True, |
53
|
|
|
'redirect_on_fallback': True |
54
|
|
|
}, |
55
|
|
|
{ |
56
|
|
|
'code': 'es', |
57
|
|
|
'fallbacks': ['en'], |
58
|
|
|
'hide_untranslated': True, |
59
|
|
|
'redirect_on_fallback': True |
60
|
|
|
}, |
61
|
|
|
{ |
62
|
|
|
'code': 'fr', |
63
|
|
|
'fallbacks': ['en'], |
64
|
|
|
'hide_untranslated': True, |
65
|
|
|
'redirect_on_fallback': True |
66
|
|
|
} |
67
|
|
|
], |
68
|
|
|
'default': { |
69
|
|
|
'fallbacks': ['en', ], |
70
|
|
|
'hide_untranslated': True, |
71
|
|
|
'redirect_on_fallback': True |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
computed = get_parler_languages_from_django_cms(cms) |
76
|
|
|
for block, block_config in computed.items(): |
77
|
|
|
self.assertEqual(cmp(computed[block], parler[block]), 0) |
78
|
|
|
|