Clean up language tests

bzr-revno: 2303
This commit is contained in:
Jeffrey Smith 2013-10-05 06:24:05 +01:00 committed by Tim Bentley
commit 474f551839

View File

@ -150,35 +150,14 @@ class TestUtils(TestCase):
# THEN: The file name should be cleaned. # THEN: The file name should be cleaned.
self.assertEqual(wanted_name, result, 'The file name should not contain any special characters.') self.assertEqual(wanted_name, result, 'The file name should not contain any special characters.')
def get_locale_key_windows_test(self): def get_locale_key_test(self):
""" """
Test the get_locale_key(string) function Test the get_locale_key(string) function
""" """
with patch('openlp.core.utils.languagemanager.LanguageManager.get_language') as mocked_get_language, \ with patch('openlp.core.utils.languagemanager.LanguageManager.get_language') as mocked_get_language:
patch('openlp.core.utils.os') as mocked_os:
# GIVEN: The language is German # GIVEN: The language is German
# 0x00C3 (A with diaresis) should be sorted as "A". 0x00DF (sharp s) should be sorted as "ss". # 0x00C3 (A with diaresis) should be sorted as "A". 0x00DF (sharp s) should be sorted as "ss".
mocked_get_language.return_value = 'de' mocked_get_language.return_value = 'de'
mocked_os.name = 'nt'
unsorted_list = ['Auszug', 'Aushang', '\u00C4u\u00DFerung']
# WHEN: We sort the list and use get_locale_key() to generate the sorting keys
sorted_list = sorted(unsorted_list, key=get_locale_key)
# THEN: We get a properly sorted list
self.assertEqual(['Aushang', '\u00C4u\u00DFerung', 'Auszug'], sorted_list,
'Strings should be sorted properly')
def get_locale_key_linux_test(self):
"""
Test the get_locale_key(string) function
"""
with patch('openlp.core.utils.languagemanager.LanguageManager.get_language') as mocked_get_language, \
patch('openlp.core.utils.os.name') as mocked_os:
# GIVEN: The language is German
# 0x00C3 (A with diaresis) should be sorted as "A". 0x00DF (sharp s) should be sorted as "ss".
mocked_get_language.return_value = 'de'
mocked_os.name = 'linux'
unsorted_list = ['Auszug', 'Aushang', '\u00C4u\u00DFerung'] unsorted_list = ['Auszug', 'Aushang', '\u00C4u\u00DFerung']
# WHEN: We sort the list and use get_locale_key() to generate the sorting keys # WHEN: We sort the list and use get_locale_key() to generate the sorting keys