forked from openlp/openlp
Fix some of the tests which were failing in Python 3.4
This commit is contained in:
parent
5eae5b2090
commit
e4c3f08a2a
@ -49,7 +49,7 @@ class EasySlidesImport(SongImport):
|
||||
"""
|
||||
Initialise the class.
|
||||
"""
|
||||
SongImport.__init__(self, manager, **kwargs)
|
||||
super(EasySlidesImport, self).__init__(manager, **kwargs)
|
||||
|
||||
def do_import(self):
|
||||
log.info('Importing EasySlides XML file %s', self.import_source)
|
||||
|
@ -73,7 +73,7 @@ class EasyWorshipSongImport(SongImport):
|
||||
ability to import EasyWorship song files.
|
||||
"""
|
||||
def __init__(self, manager, **kwargs):
|
||||
SongImport.__init__(self, manager, **kwargs)
|
||||
super(EasyWorshipSongImport, self).__init__(manager, **kwargs)
|
||||
|
||||
def do_import(self):
|
||||
"""
|
||||
|
@ -97,7 +97,7 @@ class SongBeamerImport(SongImport):
|
||||
"""
|
||||
Initialise the Song Beamer importer.
|
||||
"""
|
||||
SongImport.__init__(self, manager, **kwargs)
|
||||
super(SongBeamerImport, self).__init__(manager, **kwargs)
|
||||
|
||||
def do_import(self):
|
||||
"""
|
||||
|
@ -92,7 +92,7 @@ class SongShowPlusImport(SongImport):
|
||||
"""
|
||||
Initialise the SongShow Plus importer.
|
||||
"""
|
||||
SongImport.__init__(self, manager, **kwargs)
|
||||
super(SongShowPlusImport, self).__init__(manager, **kwargs)
|
||||
|
||||
def do_import(self):
|
||||
"""
|
||||
|
@ -77,7 +77,7 @@ class EasyWorshipSongImportLogger(EasyWorshipSongImport):
|
||||
_title_assignment_list = []
|
||||
|
||||
def __init__(self, manager):
|
||||
EasyWorshipSongImport.__init__(self, manager)
|
||||
EasyWorshipSongImport.__init__(self, manager, filenames=[])
|
||||
|
||||
@property
|
||||
def title(self):
|
||||
@ -147,7 +147,7 @@ class TestEasyWorshipSongImport(TestCase):
|
||||
mocked_manager = MagicMock()
|
||||
|
||||
# WHEN: An importer object is created
|
||||
importer = EasyWorshipSongImport(mocked_manager)
|
||||
importer = EasyWorshipSongImport(mocked_manager, filenames=[])
|
||||
|
||||
# THEN: The importer object should not be None
|
||||
self.assertIsNotNone(importer, 'Import should not be none')
|
||||
@ -159,7 +159,7 @@ class TestEasyWorshipSongImport(TestCase):
|
||||
# GIVEN: A mocked out SongImport class, a mocked out "manager" and a list of field descriptions.
|
||||
with patch('openlp.plugins.songs.lib.ewimport.SongImport'):
|
||||
mocked_manager = MagicMock()
|
||||
importer = EasyWorshipSongImport(mocked_manager)
|
||||
importer = EasyWorshipSongImport(mocked_manager, filenames=[])
|
||||
importer.field_descriptions = TEST_FIELD_DESCS
|
||||
|
||||
# WHEN: Called with a field name that exists
|
||||
@ -177,7 +177,7 @@ class TestEasyWorshipSongImport(TestCase):
|
||||
# GIVEN: A mocked out SongImport class, a mocked out "manager" and a list of field descriptions
|
||||
with patch('openlp.plugins.songs.lib.ewimport.SongImport'):
|
||||
mocked_manager = MagicMock()
|
||||
importer = EasyWorshipSongImport(mocked_manager)
|
||||
importer = EasyWorshipSongImport(mocked_manager, filenames=[])
|
||||
importer.field_descriptions = TEST_FIELD_DESCS
|
||||
|
||||
# WHEN: Called with a field name that does not exist
|
||||
@ -196,7 +196,7 @@ class TestEasyWorshipSongImport(TestCase):
|
||||
with patch('openlp.plugins.songs.lib.ewimport.SongImport'), \
|
||||
patch('openlp.plugins.songs.lib.ewimport.struct') as mocked_struct:
|
||||
mocked_manager = MagicMock()
|
||||
importer = EasyWorshipSongImport(mocked_manager)
|
||||
importer = EasyWorshipSongImport(mocked_manager, filenames=[])
|
||||
|
||||
# WHEN: set_record_struct is called with a list of field descriptions
|
||||
return_value = importer.set_record_struct(TEST_FIELD_DESCS)
|
||||
@ -213,7 +213,7 @@ class TestEasyWorshipSongImport(TestCase):
|
||||
# GIVEN: A mocked out SongImport class, a mocked out "manager", an encoding and some test data and known results
|
||||
with patch('openlp.plugins.songs.lib.ewimport.SongImport'):
|
||||
mocked_manager = MagicMock()
|
||||
importer = EasyWorshipSongImport(mocked_manager)
|
||||
importer = EasyWorshipSongImport(mocked_manager, filenames=[])
|
||||
importer.encoding = TEST_DATA_ENCODING
|
||||
importer.fields = TEST_FIELDS
|
||||
importer.field_descriptions = TEST_FIELD_DESCS
|
||||
@ -236,7 +236,7 @@ class TestEasyWorshipSongImport(TestCase):
|
||||
with patch('openlp.plugins.songs.lib.ewimport.SongImport'):
|
||||
mocked_manager = MagicMock()
|
||||
mocked_memo_file = MagicMock()
|
||||
importer = EasyWorshipSongImport(mocked_manager)
|
||||
importer = EasyWorshipSongImport(mocked_manager, filenames=[])
|
||||
importer.memo_file = mocked_memo_file
|
||||
importer.encoding = TEST_DATA_ENCODING
|
||||
|
||||
@ -267,7 +267,7 @@ class TestEasyWorshipSongImport(TestCase):
|
||||
with patch('openlp.plugins.songs.lib.ewimport.SongImport'), \
|
||||
patch('openlp.plugins.songs.lib.ewimport.os.path') as mocked_os_path:
|
||||
mocked_manager = MagicMock()
|
||||
importer = EasyWorshipSongImport(mocked_manager)
|
||||
importer = EasyWorshipSongImport(mocked_manager, filenames=[])
|
||||
mocked_os_path.isfile.side_effect = [True, False]
|
||||
|
||||
# WHEN: Supplied with an import source
|
||||
@ -286,7 +286,7 @@ class TestEasyWorshipSongImport(TestCase):
|
||||
with patch('openlp.plugins.songs.lib.ewimport.SongImport'), \
|
||||
patch('openlp.plugins.songs.lib.ewimport.os.path') as mocked_os_path:
|
||||
mocked_manager = MagicMock()
|
||||
importer = EasyWorshipSongImport(mocked_manager)
|
||||
importer = EasyWorshipSongImport(mocked_manager, filenames=[])
|
||||
mocked_os_path.isfile.return_value = True
|
||||
importer.import_source = 'Songs.DB'
|
||||
|
||||
@ -307,7 +307,7 @@ class TestEasyWorshipSongImport(TestCase):
|
||||
patch('builtins.open') as mocked_open, \
|
||||
patch('openlp.plugins.songs.lib.ewimport.struct') as mocked_struct:
|
||||
mocked_manager = MagicMock()
|
||||
importer = EasyWorshipSongImport(mocked_manager)
|
||||
importer = EasyWorshipSongImport(mocked_manager, filenames=[])
|
||||
mocked_os_path.isfile.return_value = True
|
||||
mocked_os_path.getsize.return_value = 0x800
|
||||
importer.import_source = 'Songs.DB'
|
||||
@ -334,7 +334,7 @@ class TestEasyWorshipSongImport(TestCase):
|
||||
patch('builtins.open'), patch('openlp.plugins.songs.lib.ewimport.struct') as mocked_struct, \
|
||||
patch('openlp.plugins.songs.lib.ewimport.retrieve_windows_encoding') as mocked_retrieve_windows_encoding:
|
||||
mocked_manager = MagicMock()
|
||||
importer = EasyWorshipSongImport(mocked_manager)
|
||||
importer = EasyWorshipSongImport(mocked_manager, filenames=[])
|
||||
mocked_os_path.isfile.return_value = True
|
||||
mocked_os_path.getsize.return_value = 0x800
|
||||
importer.import_source = 'Songs.DB'
|
||||
|
@ -66,7 +66,7 @@ class TestSongBeamerImport(TestCase):
|
||||
mocked_manager = MagicMock()
|
||||
|
||||
# WHEN: An importer object is created
|
||||
importer = SongBeamerImport(mocked_manager)
|
||||
importer = SongBeamerImport(mocked_manager, filenames=[])
|
||||
|
||||
# THEN: The importer object should not be None
|
||||
self.assertIsNotNone(importer, 'Import should not be none')
|
||||
@ -79,7 +79,7 @@ class TestSongBeamerImport(TestCase):
|
||||
with patch('openlp.plugins.songs.lib.songbeamerimport.SongImport'):
|
||||
mocked_manager = MagicMock()
|
||||
mocked_import_wizard = MagicMock()
|
||||
importer = SongBeamerImport(mocked_manager)
|
||||
importer = SongBeamerImport(mocked_manager, filenames=[])
|
||||
importer.import_wizard = mocked_import_wizard
|
||||
importer.stop_import_flag = True
|
||||
|
||||
@ -100,7 +100,7 @@ class TestSongBeamerImport(TestCase):
|
||||
with patch('openlp.plugins.songs.lib.songbeamerimport.SongImport'):
|
||||
mocked_manager = MagicMock()
|
||||
mocked_import_wizard = MagicMock()
|
||||
importer = SongBeamerImport(mocked_manager)
|
||||
importer = SongBeamerImport(mocked_manager, filenames=[])
|
||||
importer.import_wizard = mocked_import_wizard
|
||||
importer.stop_import_flag = True
|
||||
|
||||
@ -127,7 +127,7 @@ class TestSongBeamerImport(TestCase):
|
||||
mocked_add_verse = MagicMock()
|
||||
mocked_finish = MagicMock()
|
||||
mocked_finish.return_value = True
|
||||
importer = SongBeamerImport(mocked_manager)
|
||||
importer = SongBeamerImport(mocked_manager, filenames=[])
|
||||
importer.import_wizard = mocked_import_wizard
|
||||
importer.stop_import_flag = False
|
||||
importer.add_verse = mocked_add_verse
|
||||
|
@ -72,7 +72,7 @@ class TestSongShowPlusImport(TestCase):
|
||||
mocked_manager = MagicMock()
|
||||
|
||||
# WHEN: An importer object is created
|
||||
importer = SongShowPlusImport(mocked_manager)
|
||||
importer = SongShowPlusImport(mocked_manager, filenames=[])
|
||||
|
||||
# THEN: The importer object should not be None
|
||||
self.assertIsNotNone(importer, 'Import should not be none')
|
||||
@ -85,7 +85,7 @@ class TestSongShowPlusImport(TestCase):
|
||||
with patch('openlp.plugins.songs.lib.songshowplusimport.SongImport'):
|
||||
mocked_manager = MagicMock()
|
||||
mocked_import_wizard = MagicMock()
|
||||
importer = SongShowPlusImport(mocked_manager)
|
||||
importer = SongShowPlusImport(mocked_manager, filenames=[])
|
||||
importer.import_wizard = mocked_import_wizard
|
||||
importer.stop_import_flag = True
|
||||
|
||||
@ -106,7 +106,7 @@ class TestSongShowPlusImport(TestCase):
|
||||
with patch('openlp.plugins.songs.lib.songshowplusimport.SongImport'):
|
||||
mocked_manager = MagicMock()
|
||||
mocked_import_wizard = MagicMock()
|
||||
importer = SongShowPlusImport(mocked_manager)
|
||||
importer = SongShowPlusImport(mocked_manager, filenames=[])
|
||||
importer.import_wizard = mocked_import_wizard
|
||||
importer.stop_import_flag = True
|
||||
|
||||
@ -126,7 +126,7 @@ class TestSongShowPlusImport(TestCase):
|
||||
# GIVEN: A mocked out SongImport class, and a mocked out "manager"
|
||||
with patch('openlp.plugins.songs.lib.songshowplusimport.SongImport'):
|
||||
mocked_manager = MagicMock()
|
||||
importer = SongShowPlusImport(mocked_manager)
|
||||
importer = SongShowPlusImport(mocked_manager, filenames=[])
|
||||
|
||||
# WHEN: Supplied with the following arguments replicating verses being added
|
||||
test_values = [('Verse 1', VerseType.tags[VerseType.Verse] + '1'),
|
||||
@ -153,7 +153,7 @@ class TestSongShowPlusImport(TestCase):
|
||||
# GIVEN: A mocked out SongImport class, and a mocked out "manager"
|
||||
with patch('openlp.plugins.songs.lib.songshowplusimport.SongImport'):
|
||||
mocked_manager = MagicMock()
|
||||
importer = SongShowPlusImport(mocked_manager)
|
||||
importer = SongShowPlusImport(mocked_manager, filenames=[])
|
||||
|
||||
# WHEN: Supplied with the following arguments replicating a verse order being added
|
||||
test_values = [('Verse 1', VerseType.tags[VerseType.Verse] + '1'),
|
||||
|
@ -89,7 +89,7 @@ class SongImportTestHelper(TestCase):
|
||||
"""
|
||||
Import the given file and check that it has imported correctly
|
||||
"""
|
||||
importer = self.importer_class(self.mocked_manager)
|
||||
importer = self.importer_class(self.mocked_manager, filenames=[source_file_name])
|
||||
importer.import_wizard = self.mocked_import_wizard
|
||||
importer.stop_import_flag = False
|
||||
importer.topics = []
|
||||
|
Loading…
Reference in New Issue
Block a user