forked from openlp/openlp
Head
This commit is contained in:
commit
bfbfcd5b15
@ -87,10 +87,11 @@ def upgrade_db(url, upgrade):
|
||||
"""
|
||||
pass
|
||||
|
||||
metadata_table = Table('metadata', metadata,
|
||||
Column('key', types.Unicode(64), primary_key=True),
|
||||
Column('value', types.UnicodeText(), default=None)
|
||||
)
|
||||
metadata_table = Table(
|
||||
'metadata', metadata,
|
||||
Column('key', types.Unicode(64), primary_key=True),
|
||||
Column('value', types.UnicodeText(), default=None)
|
||||
)
|
||||
metadata_table.create(checkfirst=True)
|
||||
mapper(Metadata, metadata_table)
|
||||
version_meta = session.query(Metadata).get('version')
|
||||
@ -131,7 +132,6 @@ def delete_database(plugin_name, db_file_name=None):
|
||||
:param plugin_name: The name of the plugin to remove the database for
|
||||
:param db_file_name: The database file name. Defaults to None resulting in the plugin_name being used.
|
||||
"""
|
||||
db_file_path = None
|
||||
if db_file_name:
|
||||
db_file_path = os.path.join(AppLocation.get_section_data_path(plugin_name), db_file_name)
|
||||
else:
|
||||
|
@ -74,11 +74,13 @@ def create_button_box(dialog, name, standard_buttons, custom_buttons=None):
|
||||
:param name: A string which is set as object name.
|
||||
:param standard_buttons: A list of strings for the used buttons. It might contain: ``ok``, ``save``, ``cancel``,
|
||||
``close``, and ``defaults``.
|
||||
:param custom_buttons: A list of additional buttons. If a item is a instance of QtGui.QAbstractButton it is added
|
||||
with QDialogButtonBox.ActionRole. Other wise the item has to be a tuple of a button and a ButtonRole.
|
||||
:param custom_buttons: A list of additional buttons. If an item is an instance of QtGui.QAbstractButton it is added
|
||||
with QDialogButtonBox.ActionRole. Otherwise the item has to be a tuple of a Button and a ButtonRole.
|
||||
"""
|
||||
if custom_buttons is None:
|
||||
custom_buttons = []
|
||||
if standard_buttons is None:
|
||||
standard_buttons = []
|
||||
buttons = QtGui.QDialogButtonBox.NoButton
|
||||
if 'ok' in standard_buttons:
|
||||
buttons |= QtGui.QDialogButtonBox.Ok
|
||||
|
@ -471,7 +471,7 @@ class SlideController(DisplayController, RegistryProperties):
|
||||
category=self.category,
|
||||
triggers=self.live_escape)
|
||||
|
||||
def live_escape(self):
|
||||
def live_escape(self, field=None):
|
||||
"""
|
||||
If you press ESC on the live screen it should close the display temporarily.
|
||||
"""
|
||||
@ -1243,7 +1243,7 @@ class SlideController(DisplayController, RegistryProperties):
|
||||
if self.service_item:
|
||||
self.service_manager.add_service_item(self.service_item)
|
||||
|
||||
def on_go_live_click(self):
|
||||
def on_go_live_click(self, field=None):
|
||||
"""
|
||||
triggered by clicking the Preview slide items
|
||||
"""
|
||||
@ -1256,7 +1256,7 @@ class SlideController(DisplayController, RegistryProperties):
|
||||
self.on_media_close()
|
||||
self.on_go_live()
|
||||
|
||||
def on_go_live(self):
|
||||
def on_go_live(self, field=None):
|
||||
"""
|
||||
If preview copy slide item to live controller from Preview Controller
|
||||
"""
|
||||
|
@ -31,10 +31,8 @@ The :mod:`upgrade` module provides a way for the database and schema that is the
|
||||
"""
|
||||
import logging
|
||||
|
||||
from sqlalchemy import Table, func, select, insert
|
||||
|
||||
__version__ = 1
|
||||
log = logging.getLogger(__name__)
|
||||
__version__ = 1
|
||||
|
||||
|
||||
def upgrade_1(session, metadata):
|
||||
@ -43,136 +41,4 @@ def upgrade_1(session, metadata):
|
||||
|
||||
This upgrade renames a number of keys to a single naming convention.
|
||||
"""
|
||||
metadata_table = Table('metadata', metadata, autoload=True)
|
||||
# Copy "Version" to "name" ("version" used by upgrade system)
|
||||
# TODO: Clean up in a subsequent release of OpenLP (like 2.0 final)
|
||||
session.execute(insert(metadata_table).values(
|
||||
key='name',
|
||||
value=select(
|
||||
[metadata_table.c.value],
|
||||
metadata_table.c.key == 'Version'
|
||||
).as_scalar()
|
||||
))
|
||||
# Copy "Copyright" to "copyright"
|
||||
# TODO: Clean up in a subsequent release of OpenLP (like 2.0 final)
|
||||
session.execute(insert(metadata_table).values(
|
||||
key='copyright',
|
||||
value=select(
|
||||
[metadata_table.c.value],
|
||||
metadata_table.c.key == 'Copyright'
|
||||
).as_scalar()
|
||||
))
|
||||
# Copy "Permissions" to "permissions"
|
||||
# TODO: Clean up in a subsequent release of OpenLP (like 2.0 final)
|
||||
session.execute(insert(metadata_table).values(
|
||||
key='permissions',
|
||||
value=select(
|
||||
[metadata_table.c.value],
|
||||
metadata_table.c.key == 'Permissions'
|
||||
).as_scalar()
|
||||
))
|
||||
# Copy "Bookname language" to "book_name_language"
|
||||
# TODO: Clean up in a subsequent release of OpenLP (like 2.0 final)
|
||||
value_count = session.execute(
|
||||
select(
|
||||
[func.count(metadata_table.c.value)],
|
||||
metadata_table.c.key == 'Bookname language'
|
||||
)
|
||||
).scalar()
|
||||
if value_count > 0:
|
||||
session.execute(insert(metadata_table).values(
|
||||
key='book_name_language',
|
||||
value=select(
|
||||
[metadata_table.c.value],
|
||||
metadata_table.c.key == 'Bookname language'
|
||||
).as_scalar()
|
||||
))
|
||||
# Copy "download source" to "download_source"
|
||||
# TODO: Clean up in a subsequent release of OpenLP (like 2.0 final)
|
||||
value_count = session.execute(
|
||||
select(
|
||||
[func.count(metadata_table.c.value)],
|
||||
metadata_table.c.key == 'download source'
|
||||
)
|
||||
).scalar()
|
||||
log.debug('download source: %s', value_count)
|
||||
if value_count > 0:
|
||||
session.execute(insert(metadata_table).values(
|
||||
key='download_source',
|
||||
value=select(
|
||||
[metadata_table.c.value],
|
||||
metadata_table.c.key == 'download source'
|
||||
).as_scalar()
|
||||
))
|
||||
# Copy "download name" to "download_name"
|
||||
# TODO: Clean up in a subsequent release of OpenLP (like 2.0 final)
|
||||
value_count = session.execute(
|
||||
select(
|
||||
[func.count(metadata_table.c.value)],
|
||||
metadata_table.c.key == 'download name'
|
||||
)
|
||||
).scalar()
|
||||
log.debug('download name: %s', value_count)
|
||||
if value_count > 0:
|
||||
session.execute(insert(metadata_table).values(
|
||||
key='download_name',
|
||||
value=select(
|
||||
[metadata_table.c.value],
|
||||
metadata_table.c.key == 'download name'
|
||||
).as_scalar()
|
||||
))
|
||||
# Copy "proxy server" to "proxy_server"
|
||||
# TODO: Clean up in a subsequent release of OpenLP (like 2.0 final)
|
||||
value_count = session.execute(
|
||||
select(
|
||||
[func.count(metadata_table.c.value)],
|
||||
metadata_table.c.key == 'proxy server'
|
||||
)
|
||||
).scalar()
|
||||
log.debug('proxy server: %s', value_count)
|
||||
if value_count > 0:
|
||||
session.execute(insert(metadata_table).values(
|
||||
key='proxy_server',
|
||||
value=select(
|
||||
[metadata_table.c.value],
|
||||
metadata_table.c.key == 'proxy server'
|
||||
).as_scalar()
|
||||
))
|
||||
# Copy "proxy username" to "proxy_username"
|
||||
# TODO: Clean up in a subsequent release of OpenLP (like 2.0 final)
|
||||
value_count = session.execute(
|
||||
select(
|
||||
[func.count(metadata_table.c.value)],
|
||||
metadata_table.c.key == 'proxy username'
|
||||
)
|
||||
).scalar()
|
||||
log.debug('proxy username: %s', value_count)
|
||||
if value_count > 0:
|
||||
session.execute(insert(metadata_table).values(
|
||||
key='proxy_username',
|
||||
value=select(
|
||||
[metadata_table.c.value],
|
||||
metadata_table.c.key == 'proxy username'
|
||||
).as_scalar()
|
||||
))
|
||||
# Copy "proxy password" to "proxy_password"
|
||||
# TODO: Clean up in a subsequent release of OpenLP (like 2.0 final)
|
||||
value_count = session.execute(
|
||||
select(
|
||||
[func.count(metadata_table.c.value)],
|
||||
metadata_table.c.key == 'proxy password'
|
||||
)
|
||||
).scalar()
|
||||
log.debug('proxy password: %s', value_count)
|
||||
if value_count > 0:
|
||||
session.execute(insert(metadata_table).values(
|
||||
key='proxy_password',
|
||||
value=select(
|
||||
[metadata_table.c.value],
|
||||
metadata_table.c.key == 'proxy password'
|
||||
).as_scalar()
|
||||
))
|
||||
# TODO: Clean up in a subsequent release of OpenLP (like 2.0 final)
|
||||
#session.execute(delete(metadata_table)\
|
||||
# .where(metadata_table.c.key == u'dbversion'))
|
||||
session.commit()
|
||||
log.info('No upgrades to perform')
|
||||
|
@ -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):
|
||||
"""
|
||||
|
@ -30,12 +30,15 @@
|
||||
The :mod:`upgrade` module provides a way for the database and schema that is the
|
||||
backend for the Songs plugin
|
||||
"""
|
||||
import logging
|
||||
|
||||
from sqlalchemy import Column, types
|
||||
from sqlalchemy.exc import OperationalError
|
||||
from sqlalchemy.sql.expression import func, false, null, text
|
||||
|
||||
from openlp.core.lib.db import get_upgrade_op
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
__version__ = 3
|
||||
|
||||
|
||||
@ -50,14 +53,20 @@ def upgrade_1(session, metadata):
|
||||
In order to facilitate this one-to-many relationship, a song_id column is
|
||||
added to the media_files table, and a weight column so that the media
|
||||
files can be ordered.
|
||||
|
||||
:param session:
|
||||
:param metadata:
|
||||
"""
|
||||
op = get_upgrade_op(session)
|
||||
op.drop_table('media_files_songs')
|
||||
op.add_column('media_files', Column('song_id', types.Integer(), server_default=null()))
|
||||
op.add_column('media_files', Column('weight', types.Integer(), server_default=text('0')))
|
||||
if metadata.bind.url.get_dialect().name != 'sqlite':
|
||||
# SQLite doesn't support ALTER TABLE ADD CONSTRAINT
|
||||
op.create_foreign_key('fk_media_files_song_id', 'media_files', 'songs', ['song_id', 'id'])
|
||||
try:
|
||||
op = get_upgrade_op(session)
|
||||
op.drop_table('media_files_songs')
|
||||
op.add_column('media_files', Column('song_id', types.Integer(), server_default=null()))
|
||||
op.add_column('media_files', Column('weight', types.Integer(), server_default=text('0')))
|
||||
if metadata.bind.url.get_dialect().name != 'sqlite':
|
||||
# SQLite doesn't support ALTER TABLE ADD CONSTRAINT
|
||||
op.create_foreign_key('fk_media_files_song_id', 'media_files', 'songs', ['song_id', 'id'])
|
||||
except OperationalError:
|
||||
log.info('Upgrade 1 has already been run')
|
||||
|
||||
|
||||
def upgrade_2(session, metadata):
|
||||
@ -66,9 +75,12 @@ def upgrade_2(session, metadata):
|
||||
|
||||
This upgrade adds a create_date and last_modified date to the songs table
|
||||
"""
|
||||
op = get_upgrade_op(session)
|
||||
op.add_column('songs', Column('create_date', types.DateTime(), default=func.now()))
|
||||
op.add_column('songs', Column('last_modified', types.DateTime(), default=func.now()))
|
||||
try:
|
||||
op = get_upgrade_op(session)
|
||||
op.add_column('songs', Column('create_date', types.DateTime(), default=func.now()))
|
||||
op.add_column('songs', Column('last_modified', types.DateTime(), default=func.now()))
|
||||
except OperationalError:
|
||||
log.info('Upgrade 2 has already been run')
|
||||
|
||||
|
||||
def upgrade_3(session, metadata):
|
||||
@ -77,8 +89,11 @@ def upgrade_3(session, metadata):
|
||||
|
||||
This upgrade adds a temporary song flag to the songs table
|
||||
"""
|
||||
op = get_upgrade_op(session)
|
||||
if metadata.bind.url.get_dialect().name == 'sqlite':
|
||||
op.add_column('songs', Column('temporary', types.Boolean(create_constraint=False), server_default=false()))
|
||||
else:
|
||||
op.add_column('songs', Column('temporary', types.Boolean(), server_default=false()))
|
||||
try:
|
||||
op = get_upgrade_op(session)
|
||||
if metadata.bind.url.get_dialect().name == 'sqlite':
|
||||
op.add_column('songs', Column('temporary', types.Boolean(create_constraint=False), server_default=false()))
|
||||
else:
|
||||
op.add_column('songs', Column('temporary', types.Boolean(), server_default=false()))
|
||||
except OperationalError:
|
||||
log.info('Upgrade 3 has already been run')
|
||||
|
@ -30,10 +30,14 @@
|
||||
The :mod:`upgrade` module provides a way for the database and schema that is the
|
||||
backend for the SongsUsage plugin
|
||||
"""
|
||||
from openlp.core.lib.db import get_upgrade_op
|
||||
import logging
|
||||
|
||||
from sqlalchemy.exc import OperationalError
|
||||
from sqlalchemy import Column, types
|
||||
|
||||
from openlp.core.lib.db import get_upgrade_op
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
__version__ = 1
|
||||
|
||||
|
||||
@ -42,7 +46,13 @@ def upgrade_1(session, metadata):
|
||||
Version 1 upgrade.
|
||||
|
||||
This upgrade adds two new fields to the songusage database
|
||||
|
||||
:param session: SQLAlchemy Session object
|
||||
:param metadata: SQLAlchemy MetaData object
|
||||
"""
|
||||
op = get_upgrade_op(session)
|
||||
op.add_column('songusage_data', Column('plugin_name', types.Unicode(20), server_default=''))
|
||||
op.add_column('songusage_data', Column('source', types.Unicode(10), server_default=''))
|
||||
try:
|
||||
op = get_upgrade_op(session)
|
||||
op.add_column('songusage_data', Column('plugin_name', types.Unicode(20), server_default=''))
|
||||
op.add_column('songusage_data', Column('source', types.Unicode(10), server_default=''))
|
||||
except OperationalError:
|
||||
log.info('Upgrade 1 has already taken place')
|
||||
|
@ -29,13 +29,14 @@
|
||||
"""
|
||||
Package to test the openlp.core.lib package.
|
||||
"""
|
||||
import os
|
||||
from unittest import TestCase
|
||||
|
||||
from sqlalchemy.pool import NullPool
|
||||
from sqlalchemy.orm.scoping import ScopedSession
|
||||
from sqlalchemy import MetaData
|
||||
|
||||
from openlp.core.lib.db import init_db, get_upgrade_op
|
||||
from openlp.core.lib.db import init_db, get_upgrade_op, delete_database
|
||||
from tests.functional import patch, MagicMock
|
||||
|
||||
|
||||
@ -110,3 +111,44 @@ class TestDB(TestCase):
|
||||
mocked_session.bind.connect.assert_called_with()
|
||||
MockedMigrationContext.configure.assert_called_with(mocked_connection)
|
||||
MockedOperations.assert_called_with(mocked_context)
|
||||
|
||||
def delete_database_without_db_file_name_test(self):
|
||||
"""
|
||||
Test that the ``delete_database`` function removes a database file, without the file name parameter
|
||||
"""
|
||||
# GIVEN: Mocked out AppLocation class and delete_file method, a test plugin name and a db location
|
||||
with patch('openlp.core.lib.db.AppLocation') as MockedAppLocation, \
|
||||
patch('openlp.core.lib.db.delete_file') as mocked_delete_file:
|
||||
MockedAppLocation.get_section_data_path.return_value = 'test-dir'
|
||||
mocked_delete_file.return_value = True
|
||||
test_plugin = 'test'
|
||||
test_location = os.path.join('test-dir', test_plugin)
|
||||
|
||||
# WHEN: delete_database is run without a database file
|
||||
result = delete_database(test_plugin)
|
||||
|
||||
# THEN: The AppLocation.get_section_data_path and delete_file methods should have been called
|
||||
MockedAppLocation.get_section_data_path.assert_called_with(test_plugin)
|
||||
mocked_delete_file.assert_called_with(test_location)
|
||||
self.assertTrue(result, 'The result of delete_file should be True (was rigged that way)')
|
||||
|
||||
def delete_database_with_db_file_name_test(self):
|
||||
"""
|
||||
Test that the ``delete_database`` function removes a database file, with the file name supplied
|
||||
"""
|
||||
# GIVEN: Mocked out AppLocation class and delete_file method, a test plugin name and a db location
|
||||
with patch('openlp.core.lib.db.AppLocation') as MockedAppLocation, \
|
||||
patch('openlp.core.lib.db.delete_file') as mocked_delete_file:
|
||||
MockedAppLocation.get_section_data_path.return_value = 'test-dir'
|
||||
mocked_delete_file.return_value = False
|
||||
test_plugin = 'test'
|
||||
test_db_file = 'mydb.sqlite'
|
||||
test_location = os.path.join('test-dir', test_db_file)
|
||||
|
||||
# WHEN: delete_database is run without a database file
|
||||
result = delete_database(test_plugin, test_db_file)
|
||||
|
||||
# THEN: The AppLocation.get_section_data_path and delete_file methods should have been called
|
||||
MockedAppLocation.get_section_data_path.assert_called_with(test_plugin)
|
||||
mocked_delete_file.assert_called_with(test_location)
|
||||
self.assertFalse(result, 'The result of delete_file should be False (was rigged that way)')
|
||||
|
@ -53,3 +53,31 @@ class TestUi(TestCase):
|
||||
# THEN: The wizard should have one page with a pixmap.
|
||||
self.assertEqual(1, len(wizard.pageIds()), 'The wizard should have one page.')
|
||||
self.assertIsInstance(wizard.page(0).pixmap(QtGui.QWizard.WatermarkPixmap), QtGui.QPixmap)
|
||||
|
||||
def test_create_button_box(self):
|
||||
"""
|
||||
Test creating a button box for a dialog
|
||||
"""
|
||||
# GIVEN: A dialog
|
||||
dialog = QtGui.QDialog()
|
||||
|
||||
# WHEN: We create the button box with five buttons
|
||||
btnbox = create_button_box(dialog, 'my_btns', ['ok', 'save', 'cancel', 'close', 'defaults'])
|
||||
|
||||
# THEN: We should get a QDialogButtonBox with five buttons
|
||||
self.assertIsInstance(btnbox, QtGui.QDialogButtonBox)
|
||||
self.assertEqual(5, len(btnbox.buttons()))
|
||||
|
||||
# WHEN: We create the button box with a custom button
|
||||
btnbox = create_button_box(dialog, 'my_btns', None, [QtGui.QPushButton('Custom')])
|
||||
# THEN: We should get a QDialogButtonBox with one button
|
||||
self.assertIsInstance(btnbox, QtGui.QDialogButtonBox)
|
||||
self.assertEqual(1, len(btnbox.buttons()))
|
||||
|
||||
# WHEN: We create the button box with a custom button and a custom role
|
||||
btnbox = create_button_box(dialog, 'my_btns', None,
|
||||
[(QtGui.QPushButton('Help'), QtGui.QDialogButtonBox.HelpRole)])
|
||||
# THEN: We should get a QDialogButtonBox with one button with a certain role
|
||||
self.assertIsInstance(btnbox, QtGui.QDialogButtonBox)
|
||||
self.assertEqual(1, len(btnbox.buttons()))
|
||||
self.assertEqual(QtGui.QDialogButtonBox.HelpRole, btnbox.buttonRole(btnbox.buttons()[0]))
|
||||
|
@ -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