/
test_plugin.py
64 lines (54 loc) · 2.46 KB
/
test_plugin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from ckan import plugins
from ckan.tests import helpers
from nose.tools import assert_true, assert_false
class TestExampleITranslationPlugin(helpers.FunctionalTestBase):
@classmethod
def setup_class(cls):
super(TestExampleITranslationPlugin, cls).setup_class()
plugins.load('example_itranslation')
@classmethod
def teardown_class(cls):
plugins.unload('example_itranslation')
super(TestExampleITranslationPlugin, cls).teardown_class()
def test_translated_string_in_extensions_templates(self):
app = self._get_test_app()
response = app.get(
url=plugins.toolkit.url_for(controller='home', action='index',
locale='fr'),
)
assert_true('This is a itranslated string' in response.body)
assert_false('This is an untranslated string' in response.body)
# double check the untranslated strings
response = app.get(
url=plugins.toolkit.url_for(controller='home', action='index'),
)
assert_true('This is an untranslated string' in response.body)
assert_false('This is a itranslated string' in response.body)
def test_translated_string_in_core_templates(self):
app = self._get_test_app()
response = app.get(
url=plugins.toolkit.url_for(controller='home', action='index',
locale='fr'),
)
assert_true('Overwritten string in ckan.mo' in response.body)
assert_false('Connexion' in response.body)
# double check the untranslated strings
response = app.get(
url=plugins.toolkit.url_for(controller='home', action='index'),
)
assert_true('Log in' in response.body)
assert_false('Overwritten string in ckan.mo' in response.body)
# check that we have only overwritten 'fr'
response = app.get(
url=plugins.toolkit.url_for(controller='home', action='index',
locale='de'),
)
assert_true('Einloggen' in response.body)
assert_false('Overwritten string in ckan.mo' in response.body)
def test_english_translation_replaces_default_english_string(self):
app = self._get_test_app()
response = app.get(
url=plugins.toolkit.url_for(controller='home', action='index'),
)
assert_true('Replaced' in response.body)
assert_false('Register' in response.body)