~tomasgroth/openlp/portable-path

« back to all changes in this revision

Viewing changes to tests/functional/openlp_core/common/test_i18n.py

  • Committer: Tomas Groth
  • Date: 2019-04-30 19:02:42 UTC
  • mfrom: (2829.2.32 openlp)
  • Revision ID: tomasgroth@yahoo.dk-20190430190242-6zwjk8724tyux70m
trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
###############################################################################
5
5
# OpenLP - Open Source Lyrics Projection                                      #
6
6
# --------------------------------------------------------------------------- #
7
 
# Copyright (c) 2008-2018 OpenLP Developers                                   #
 
7
# Copyright (c) 2008-2019 OpenLP Developers                                   #
8
8
# --------------------------------------------------------------------------- #
9
9
# This program is free software; you can redistribute it and/or modify it     #
10
10
# under the terms of the GNU General Public License as published by the Free  #
22
22
"""
23
23
Package to test the openlp.core.lib.languages package.
24
24
"""
25
 
from unittest import skipIf
26
25
from unittest.mock import MagicMock, patch
27
26
 
28
 
from openlp.core.common import is_macosx
29
27
from openlp.core.common.i18n import LANGUAGES, Language, UiStrings, get_language, get_locale_key, get_natural_key, \
30
 
    translate
 
28
    translate, LanguageManager
 
29
from openlp.core.common.settings import Settings
31
30
 
32
31
 
33
32
def test_languages_type():
112
111
    assert language is None
113
112
 
114
113
 
115
 
@skipIf(is_macosx(), 'This test doesn\'t work on macOS currently')
116
114
def test_get_locale_key():
117
115
    """
118
116
    Test the get_locale_key(string) function
158
156
    assert first_instance is second_instance, 'Two UiStrings objects should be the same instance'
159
157
 
160
158
 
 
159
def test_get_language_from_settings():
 
160
    assert LanguageManager.get_language() == 'en'
 
161
 
 
162
 
 
163
def test_get_language_from_settings_returns_unchanged_if_unknown_format():
 
164
    Settings().setValue('core/language', '(foobar)')
 
165
    assert LanguageManager.get_language() == '(foobar)'
 
166
 
 
167
 
161
168
def test_translate():
162
169
    """
163
170
    Test the translate() function