1
0
mirror of https://gitlab.com/openlp/openlp.git synced 2024-09-28 19:07:35 +00:00

Move song test resources to a 'song' sub directory'

A few other minor changes
This commit is contained in:
Phill Ridout 2017-12-24 08:42:46 +00:00
parent b87a797b39
commit a4054d3c2c
24 changed files with 45 additions and 45 deletions

View File

@ -34,7 +34,7 @@ from openlp.core.common.registry import Registry
from openlp.core.common.path import Path
from openlp.core.ui import ThemeManager
from tests.utils.constants import TEST_RESOURCES_PATH
from tests.utils.constants import RESOURCE_PATH
class TestThemeManager(TestCase):
@ -60,7 +60,7 @@ class TestThemeManager(TestCase):
"""
# GIVEN: A new ThemeManager instance.
theme_manager = ThemeManager()
theme_manager.theme_path = Path(TEST_RESOURCES_PATH, 'themes')
theme_manager.theme_path = RESOURCE_PATH / 'themes'
mocked_zipfile_init.return_value = None
# WHEN: The theme is exported
@ -68,7 +68,7 @@ class TestThemeManager(TestCase):
# THEN: The zipfile should be created at the given path
mocked_zipfile_init.assert_called_with(os.path.join('some', 'path', 'Default.otz'), 'w')
mocked_zipfile_write.assert_called_with(os.path.join(TEST_RESOURCES_PATH, 'themes', 'Default', 'Default.xml'),
mocked_zipfile_write.assert_called_with(str(RESOURCE_PATH / 'themes' / 'Default' / 'Default.xml'),
os.path.join('Default', 'Default.xml'))
def test_initial_theme_manager(self):
@ -100,8 +100,8 @@ class TestThemeManager(TestCase):
mocked_theme.extract_formatted_xml.return_value = 'fake_theme_xml'.encode()
# WHEN: Calling _write_theme with path to the same image, but the path written slightly different
file_name1 = Path(TEST_RESOURCES_PATH, 'church.jpg')
theme_manager._write_theme(mocked_theme, file_name1, file_name1)
file_path_1 = RESOURCE_PATH / 'church.jpg'
theme_manager._write_theme(mocked_theme, file_path_1, file_path_1)
# THEN: The mocked_copyfile should not have been called
assert mocked_copyfile.called is False, 'copyfile should not be called'
@ -123,9 +123,9 @@ class TestThemeManager(TestCase):
mocked_theme.filename = "filename"
# WHEN: Calling _write_theme with path to different images
file_name1 = Path(TEST_RESOURCES_PATH, 'church.jpg')
file_name2 = Path(TEST_RESOURCES_PATH, 'church2.jpg')
theme_manager._write_theme(mocked_theme, file_name1, file_name2)
file_path_1 = RESOURCE_PATH / 'church.jpg'
file_path_2 = RESOURCE_PATH / 'church2.jpg'
theme_manager._write_theme(mocked_theme, file_path_1, file_path_2)
# THEN: The mocked_copyfile should not have been called
assert mocked_copyfile.called is True, 'copyfile should be called'
@ -200,10 +200,10 @@ class TestThemeManager(TestCase):
theme_manager.generate_and_save_image = MagicMock()
theme_manager.theme_path = None
folder_path = Path(mkdtemp())
theme_file = Path(TEST_RESOURCES_PATH, 'themes', 'Moss_on_tree.otz')
theme_file_path = RESOURCE_PATH / 'themes' / 'Moss_on_tree.otz'
# WHEN: We try to unzip it
theme_manager.unzip_theme(theme_file, folder_path)
theme_manager.unzip_theme(theme_file_path, folder_path)
# THEN: Files should be unpacked
assert (folder_path / 'Moss on tree' / 'Moss on tree.xml').exists() is True

View File

@ -32,7 +32,7 @@ from openlp.core.common.path import Path
from openlp.plugins.presentations.lib.impresscontroller import ImpressController, ImpressDocument, TextType
from openlp.plugins.presentations.presentationplugin import __default_settings__
from tests.utils.constants import TEST_RESOURCES_PATH
from tests.utils.constants import RESOURCE_PATH
from tests.helpers.testmixin import TestMixin
@ -134,7 +134,7 @@ class TestImpressDocument(TestCase):
mocked_plugin = MagicMock()
mocked_plugin.settings_section = 'presentations'
Settings().extend_default_settings(__default_settings__)
self.file_name = Path(TEST_RESOURCES_PATH, 'presentations', 'test.pptx')
self.file_name = RESOURCE_PATH / 'presentations' / 'test.pptx'
self.ppc = ImpressController(mocked_plugin)
self.doc = ImpressDocument(self.ppc, self.file_name)

View File

@ -35,7 +35,7 @@ from openlp.core.common.settings import Settings
from openlp.core.common.path import Path
from openlp.core.display.screens import ScreenList
from tests.utils.constants import TEST_RESOURCES_PATH
from tests.utils.constants import RESOURCE_PATH
from tests.helpers.testmixin import TestMixin
__default_settings__ = {
@ -99,7 +99,7 @@ class TestPdfController(TestCase, TestMixin):
Test loading of a Pdf using the PdfController
"""
# GIVEN: A Pdf-file
test_file = Path(TEST_RESOURCES_PATH, 'presentations', 'pdf_test1.pdf')
test_file_path = RESOURCE_PATH / 'presentations' / 'pdf_test1.pdf'
# WHEN: The Pdf is loaded
controller = PdfController(plugin=self.mock_plugin)
@ -107,7 +107,7 @@ class TestPdfController(TestCase, TestMixin):
raise SkipTest('Could not detect mudraw or ghostscript, so skipping PDF test')
controller.temp_folder = self.temp_folder_path
controller.thumbnail_folder = self.thumbnail_folder_path
document = PdfDocument(controller, test_file)
document = PdfDocument(controller, test_file_path)
loaded = document.load_presentation()
# THEN: The load should succeed and we should be able to get a pagecount
@ -119,7 +119,7 @@ class TestPdfController(TestCase, TestMixin):
Test loading of a Pdf and check size of generate pictures
"""
# GIVEN: A Pdf-file
test_file = Path(TEST_RESOURCES_PATH, 'presentations', 'pdf_test1.pdf')
test_file_path = RESOURCE_PATH / 'presentations' / 'pdf_test1.pdf'
# WHEN: The Pdf is loaded
controller = PdfController(plugin=self.mock_plugin)
@ -127,7 +127,7 @@ class TestPdfController(TestCase, TestMixin):
raise SkipTest('Could not detect mudraw or ghostscript, so skipping PDF test')
controller.temp_folder = self.temp_folder_path
controller.thumbnail_folder = self.thumbnail_folder_path
document = PdfDocument(controller, test_file)
document = PdfDocument(controller, test_file_path)
loaded = document.load_presentation()
# THEN: The load should succeed and pictures should be created and have been scales to fit the screen

View File

@ -32,7 +32,7 @@ from openlp.core.common import is_win
from openlp.core.common.path import Path
from tests.helpers.testmixin import TestMixin
from tests.utils.constants import TEST_RESOURCES_PATH
from tests.utils.constants import RESOURCE_PATH
class TestPptviewController(TestCase, TestMixin):
@ -172,7 +172,7 @@ class TestPptviewDocument(TestCase):
"""
# GIVEN: mocked PresentationController.save_titles_and_notes and a pptx file
doc = PptviewDocument(self.mock_controller, self.mock_presentation)
doc.file_path = Path(TEST_RESOURCES_PATH, 'presentations', 'test.pptx')
doc.file_path = RESOURCE_PATH / 'presentations' / 'test.pptx'
doc.save_titles_and_notes = MagicMock()
# WHEN reading the titles and notes
@ -216,7 +216,7 @@ class TestPptviewDocument(TestCase):
mocked_is_zf.return_value = False
mocked_open.filesize = 10
doc = PptviewDocument(self.mock_controller, self.mock_presentation)
doc.file_path = Path(TEST_RESOURCES_PATH, 'presentations', 'test.ppt')
doc.file_path = RESOURCE_PATH / 'presentations' / 'test.ppt'
doc.save_titles_and_notes = MagicMock()
# WHEN: reading the titles and notes

