forked from openlp/openlp
Handle tests with platform-dependent behavior carefully
This commit is contained in:
parent
2511332a9e
commit
1ac75c85fd
@ -105,33 +105,14 @@ class TestUtils(TestCase):
|
|||||||
# THEN: The file name should be cleaned.
|
# THEN: The file name should be cleaned.
|
||||||
assert result == wanted_name, 'The file name should not contain any special characters.'
|
assert result == wanted_name, '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
|
|
||||||
# THEN: We get a properly sorted list
|
|
||||||
test_passes = sorted(unsorted_list, key=get_locale_key) == ['Aushang', '\u00C4u\u00DFerung', 'Auszug']
|
|
||||||
assert test_passes, '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
|
||||||
# THEN: We get a properly sorted list
|
# THEN: We get a properly sorted list
|
||||||
|
@ -5,10 +5,12 @@
|
|||||||
This module contains tests for the WorshipCenter Pro song importer.
|
This module contains tests for the WorshipCenter Pro song importer.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from unittest import TestCase
|
from unittest import TestCase, skipIf
|
||||||
from mock import patch, MagicMock
|
from mock import patch, MagicMock
|
||||||
import pyodbc
|
|
||||||
|
|
||||||
|
import os
|
||||||
|
if os.name == 'nt':
|
||||||
|
import pyodbc
|
||||||
from openlp.plugins.songs.lib.worshipcenterproimport import WorshipCenterProImport
|
from openlp.plugins.songs.lib.worshipcenterproimport import WorshipCenterProImport
|
||||||
|
|
||||||
class TestRecord(object):
|
class TestRecord(object):
|
||||||
@ -23,6 +25,7 @@ class TestRecord(object):
|
|||||||
self.Field = field
|
self.Field = field
|
||||||
self.Value = value
|
self.Value = value
|
||||||
|
|
||||||
|
if os.name == 'nt':
|
||||||
class WorshipCenterProImportLogger(WorshipCenterProImport):
|
class WorshipCenterProImportLogger(WorshipCenterProImport):
|
||||||
"""
|
"""
|
||||||
This class logs changes in the title instance variable
|
This class logs changes in the title instance variable
|
||||||
@ -98,6 +101,7 @@ SONG_TEST_DATA = [{'title': 'Amazing Grace',
|
|||||||
('There\'s a garden where\nJesus is waiting,\nAnd He bids you to come,\nmeet Him there;\n'
|
('There\'s a garden where\nJesus is waiting,\nAnd He bids you to come,\nmeet Him there;\n'
|
||||||
'Just to bow and\nreceive a new blessing\nIn the beautiful\ngarden of prayer.')]}]
|
'Just to bow and\nreceive a new blessing\nIn the beautiful\ngarden of prayer.')]}]
|
||||||
|
|
||||||
|
@skipIf(os.name != 'nt', 'WorshipCenter Pro import only supported on Windows')
|
||||||
class TestWorshipCenterProSongImport(TestCase):
|
class TestWorshipCenterProSongImport(TestCase):
|
||||||
"""
|
"""
|
||||||
Test the functions in the :mod:`worshipcenterproimport` module.
|
Test the functions in the :mod:`worshipcenterproimport` module.
|
||||||
|
Loading…
Reference in New Issue
Block a user