View File

@ -27,7 +27,7 @@ from unittest.mock import patch, MagicMock
from tests.helpers.songfileimport import SongImportTestHelper
from tests.utils.constants import RESOURCE_PATH
TEST_PATH = RESOURCE_PATH / 'chordprosongs'
TEST_PATH = RESOURCE_PATH / 'songs' / 'chordpro'
class TestChordProFileImport(SongImportTestHelper):

View File

@ -24,7 +24,7 @@ This module contains tests for the EasySlides song importer.
from tests.helpers.songfileimport import SongImportTestHelper
from tests.utils.constants import RESOURCE_PATH
TEST_PATH = RESOURCE_PATH / 'easyslidessongs'
TEST_PATH = RESOURCE_PATH / 'songs' / 'easyslides'
class TestEasySlidesFileImport(SongImportTestHelper):

View File

@ -31,7 +31,7 @@ from openlp.plugins.songs.lib.importers.easyworship import EasyWorshipSongImport
from tests.utils.constants import RESOURCE_PATH
TEST_PATH = RESOURCE_PATH / 'easyworshipsongs'
TEST_PATH = RESOURCE_PATH / 'songs' / 'easyworship'
SONG_TEST_DATA = [
{'title': 'Amazing Grace',
'authors': ['John Newton'],

View File

@ -24,7 +24,7 @@ This module contains tests for the LyriX song importer.
from tests.helpers.songfileimport import SongImportTestHelper
from tests.utils.constants import RESOURCE_PATH
TEST_PATH = RESOURCE_PATH / 'lyrixsongs'
TEST_PATH = RESOURCE_PATH / 'songs' / 'lyrix'
class TestLyrixFileImport(SongImportTestHelper):

View File

@ -37,7 +37,7 @@ from openlp.plugins.songs.lib.openlyricsxml import OpenLyrics
from tests.helpers.testmixin import TestMixin
from tests.utils.constants import RESOURCE_PATH
TEST_PATH = RESOURCE_PATH / 'openlyricssongs'
TEST_PATH = RESOURCE_PATH / 'songs' / 'openlyrics'
SONG_TEST_DATA = {
'What a friend we have in Jesus.xml': {
'title': 'What A Friend We Have In Jesus',

View File

@ -31,7 +31,7 @@ from openlp.plugins.songs.lib.importers.opensong import OpenSongImport
from tests.helpers.songfileimport import SongImportTestHelper
from tests.utils.constants import RESOURCE_PATH
TEST_PATH = RESOURCE_PATH / 'opensongsongs'
TEST_PATH = RESOURCE_PATH / 'songs' / 'opensong'
class TestOpenSongFileImport(SongImportTestHelper):

View File

@ -35,7 +35,7 @@ except ImportError:
from tests.utils import load_external_result_data
from tests.utils.constants import RESOURCE_PATH
TEST_PATH = RESOURCE_PATH / 'opsprosongs'
TEST_PATH = RESOURCE_PATH / 'songs' / 'opspro'
def _get_item(data, key):

View File

@ -26,7 +26,7 @@ ProPresenter song files into the current installation database.
from tests.helpers.songfileimport import SongImportTestHelper
from tests.utils.constants import RESOURCE_PATH
TEST_PATH = RESOURCE_PATH / 'powerpraisesongs'
TEST_PATH = RESOURCE_PATH / 'songs' / 'powerpraise'
class TestPowerPraiseFileImport(SongImportTestHelper):

View File

@ -25,7 +25,7 @@ This module contains tests for the PresentationManager song importer.
from tests.helpers.songfileimport import SongImportTestHelper
from tests.utils.constants import RESOURCE_PATH
TEST_PATH = RESOURCE_PATH / 'presentationmanagersongs'
TEST_PATH = RESOURCE_PATH / 'songs' / 'presentationmanager'
class TestPresentationManagerFileImport(SongImportTestHelper):

View File

@ -26,7 +26,7 @@ ProPresenter song files into the current installation database.
from tests.helpers.songfileimport import SongImportTestHelper
from tests.utils.constants import RESOURCE_PATH
TEST_PATH = RESOURCE_PATH / 'propresentersongs'
TEST_PATH = RESOURCE_PATH / 'songs' / 'propresenter'
class TestProPresenterFileImport(SongImportTestHelper):

View File

@ -31,7 +31,7 @@ from openlp.plugins.songs.lib.importers.songbeamer import SongBeamerImport, Song
from tests.helpers.songfileimport import SongImportTestHelper
from tests.utils.constants import RESOURCE_PATH
TEST_PATH = RESOURCE_PATH / 'songbeamersongs'
TEST_PATH = RESOURCE_PATH / 'songs' / 'songbeamersongs'
class TestSongBeamerFileImport(SongImportTestHelper):

View File

@ -26,7 +26,7 @@ SongPro song files into the current installation database.
from tests.helpers.songfileimport import SongImportTestHelper
from tests.utils.constants import RESOURCE_PATH
TEST_PATH = RESOURCE_PATH / 'songprosongs'
TEST_PATH = RESOURCE_PATH / 'songs' / 'songprosongs'
class TestSongProFileImport(SongImportTestHelper):

View File

@ -38,7 +38,7 @@ from tests.helpers.songfileimport import SongImportTestHelper
from tests.helpers.testmixin import TestMixin
from tests.utils.constants import RESOURCE_PATH
TEST_PATH = RESOURCE_PATH / 'songselect'
TEST_PATH = RESOURCE_PATH / 'songs' / 'songselect'
class TestSongSelectImport(TestCase, TestMixin):

View File

@ -31,7 +31,7 @@ from openlp.plugins.songs.lib.importers.songshowplus import SongShowPlusImport
from tests.helpers.songfileimport import SongImportTestHelper
from tests.utils.constants import RESOURCE_PATH
TEST_PATH = RESOURCE_PATH / 'songshowplussongs'
TEST_PATH = RESOURCE_PATH / 'songs' / 'songshowplus'
class TestSongShowPlusFileImport(SongImportTestHelper):

View File

@ -26,7 +26,7 @@ from unittest.mock import patch
from tests.helpers.songfileimport import SongImportTestHelper
from tests.utils.constants import RESOURCE_PATH
TEST_PATH = RESOURCE_PATH / 'sundayplussongs'
TEST_PATH = RESOURCE_PATH / 'songs' / 'sundayplus'
class TestSundayPlusFileImport(SongImportTestHelper):

View File

@ -26,7 +26,7 @@ from unittest.mock import patch, MagicMock
from tests.helpers.songfileimport import SongImportTestHelper
from tests.utils.constants import RESOURCE_PATH
TEST_PATH = RESOURCE_PATH / 'videopsalmsongs'
TEST_PATH = RESOURCE_PATH / 'songs' / 'videopsalm'
class TestVideoPsalmFileImport(SongImportTestHelper):

View File

@ -25,7 +25,7 @@ This module contains tests for the Words of Worship song importer.
from tests.helpers.songfileimport import SongImportTestHelper
from tests.utils.constants import RESOURCE_PATH
TEST_PATH = RESOURCE_PATH / 'wordsofworshipsongs'
TEST_PATH = RESOURCE_PATH / 'songs' / 'wordsofworship'
class TestWordsOfWorshipFileImport(SongImportTestHelper):

View File

@ -26,7 +26,7 @@ WorshipAssistant song files into the current installation database.
from tests.helpers.songfileimport import SongImportTestHelper
from tests.utils.constants import RESOURCE_PATH
TEST_PATH = RESOURCE_PATH / 'worshipassistantsongs'
TEST_PATH = RESOURCE_PATH / 'songs' / 'worshipassistant'
class TestWorshipAssistantFileImport(SongImportTestHelper):

View File

@ -32,7 +32,7 @@ from openlp.plugins.songs.lib.importers.zionworx import ZionWorxImport
from tests.helpers.songfileimport import SongImportTestHelper
from tests.utils.constants import RESOURCE_PATH
TEST_PATH = RESOURCE_PATH / 'zionworxsongs'
TEST_PATH = RESOURCE_PATH / 'songs' / 'zionworx'
class TestZionWorxImport(TestCase):

View File

@ -25,8 +25,8 @@ Functional tests to test the AppLocation class and related methods.
from unittest import TestCase
from openlp.core.common import is_not_image_file
from openlp.core.common.path import Path
from tests.utils.constants import TEST_RESOURCES_PATH
from tests.utils.constants import RESOURCE_PATH
from tests.helpers.testmixin import TestMixin
@ -59,10 +59,10 @@ class TestUtils(TestCase, TestMixin):
Test the method handles an image file
"""
# Given and empty string
file_name = Path(TEST_RESOURCES_PATH, 'church.jpg')
file_path = RESOURCE_PATH / 'church.jpg'
# WHEN testing for it
result = is_not_image_file(file_name)
result = is_not_image_file(file_path)
# THEN the result is false
assert result is False, 'The file is present so the test should return False'
@ -72,10 +72,10 @@ class TestUtils(TestCase, TestMixin):
Test the method handles a non image file
"""
# Given and empty string
file_name = Path(TEST_RESOURCES_PATH, 'serviceitem_custom_1.osj')
file_path = RESOURCE_PATH / 'serviceitem_custom_1.osj'
# WHEN testing for it
result = is_not_image_file(file_name)
result = is_not_image_file(file_path)
# THEN the result is false
assert result is True, 'The file is not an image file so the test should return True'