forked from openlp/openlp
trunk
This commit is contained in:
commit
1adeb175ae
@ -81,4 +81,4 @@ class OpenLPToolbar(QtGui.QToolBar):
|
||||
if handle in self.actions:
|
||||
self.actions[handle].setVisible(visible)
|
||||
else:
|
||||
log.warn('No handle "%s" in actions list.', str(handle))
|
||||
log.warning('No handle "%s" in actions list.', str(handle))
|
||||
|
@ -172,7 +172,7 @@ def create_button(parent, name, **kwargs):
|
||||
kwargs.setdefault('icon', ':/services/service_down.png')
|
||||
kwargs.setdefault('tooltip', translate('OpenLP.Ui', 'Move selection down one position.'))
|
||||
else:
|
||||
log.warn('The role "%s" is not defined in create_push_button().', role)
|
||||
log.warning('The role "%s" is not defined in create_push_button().', role)
|
||||
if kwargs.pop('btn_class', '') == 'toolbutton':
|
||||
button = QtGui.QToolButton(parent)
|
||||
else:
|
||||
@ -190,7 +190,7 @@ def create_button(parent, name, **kwargs):
|
||||
button.clicked.connect(kwargs.pop('click'))
|
||||
for key in list(kwargs.keys()):
|
||||
if key not in ['text', 'icon', 'tooltip', 'click']:
|
||||
log.warn('Parameter %s was not consumed in create_button().', key)
|
||||
log.warning('Parameter %s was not consumed in create_button().', key)
|
||||
return button
|
||||
|
||||
|
||||
@ -275,7 +275,7 @@ def create_action(parent, name, **kwargs):
|
||||
action.triggered.connect(kwargs.pop('triggers'))
|
||||
for key in list(kwargs.keys()):
|
||||
if key not in ['text', 'icon', 'tooltip', 'statustip', 'checked', 'can_shortcuts', 'category', 'triggers']:
|
||||
log.warn('Parameter %s was not consumed in create_action().' % key)
|
||||
log.warning('Parameter %s was not consumed in create_action().' % key)
|
||||
return action
|
||||
|
||||
|
||||
|
@ -175,7 +175,7 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
|
||||
# On some platforms importing vlc.py might cause
|
||||
# also OSError exceptions. (e.g. Mac OS X)
|
||||
except (ImportError, OSError):
|
||||
log.warn('Failed to import %s on path %s', module_name, path)
|
||||
log.warning('Failed to import %s on path %s', module_name, path)
|
||||
player_classes = MediaPlayer.__subclasses__()
|
||||
for player_class in player_classes:
|
||||
player = player_class(self)
|
||||
|
@ -993,7 +993,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage
|
||||
service_item.auto_play_slides_once = False
|
||||
self.set_modified()
|
||||
|
||||
def on_auto_start(self):
|
||||
def on_auto_start(self, field=None):
|
||||
"""
|
||||
Toggles to Auto Start Setting.
|
||||
"""
|
||||
|
@ -660,7 +660,7 @@ class ThemeManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ThemeManager, R
|
||||
finally:
|
||||
if out_file:
|
||||
out_file.close()
|
||||
if image_from and image_from != image_to:
|
||||
if image_from and os.path.abspath(image_from) != os.path.abspath(image_to):
|
||||
try:
|
||||
encoding = get_filesystem_encoding()
|
||||
shutil.copyfile(str(image_from).encode(encoding), str(image_to).encode(encoding))
|
||||
|
@ -279,8 +279,8 @@ class ActionList(object):
|
||||
actions.append(action)
|
||||
ActionList.shortcut_map[shortcuts[1]] = actions
|
||||
else:
|
||||
log.warn('Shortcut "%s" is removed from "%s" because another action already uses this shortcut.' %
|
||||
(shortcuts[1], action.objectName()))
|
||||
log.warning('Shortcut "%s" is removed from "%s" because another action already uses this shortcut.' %
|
||||
(shortcuts[1], action.objectName()))
|
||||
shortcuts.remove(shortcuts[1])
|
||||
# Check the primary shortcut.
|
||||
existing_actions = ActionList.shortcut_map.get(shortcuts[0], [])
|
||||
@ -290,8 +290,8 @@ class ActionList(object):
|
||||
actions.append(action)
|
||||
ActionList.shortcut_map[shortcuts[0]] = actions
|
||||
else:
|
||||
log.warn('Shortcut "%s" is removed from "%s" because another action already uses this shortcut.' %
|
||||
(shortcuts[0], action.objectName()))
|
||||
log.warning('Shortcut "%s" is removed from "%s" because another action already uses this shortcut.' %
|
||||
(shortcuts[0], action.objectName()))
|
||||
shortcuts.remove(shortcuts[0])
|
||||
action.setShortcuts([QtGui.QKeySequence(shortcut) for shortcut in shortcuts])
|
||||
|
||||
|
@ -423,7 +423,7 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
else:
|
||||
language_id = self.new_bibles[number].get_language(name)
|
||||
if not language_id:
|
||||
log.warn('Upgrading from "%s" failed' % filename[0])
|
||||
log.warning('Upgrading from "%s" failed' % filename[0])
|
||||
self.new_bibles[number].session.close()
|
||||
del self.new_bibles[number]
|
||||
self.increment_progress_bar(
|
||||
@ -444,7 +444,7 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
book_ref_id = self.new_bibles[number].\
|
||||
get_book_ref_id_by_name(book, len(books), language_id)
|
||||
if not book_ref_id:
|
||||
log.warn('Upgrading books from %s - download name: "%s" aborted by user' % (
|
||||
log.warning('Upgrading books from %s - download name: "%s" aborted by user' % (
|
||||
meta_data['download_source'], meta_data['download_name']))
|
||||
self.new_bibles[number].session.close()
|
||||
del self.new_bibles[number]
|
||||
@ -457,7 +457,7 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
if oldbook:
|
||||
verses = old_bible.get_verses(oldbook['id'])
|
||||
if not verses:
|
||||
log.warn('No verses found to import for book "%s"', book)
|
||||
log.warning('No verses found to import for book "%s"', book)
|
||||
continue
|
||||
for verse in verses:
|
||||
if self.stop_import_flag:
|
||||
@ -472,7 +472,7 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
if not language_id:
|
||||
language_id = self.new_bibles[number].get_language(name)
|
||||
if not language_id:
|
||||
log.warn('Upgrading books from "%s" failed' % name)
|
||||
log.warning('Upgrading books from "%s" failed' % name)
|
||||
self.new_bibles[number].session.close()
|
||||
del self.new_bibles[number]
|
||||
self.increment_progress_bar(
|
||||
@ -493,7 +493,7 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
(number + 1, max_bibles, name, book['name']))
|
||||
book_ref_id = self.new_bibles[number].get_book_ref_id_by_name(book['name'], len(books), language_id)
|
||||
if not book_ref_id:
|
||||
log.warn('Upgrading books from %s " failed - aborted by user' % name)
|
||||
log.warning('Upgrading books from %s " failed - aborted by user' % name)
|
||||
self.new_bibles[number].session.close()
|
||||
del self.new_bibles[number]
|
||||
self.success[number] = False
|
||||
@ -503,7 +503,7 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
book_details['testament_id'])
|
||||
verses = old_bible.get_verses(book['id'])
|
||||
if not verses:
|
||||
log.warn('No verses found to import for book "%s"', book['name'])
|
||||
log.warning('No verses found to import for book "%s"', book['name'])
|
||||
self.new_bibles[number].delete_book(db_book)
|
||||
continue
|
||||
for verse in verses:
|
||||
|
@ -164,7 +164,7 @@ class BGExtract(RegistryProperties):
|
||||
if len(verse_parts) > 1:
|
||||
verse = int(verse_parts[0])
|
||||
except TypeError:
|
||||
log.warn('Illegal verse number: %s', str(verse))
|
||||
log.warning('Illegal verse number: %s', str(verse))
|
||||
verses.append((verse, text))
|
||||
verse_list = {}
|
||||
for verse, text in verses[::-1]:
|
||||
@ -197,7 +197,7 @@ class BGExtract(RegistryProperties):
|
||||
if len(verse_parts) > 1:
|
||||
clean_verse_num = int(verse_parts[0])
|
||||
except TypeError:
|
||||
log.warn('Illegal verse number: %s', str(raw_verse_num))
|
||||
log.warning('Illegal verse number: %s', str(raw_verse_num))
|
||||
if clean_verse_num:
|
||||
verse_text = raw_verse_num.next_element
|
||||
part = raw_verse_num.next_element.next_element
|
||||
|
@ -123,7 +123,7 @@ class OpenSongBible(BibleDB):
|
||||
if len(verse_parts) > 1:
|
||||
number = int(verse_parts[0])
|
||||
except TypeError:
|
||||
log.warn('Illegal verse number: %s', str(verse.attrib['n']))
|
||||
log.warning('Illegal verse number: %s', str(verse.attrib['n']))
|
||||
verse_number = number
|
||||
else:
|
||||
verse_number += 1
|
||||
|
@ -129,7 +129,7 @@ class ImpressController(PresentationController):
|
||||
try:
|
||||
uno_instance = get_uno_instance(resolver)
|
||||
except:
|
||||
log.warn('Unable to find running instance ')
|
||||
log.warning('Unable to find running instance ')
|
||||
self.start_process()
|
||||
loop += 1
|
||||
try:
|
||||
@ -138,7 +138,7 @@ class ImpressController(PresentationController):
|
||||
desktop = self.manager.createInstanceWithContext("com.sun.star.frame.Desktop", uno_instance)
|
||||
return desktop
|
||||
except:
|
||||
log.warn('Failed to get UNO desktop')
|
||||
log.warning('Failed to get UNO desktop')
|
||||
return None
|
||||
|
||||
def get_com_desktop(self):
|
||||
@ -152,7 +152,7 @@ class ImpressController(PresentationController):
|
||||
try:
|
||||
desktop = self.manager.createInstance('com.sun.star.frame.Desktop')
|
||||
except (AttributeError, pywintypes.com_error):
|
||||
log.warn('Failure to find desktop - Impress may have closed')
|
||||
log.warning('Failure to find desktop - Impress may have closed')
|
||||
return desktop if desktop else None
|
||||
|
||||
def get_com_servicemanager(self):
|
||||
@ -163,7 +163,7 @@ class ImpressController(PresentationController):
|
||||
try:
|
||||
return Dispatch('com.sun.star.ServiceManager')
|
||||
except pywintypes.com_error:
|
||||
log.warn('Failed to get COM service manager. Impress Controller has been disabled')
|
||||
log.warning('Failed to get COM service manager. Impress Controller has been disabled')
|
||||
return None
|
||||
|
||||
def kill(self):
|
||||
@ -180,7 +180,7 @@ class ImpressController(PresentationController):
|
||||
else:
|
||||
desktop = self.get_com_desktop()
|
||||
except:
|
||||
log.warn('Failed to find an OpenOffice desktop to terminate')
|
||||
log.warning('Failed to find an OpenOffice desktop to terminate')
|
||||
if not desktop:
|
||||
return
|
||||
docs = desktop.getComponents()
|
||||
@ -198,7 +198,7 @@ class ImpressController(PresentationController):
|
||||
desktop.terminate()
|
||||
log.debug('OpenOffice killed')
|
||||
except:
|
||||
log.warn('Failed to terminate OpenOffice')
|
||||
log.warning('Failed to terminate OpenOffice')
|
||||
|
||||
|
||||
class ImpressDocument(PresentationDocument):
|
||||
@ -244,7 +244,7 @@ class ImpressDocument(PresentationDocument):
|
||||
try:
|
||||
self.document = desktop.loadComponentFromURL(url, '_blank', 0, properties)
|
||||
except:
|
||||
log.warn('Failed to load presentation %s' % url)
|
||||
log.warning('Failed to load presentation %s' % url)
|
||||
return False
|
||||
if os.name == 'nt':
|
||||
# As we can't start minimized the Impress window gets in the way.
|
||||
@ -318,7 +318,7 @@ class ImpressDocument(PresentationDocument):
|
||||
self.presentation = None
|
||||
self.document.dispose()
|
||||
except:
|
||||
log.warn("Closing presentation failed")
|
||||
log.warning("Closing presentation failed")
|
||||
self.document = None
|
||||
self.controller.remove_doc(self)
|
||||
|
||||
@ -335,7 +335,7 @@ class ImpressDocument(PresentationDocument):
|
||||
log.debug("getPresentation failed to find a presentation")
|
||||
return False
|
||||
except:
|
||||
log.warn("getPresentation failed to find a presentation")
|
||||
log.warning("getPresentation failed to find a presentation")
|
||||
return False
|
||||
return True
|
||||
|
||||
|
@ -98,7 +98,7 @@ class Controller(object):
|
||||
return True
|
||||
if not self.doc.is_loaded():
|
||||
if not self.doc.load_presentation():
|
||||
log.warn('Failed to activate %s' % self.doc.filepath)
|
||||
log.warning('Failed to activate %s' % self.doc.filepath)
|
||||
return False
|
||||
if self.is_live:
|
||||
self.doc.start_presentation()
|
||||
@ -109,7 +109,7 @@ class Controller(object):
|
||||
if self.doc.is_active():
|
||||
return True
|
||||
else:
|
||||
log.warn('Failed to activate %s' % self.doc.filepath)
|
||||
log.warning('Failed to activate %s' % self.doc.filepath)
|
||||
return False
|
||||
|
||||
def slide(self, slide):
|
||||
|
@ -90,7 +90,7 @@ class PresentationPlugin(Plugin):
|
||||
try:
|
||||
self.controllers[controller].start_process()
|
||||
except Exception:
|
||||
log.warn('Failed to start controller process')
|
||||
log.warning('Failed to start controller process')
|
||||
self.controllers[controller].available = False
|
||||
self.media_item.build_file_mask_string()
|
||||
|
||||
@ -134,7 +134,7 @@ class PresentationPlugin(Plugin):
|
||||
try:
|
||||
__import__(module_name, globals(), locals(), [])
|
||||
except ImportError:
|
||||
log.warn('Failed to import %s on path %s', module_name, path)
|
||||
log.warning('Failed to import %s on path %s', module_name, path)
|
||||
controller_classes = PresentationController.__subclasses__()
|
||||
for controller_class in controller_classes:
|
||||
controller = controller_class(self)
|
||||
|
@ -290,9 +290,9 @@ class SongFormat(object):
|
||||
},
|
||||
ProPresenter: {
|
||||
'class': ProPresenterImport,
|
||||
'name': 'ProPresenter',
|
||||
'name': 'ProPresenter 4',
|
||||
'prefix': 'proPresenter',
|
||||
'filter': '%s (*.pro4)' % translate('SongsPlugin.ImportWizardForm', 'ProPresenter Song Files')
|
||||
'filter': '%s (*.pro4)' % translate('SongsPlugin.ImportWizardForm', 'ProPresenter 4 Song Files')
|
||||
},
|
||||
SongBeamer: {
|
||||
'class': SongBeamerImport,
|
||||
|
@ -27,5 +27,5 @@
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
"""
|
||||
The :mod:`~openlp.plugins.songs.lib.import` module contains importers for the Songs plugin.
|
||||
The :mod:`~openlp.plugins.songs.lib.importers` module contains importers for the Songs plugin.
|
||||
"""
|
||||
|
@ -33,17 +33,20 @@ ProPresenter song files into the current installation database.
|
||||
|
||||
import os
|
||||
import base64
|
||||
import logging
|
||||
from lxml import objectify
|
||||
|
||||
from openlp.core.ui.wizard import WizardStrings
|
||||
from openlp.plugins.songs.lib import strip_rtf
|
||||
from .songimport import SongImport
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ProPresenterImport(SongImport):
|
||||
"""
|
||||
The :class:`ProPresenterImport` class provides OpenLP with the
|
||||
ability to import ProPresenter song files.
|
||||
ability to import ProPresenter 4 song files.
|
||||
"""
|
||||
def do_import(self):
|
||||
self.import_wizard.progress_bar.setMaximum(len(self.import_source))
|
||||
@ -52,11 +55,11 @@ class ProPresenterImport(SongImport):
|
||||
return
|
||||
self.import_wizard.increment_progress_bar(WizardStrings.ImportingType % os.path.basename(file_path))
|
||||
root = objectify.parse(open(file_path, 'rb')).getroot()
|
||||
self.process_song(root)
|
||||
self.process_song(root, file_path)
|
||||
|
||||
def process_song(self, root):
|
||||
def process_song(self, root, filename):
|
||||
self.set_defaults()
|
||||
self.title = root.get('CCLISongTitle')
|
||||
self.title = os.path.basename(filename).rstrip('.pro4')
|
||||
self.copyright = root.get('CCLICopyrightInfo')
|
||||
self.comments = root.get('notes')
|
||||
self.ccli_number = root.get('CCLILicenseNumber')
|
||||
@ -67,6 +70,9 @@ class ProPresenterImport(SongImport):
|
||||
count = 0
|
||||
for slide in root.slides.RVDisplaySlide:
|
||||
count += 1
|
||||
if not hasattr(slide.displayElements, 'RVTextElement'):
|
||||
log.debug('No text found, may be an image slide')
|
||||
continue
|
||||
RTFData = slide.displayElements.RVTextElement.get('RTFData')
|
||||
rtf = base64.standard_b64decode(RTFData)
|
||||
words, encoding = strip_rtf(rtf.decode())
|
||||
|
@ -152,7 +152,7 @@ class SongShowPlusImport(SongImport):
|
||||
if match:
|
||||
self.ccli_number = int(match.group())
|
||||
else:
|
||||
log.warn("Can't parse CCLI Number from string: %s" % self.decode(data))
|
||||
log.warning("Can't parse CCLI Number from string: %s" % self.decode(data))
|
||||
elif block_key == VERSE:
|
||||
self.add_verse(self.decode(data), "%s%s" % (VerseType.tags[VerseType.Verse], verse_no))
|
||||
elif block_key == CHORUS:
|
||||
|
@ -58,7 +58,7 @@ class WorshipCenterProImport(SongImport):
|
||||
try:
|
||||
conn = pyodbc.connect('DRIVER={Microsoft Access Driver (*.mdb)};DBQ=%s' % self.import_source)
|
||||
except (pyodbc.DatabaseError, pyodbc.IntegrityError, pyodbc.InternalError, pyodbc.OperationalError) as e:
|
||||
log.warn('Unable to connect the WorshipCenter Pro database %s. %s', self.import_source, str(e))
|
||||
log.warning('Unable to connect the WorshipCenter Pro database %s. %s', self.import_source, str(e))
|
||||
# Unfortunately no specific exception type
|
||||
self.log_error(self.import_source, translate('SongsPlugin.WorshipCenterProImport',
|
||||
'Unable to connect the WorshipCenter Pro database.'))
|
||||
|
@ -67,7 +67,8 @@ class OpenLPJobs(object):
|
||||
Branch_PEP = 'Branch-05a-Code_Analysis'
|
||||
Branch_Coverage = 'Branch-05b-Test_Coverage'
|
||||
|
||||
Jobs = [Branch_Pull, Branch_Functional, Branch_Interface, Branch_Windows_Functional, Branch_Windows_Interface, Branch_PEP, Branch_Coverage]
|
||||
Jobs = [Branch_Pull, Branch_Functional, Branch_Interface, Branch_Windows_Functional, Branch_Windows_Interface,
|
||||
Branch_PEP, Branch_Coverage]
|
||||
|
||||
|
||||
class Colour(object):
|
||||
|
@ -5,7 +5,7 @@ from unittest import TestCase
|
||||
|
||||
from openlp.core.common import UiStrings
|
||||
from openlp.core.lib.filedialog import FileDialog
|
||||
from tests.functional import MagicMock, patch
|
||||
from tests.functional import MagicMock, call, patch
|
||||
|
||||
|
||||
class TestFileDialog(TestCase):
|
||||
@ -65,11 +65,9 @@ class TestFileDialog(TestCase):
|
||||
|
||||
# THEN: os.path.exists should have been called with known args. QmessageBox.information should have been
|
||||
# called. The returned result should correlate with the input.
|
||||
self.mocked_os.path.exists.assert_callde_with('/Valid File')
|
||||
self.mocked_os.path.exists.assert_callde_with('/url%20encoded%20file%20%231')
|
||||
self.mocked_os.path.exists.assert_callde_with('/url encoded file #1')
|
||||
self.mocked_os.path.exists.assert_callde_with('/non-existing')
|
||||
self.mocked_os.path.exists.assert_callde_with('/non-existing')
|
||||
call_list = [call('/Valid File'), call('/url%20encoded%20file%20%231'), call('/url encoded file #1'),
|
||||
call('/non-existing'), call('/non-existing')]
|
||||
self.mocked_os.path.exists.assert_has_calls(call_list)
|
||||
self.mocked_qt_gui.QmessageBox.information.called_with(self.mocked_parent, UiStrings().FileNotFound,
|
||||
UiStrings().FileNotFoundMessage % '/non-existing')
|
||||
self.assertEqual(result, ['/Valid File', '/url encoded file #1'], 'The returned file list is incorrect')
|
||||
|
@ -31,7 +31,8 @@ Package to test the openlp.core.ui.slidecontroller package.
|
||||
"""
|
||||
from unittest import TestCase
|
||||
|
||||
from openlp.core.common import Registry
|
||||
from openlp.core.common import Registry, ThemeLevel
|
||||
from openlp.core.lib import ServiceItem, ServiceItemType, ItemCapabilities
|
||||
from openlp.core.ui import ServiceManager
|
||||
|
||||
from tests.interfaces import MagicMock, patch
|
||||
@ -89,3 +90,466 @@ class TestServiceManager(TestCase):
|
||||
self.assertEqual('txt' in service_manager.suffixes, True, 'The suffix txt should be in the list')
|
||||
self.assertEqual('ppt' in service_manager.suffixes, True, 'The suffix ppt should be in the list')
|
||||
self.assertEqual('pptx' in service_manager.suffixes, True, 'The suffix pptx should be in the list')
|
||||
|
||||
def build_context_menu_test(self):
|
||||
"""
|
||||
Test the creation of a context menu from a null service item.
|
||||
"""
|
||||
# GIVEN: A new service manager instance and a default service item.
|
||||
service_manager = ServiceManager(None)
|
||||
item = MagicMock()
|
||||
item.parent.return_value = False
|
||||
item.data.return_value = 0
|
||||
service_manager.service_manager_list = MagicMock()
|
||||
service_manager.service_manager_list.itemAt.return_value = item
|
||||
service_item = ServiceItem(None)
|
||||
service_manager.service_items.insert(1, {'service_item': service_item})
|
||||
service_manager.edit_action = MagicMock()
|
||||
service_manager.rename_action = MagicMock()
|
||||
service_manager.create_custom_action = MagicMock()
|
||||
service_manager.maintain_action = MagicMock()
|
||||
service_manager.notes_action = MagicMock()
|
||||
service_manager.time_action = MagicMock()
|
||||
service_manager.auto_start_action = MagicMock()
|
||||
service_manager.auto_play_slides_menu = MagicMock()
|
||||
service_manager.auto_play_slides_once = MagicMock()
|
||||
service_manager.auto_play_slides_loop = MagicMock()
|
||||
service_manager.timed_slide_interval = MagicMock()
|
||||
service_manager.theme_menu = MagicMock()
|
||||
service_manager.menu = MagicMock()
|
||||
# WHEN I define a context menu
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following calls should have occurred.
|
||||
self.assertEquals(service_manager.edit_action.setVisible.call_count, 1, 'Should have been called once')
|
||||
self.assertEquals(service_manager.rename_action.setVisible.call_count, 1, 'Should have been called once')
|
||||
self.assertEquals(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have been called once')
|
||||
self.assertEquals(service_manager.maintain_action.setVisible.call_count, 1, 'Should have been called once')
|
||||
self.assertEquals(service_manager.notes_action.setVisible.call_count, 1, 'Should have been called once')
|
||||
self.assertEquals(service_manager.time_action.setVisible.call_count, 1, 'Should have been called once')
|
||||
self.assertEquals(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have been called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have been called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.theme_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have been called once')
|
||||
|
||||
def build_song_context_menu_test(self):
|
||||
"""
|
||||
Test the creation of a context menu from service item of type text from Songs.
|
||||
"""
|
||||
# GIVEN: A new service manager instance and a default service item.
|
||||
mocked_renderer = MagicMock()
|
||||
mocked_renderer.theme_level = ThemeLevel.Song
|
||||
Registry().register('plugin_manager', MagicMock())
|
||||
Registry().register('renderer', mocked_renderer)
|
||||
service_manager = ServiceManager(None)
|
||||
item = MagicMock()
|
||||
item.parent.return_value = False
|
||||
item.data.return_value = 0
|
||||
service_manager.service_manager_list = MagicMock()
|
||||
service_manager.service_manager_list.itemAt.return_value = item
|
||||
service_item = ServiceItem(None)
|
||||
service_item.add_capability(ItemCapabilities.CanEdit)
|
||||
service_item.add_capability(ItemCapabilities.CanPreview)
|
||||
service_item.add_capability(ItemCapabilities.CanLoop)
|
||||
service_item.add_capability(ItemCapabilities.OnLoadUpdate)
|
||||
service_item.add_capability(ItemCapabilities.AddIfNewItem)
|
||||
service_item.add_capability(ItemCapabilities.CanSoftBreak)
|
||||
service_item.service_item_type = ServiceItemType.Text
|
||||
service_item.edit_id = 1
|
||||
service_item._display_frames.append(MagicMock())
|
||||
service_manager.service_items.insert(1, {'service_item': service_item})
|
||||
service_manager.edit_action = MagicMock()
|
||||
service_manager.rename_action = MagicMock()
|
||||
service_manager.create_custom_action = MagicMock()
|
||||
service_manager.maintain_action = MagicMock()
|
||||
service_manager.notes_action = MagicMock()
|
||||
service_manager.time_action = MagicMock()
|
||||
service_manager.auto_start_action = MagicMock()
|
||||
service_manager.auto_play_slides_menu = MagicMock()
|
||||
service_manager.auto_play_slides_once = MagicMock()
|
||||
service_manager.auto_play_slides_loop = MagicMock()
|
||||
service_manager.timed_slide_interval = MagicMock()
|
||||
service_manager.theme_menu = MagicMock()
|
||||
service_manager.menu = MagicMock()
|
||||
# WHEN I define a context menu
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following calls should have occurred.
|
||||
self.assertEquals(service_manager.edit_action.setVisible.call_count, 2, 'Should have be called twice')
|
||||
self.assertEquals(service_manager.rename_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.maintain_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.theme_menu.menuAction().setVisible.call_count, 2,
|
||||
'Should have be called twice')
|
||||
# THEN we add a 2nd display frame
|
||||
service_item._display_frames.append(MagicMock())
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following additional calls should have occurred.
|
||||
self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 2,
|
||||
'Should have be called twice')
|
||||
self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 1, 'Should have be called once')
|
||||
|
||||
def build_bible_context_menu_test(self):
|
||||
"""
|
||||
Test the creation of a context menu from service item of type text from Bibles.
|
||||
"""
|
||||
# GIVEN: A new service manager instance and a default service item.
|
||||
mocked_renderer = MagicMock()
|
||||
mocked_renderer.theme_level = ThemeLevel.Song
|
||||
Registry().register('plugin_manager', MagicMock())
|
||||
Registry().register('renderer', mocked_renderer)
|
||||
service_manager = ServiceManager(None)
|
||||
item = MagicMock()
|
||||
item.parent.return_value = False
|
||||
item.data.return_value = 0
|
||||
service_manager.service_manager_list = MagicMock()
|
||||
service_manager.service_manager_list.itemAt.return_value = item
|
||||
service_item = ServiceItem(None)
|
||||
service_item.add_capability(ItemCapabilities.NoLineBreaks)
|
||||
service_item.add_capability(ItemCapabilities.CanPreview)
|
||||
service_item.add_capability(ItemCapabilities.CanLoop)
|
||||
service_item.add_capability(ItemCapabilities.CanWordSplit)
|
||||
service_item.add_capability(ItemCapabilities.CanEditTitle)
|
||||
service_item.service_item_type = ServiceItemType.Text
|
||||
service_item.edit_id = 1
|
||||
service_item._display_frames.append(MagicMock())
|
||||
service_manager.service_items.insert(1, {'service_item': service_item})
|
||||
service_manager.edit_action = MagicMock()
|
||||
service_manager.rename_action = MagicMock()
|
||||
service_manager.create_custom_action = MagicMock()
|
||||
service_manager.maintain_action = MagicMock()
|
||||
service_manager.notes_action = MagicMock()
|
||||
service_manager.time_action = MagicMock()
|
||||
service_manager.auto_start_action = MagicMock()
|
||||
service_manager.auto_play_slides_menu = MagicMock()
|
||||
service_manager.auto_play_slides_once = MagicMock()
|
||||
service_manager.auto_play_slides_loop = MagicMock()
|
||||
service_manager.timed_slide_interval = MagicMock()
|
||||
service_manager.theme_menu = MagicMock()
|
||||
service_manager.menu = MagicMock()
|
||||
# WHEN I define a context menu
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following calls should have occurred.
|
||||
self.assertEquals(service_manager.edit_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.rename_action.setVisible.call_count, 2, 'Should have be called twice')
|
||||
self.assertEquals(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.maintain_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.theme_menu.menuAction().setVisible.call_count, 2,
|
||||
'Should have be called twice')
|
||||
# THEN we add a 2nd display frame
|
||||
service_item._display_frames.append(MagicMock())
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following additional calls should have occurred.
|
||||
self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 2,
|
||||
'Should have be called twice')
|
||||
self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 1, 'Should have be called once')
|
||||
|
||||
def build_custom_context_menu_test(self):
|
||||
"""
|
||||
Test the creation of a context menu from service item of type text from Custom.
|
||||
"""
|
||||
# GIVEN: A new service manager instance and a default service item.
|
||||
mocked_renderer = MagicMock()
|
||||
mocked_renderer.theme_level = ThemeLevel.Song
|
||||
Registry().register('plugin_manager', MagicMock())
|
||||
Registry().register('renderer', mocked_renderer)
|
||||
service_manager = ServiceManager(None)
|
||||
item = MagicMock()
|
||||
item.parent.return_value = False
|
||||
item.data.return_value = 0
|
||||
service_manager.service_manager_list = MagicMock()
|
||||
service_manager.service_manager_list.itemAt.return_value = item
|
||||
service_item = ServiceItem(None)
|
||||
service_item.add_capability(ItemCapabilities.CanEdit)
|
||||
service_item.add_capability(ItemCapabilities.CanPreview)
|
||||
service_item.add_capability(ItemCapabilities.CanLoop)
|
||||
service_item.add_capability(ItemCapabilities.CanSoftBreak)
|
||||
service_item.add_capability(ItemCapabilities.OnLoadUpdate)
|
||||
service_item.service_item_type = ServiceItemType.Text
|
||||
service_item.edit_id = 1
|
||||
service_item._display_frames.append(MagicMock())
|
||||
service_manager.service_items.insert(1, {'service_item': service_item})
|
||||
service_manager.edit_action = MagicMock()
|
||||
service_manager.rename_action = MagicMock()
|
||||
service_manager.create_custom_action = MagicMock()
|
||||
service_manager.maintain_action = MagicMock()
|
||||
service_manager.notes_action = MagicMock()
|
||||
service_manager.time_action = MagicMock()
|
||||
service_manager.auto_start_action = MagicMock()
|
||||
service_manager.auto_play_slides_menu = MagicMock()
|
||||
service_manager.auto_play_slides_once = MagicMock()
|
||||
service_manager.auto_play_slides_loop = MagicMock()
|
||||
service_manager.timed_slide_interval = MagicMock()
|
||||
service_manager.theme_menu = MagicMock()
|
||||
service_manager.menu = MagicMock()
|
||||
# WHEN I define a context menu
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following calls should have occurred.
|
||||
self.assertEquals(service_manager.edit_action.setVisible.call_count, 2, 'Should have be called twice')
|
||||
self.assertEquals(service_manager.rename_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.maintain_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.theme_menu.menuAction().setVisible.call_count, 2,
|
||||
'Should have be called twice')
|
||||
# THEN we add a 2nd display frame
|
||||
service_item._display_frames.append(MagicMock())
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following additional calls should have occurred.
|
||||
self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 2,
|
||||
'Should have be called twice')
|
||||
self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 1, 'Should have be called once')
|
||||
|
||||
def build_image_context_menu_test(self):
|
||||
"""
|
||||
Test the creation of a context menu from service item of type Image from Image.
|
||||
"""
|
||||
# GIVEN: A new service manager instance and a default service item.
|
||||
Registry().register('plugin_manager', MagicMock())
|
||||
Registry().register('renderer', MagicMock())
|
||||
service_manager = ServiceManager(None)
|
||||
item = MagicMock()
|
||||
item.parent.return_value = False
|
||||
item.data.return_value = 0
|
||||
service_manager.service_manager_list = MagicMock()
|
||||
service_manager.service_manager_list.itemAt.return_value = item
|
||||
service_item = ServiceItem(None)
|
||||
service_item.add_capability(ItemCapabilities.CanMaintain)
|
||||
service_item.add_capability(ItemCapabilities.CanPreview)
|
||||
service_item.add_capability(ItemCapabilities.CanLoop)
|
||||
service_item.add_capability(ItemCapabilities.CanAppend)
|
||||
service_item.add_capability(ItemCapabilities.CanEditTitle)
|
||||
service_item.service_item_type = ServiceItemType.Image
|
||||
service_item.edit_id = 1
|
||||
service_item._raw_frames.append(MagicMock())
|
||||
service_manager.service_items.insert(1, {'service_item': service_item})
|
||||
service_manager.edit_action = MagicMock()
|
||||
service_manager.rename_action = MagicMock()
|
||||
service_manager.create_custom_action = MagicMock()
|
||||
service_manager.maintain_action = MagicMock()
|
||||
service_manager.notes_action = MagicMock()
|
||||
service_manager.time_action = MagicMock()
|
||||
service_manager.auto_start_action = MagicMock()
|
||||
service_manager.auto_play_slides_menu = MagicMock()
|
||||
service_manager.auto_play_slides_once = MagicMock()
|
||||
service_manager.auto_play_slides_loop = MagicMock()
|
||||
service_manager.timed_slide_interval = MagicMock()
|
||||
service_manager.theme_menu = MagicMock()
|
||||
service_manager.menu = MagicMock()
|
||||
# WHEN I define a context menu
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following calls should have occurred.
|
||||
self.assertEquals(service_manager.edit_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.rename_action.setVisible.call_count, 2, 'Should have be called twice')
|
||||
self.assertEquals(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.maintain_action.setVisible.call_count, 2, 'Should have be called twice')
|
||||
self.assertEquals(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.theme_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
# THEN we add a 2nd display frame and regenerate the menu.
|
||||
service_item._raw_frames.append(MagicMock())
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following additional calls should have occurred.
|
||||
self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 2,
|
||||
'Should have be called twice')
|
||||
self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 1, 'Should have be called once')
|
||||
|
||||
def build_media_context_menu_test(self):
|
||||
"""
|
||||
Test the creation of a context menu from service item of type Command from Media.
|
||||
"""
|
||||
# GIVEN: A new service manager instance and a default service item.
|
||||
Registry().register('plugin_manager', MagicMock())
|
||||
Registry().register('renderer', MagicMock())
|
||||
service_manager = ServiceManager(None)
|
||||
item = MagicMock()
|
||||
item.parent.return_value = False
|
||||
item.data.return_value = 0
|
||||
service_manager.service_manager_list = MagicMock()
|
||||
service_manager.service_manager_list.itemAt.return_value = item
|
||||
service_item = ServiceItem(None)
|
||||
service_item.add_capability(ItemCapabilities.CanAutoStartForLive)
|
||||
service_item.add_capability(ItemCapabilities.CanEditTitle)
|
||||
service_item.add_capability(ItemCapabilities.RequiresMedia)
|
||||
service_item.service_item_type = ServiceItemType.Command
|
||||
service_item.edit_id = 1
|
||||
service_item._raw_frames.append(MagicMock())
|
||||
service_manager.service_items.insert(1, {'service_item': service_item})
|
||||
service_manager.edit_action = MagicMock()
|
||||
service_manager.rename_action = MagicMock()
|
||||
service_manager.create_custom_action = MagicMock()
|
||||
service_manager.maintain_action = MagicMock()
|
||||
service_manager.notes_action = MagicMock()
|
||||
service_manager.time_action = MagicMock()
|
||||
service_manager.auto_start_action = MagicMock()
|
||||
service_manager.auto_play_slides_menu = MagicMock()
|
||||
service_manager.auto_play_slides_once = MagicMock()
|
||||
service_manager.auto_play_slides_loop = MagicMock()
|
||||
service_manager.timed_slide_interval = MagicMock()
|
||||
service_manager.theme_menu = MagicMock()
|
||||
service_manager.menu = MagicMock()
|
||||
# WHEN I define a context menu
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following calls should have occurred.
|
||||
self.assertEquals(service_manager.edit_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.rename_action.setVisible.call_count, 2, 'Should have be called twice')
|
||||
self.assertEquals(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.maintain_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_start_action.setVisible.call_count, 2, 'Should have be called twice')
|
||||
self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.theme_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
# THEN I change the length of the media and regenerate the menu.
|
||||
service_item.set_media_length(5)
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following additional calls should have occurred.
|
||||
self.assertEquals(service_manager.time_action.setVisible.call_count, 3, 'Should have be called three times')
|
||||
|
||||
def build_presentation_pdf_context_menu_test(self):
|
||||
"""
|
||||
Test the creation of a context menu from service item of type Command with PDF from Presentation.
|
||||
"""
|
||||
# GIVEN: A new service manager instance and a default service item.
|
||||
Registry().register('plugin_manager', MagicMock())
|
||||
Registry().register('renderer', MagicMock())
|
||||
service_manager = ServiceManager(None)
|
||||
item = MagicMock()
|
||||
item.parent.return_value = False
|
||||
item.data.return_value = 0
|
||||
service_manager.service_manager_list = MagicMock()
|
||||
service_manager.service_manager_list.itemAt.return_value = item
|
||||
service_item = ServiceItem(None)
|
||||
service_item.add_capability(ItemCapabilities.CanMaintain)
|
||||
service_item.add_capability(ItemCapabilities.CanPreview)
|
||||
service_item.add_capability(ItemCapabilities.CanLoop)
|
||||
service_item.add_capability(ItemCapabilities.CanAppend)
|
||||
service_item.service_item_type = ServiceItemType.Command
|
||||
service_item.edit_id = 1
|
||||
service_item._raw_frames.append(MagicMock())
|
||||
service_manager.service_items.insert(1, {'service_item': service_item})
|
||||
service_manager.edit_action = MagicMock()
|
||||
service_manager.rename_action = MagicMock()
|
||||
service_manager.create_custom_action = MagicMock()
|
||||
service_manager.maintain_action = MagicMock()
|
||||
service_manager.notes_action = MagicMock()
|
||||
service_manager.time_action = MagicMock()
|
||||
service_manager.auto_start_action = MagicMock()
|
||||
service_manager.auto_play_slides_menu = MagicMock()
|
||||
service_manager.auto_play_slides_once = MagicMock()
|
||||
service_manager.auto_play_slides_loop = MagicMock()
|
||||
service_manager.timed_slide_interval = MagicMock()
|
||||
service_manager.theme_menu = MagicMock()
|
||||
service_manager.menu = MagicMock()
|
||||
# WHEN I define a context menu
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following calls should have occurred.
|
||||
self.assertEquals(service_manager.edit_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.rename_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.maintain_action.setVisible.call_count, 2, 'Should have be called twice')
|
||||
self.assertEquals(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.theme_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
|
||||
def build_presentation_non_pdf_context_menu_test(self):
|
||||
"""
|
||||
Test the creation of a context menu from service item of type Command with Impress from Presentation.
|
||||
"""
|
||||
# GIVEN: A new service manager instance and a default service item.
|
||||
Registry().register('plugin_manager', MagicMock())
|
||||
Registry().register('renderer', MagicMock())
|
||||
service_manager = ServiceManager(None)
|
||||
item = MagicMock()
|
||||
item.parent.return_value = False
|
||||
item.data.return_value = 0
|
||||
service_manager.service_manager_list = MagicMock()
|
||||
service_manager.service_manager_list.itemAt.return_value = item
|
||||
service_item = ServiceItem(None)
|
||||
service_item.add_capability(ItemCapabilities.ProvidesOwnDisplay)
|
||||
service_item.service_item_type = ServiceItemType.Command
|
||||
service_item.edit_id = 1
|
||||
service_item._raw_frames.append(MagicMock())
|
||||
service_manager.service_items.insert(1, {'service_item': service_item})
|
||||
service_manager.edit_action = MagicMock()
|
||||
service_manager.rename_action = MagicMock()
|
||||
service_manager.create_custom_action = MagicMock()
|
||||
service_manager.maintain_action = MagicMock()
|
||||
service_manager.notes_action = MagicMock()
|
||||
service_manager.time_action = MagicMock()
|
||||
service_manager.auto_start_action = MagicMock()
|
||||
service_manager.auto_play_slides_menu = MagicMock()
|
||||
service_manager.auto_play_slides_once = MagicMock()
|
||||
service_manager.auto_play_slides_loop = MagicMock()
|
||||
service_manager.timed_slide_interval = MagicMock()
|
||||
service_manager.theme_menu = MagicMock()
|
||||
service_manager.menu = MagicMock()
|
||||
# WHEN I define a context menu
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following calls should have occurred.
|
||||
self.assertEquals(service_manager.edit_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.rename_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.maintain_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.theme_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
|
@ -36,27 +36,101 @@ from unittest import TestCase
|
||||
from tests.interfaces import MagicMock
|
||||
|
||||
from openlp.core.ui import ThemeManager
|
||||
from openlp.core.common import Registry
|
||||
|
||||
RESOURCES_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'resources', 'themes'))
|
||||
from tests.utils.constants import TEST_RESOURCES_PATH
|
||||
from tests.interfaces import MagicMock, patch
|
||||
|
||||
|
||||
class TestThemeManager(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
Set up the tests
|
||||
"""
|
||||
Registry.create()
|
||||
|
||||
def export_theme_test(self):
|
||||
"""
|
||||
Test exporting a theme .
|
||||
"""
|
||||
# GIVEN: A new ThemeManager instance.
|
||||
theme_manager = ThemeManager()
|
||||
theme_manager.path = RESOURCES_PATH
|
||||
theme_manager.path = os.path.join(TEST_RESOURCES_PATH, 'themes')
|
||||
zipfile.ZipFile.__init__ = MagicMock()
|
||||
zipfile.ZipFile.__init__.return_value = None
|
||||
zipfile.ZipFile.write = MagicMock()
|
||||
|
||||
# WHEN: The theme is exported
|
||||
theme_manager._export_theme('/some/path', 'Default')
|
||||
theme_manager._export_theme(os.path.join('some', 'path'), 'Default')
|
||||
|
||||
# THEN: The zipfile should be created at the given path
|
||||
zipfile.ZipFile.__init__.assert_called_with('/some/path/Default.otz', 'w')
|
||||
zipfile.ZipFile.write.assert_called_with(os.path.join(RESOURCES_PATH, 'Default', 'Default.xml'),
|
||||
'Default/Default.xml')
|
||||
zipfile.ZipFile.__init__.assert_called_with(os.path.join('some', 'path', 'Default.otz'), 'w')
|
||||
zipfile.ZipFile.write.assert_called_with(os.path.join(TEST_RESOURCES_PATH, 'themes', 'Default', 'Default.xml'),
|
||||
os.path.join('Default', 'Default.xml'))
|
||||
|
||||
def initial_theme_manager_test(self):
|
||||
"""
|
||||
Test the instantiation of theme manager.
|
||||
"""
|
||||
# GIVEN: A new service manager instance.
|
||||
ThemeManager(None)
|
||||
|
||||
# WHEN: the default theme manager is built.
|
||||
# THEN: The the controller should be registered in the registry.
|
||||
self.assertIsNotNone(Registry().get('theme_manager'), 'The base theme manager should be registered')
|
||||
|
||||
def write_theme_same_image_test(self):
|
||||
"""
|
||||
Test that we don't try to overwrite a theme background image with itself
|
||||
"""
|
||||
# GIVEN: A new theme manager instance, with mocked builtins.open, shutil.copyfile,
|
||||
# theme, check_directory_exists and thememanager-attributes.
|
||||
with patch('builtins.open') as mocked_open, \
|
||||
patch('openlp.core.ui.thememanager.shutil.copyfile') as mocked_copyfile, \
|
||||
patch('openlp.core.ui.thememanager.check_directory_exists') as mocked_check_directory_exists:
|
||||
mocked_open.return_value = MagicMock()
|
||||
theme_manager = ThemeManager(None)
|
||||
theme_manager.old_background_image = None
|
||||
theme_manager.generate_and_save_image = MagicMock()
|
||||
theme_manager.path = ''
|
||||
mocked_theme = MagicMock()
|
||||
mocked_theme.theme_name = 'themename'
|
||||
mocked_theme.extract_formatted_xml = MagicMock()
|
||||
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 = os.path.join(TEST_RESOURCES_PATH, 'church.jpg')
|
||||
# Do replacement from end of string to avoid problems with path start
|
||||
file_name2 = file_name1[::-1].replace(os.sep, os.sep + os.sep, 2)[::-1]
|
||||
theme_manager._write_theme(mocked_theme, file_name1, file_name2)
|
||||
|
||||
# THEN: The mocked_copyfile should not have been called
|
||||
self.assertFalse(mocked_copyfile.called, 'shutil.copyfile should not be called')
|
||||
|
||||
def write_theme_diff_images_test(self):
|
||||
"""
|
||||
Test that we do overwrite a theme background image when a new is submitted
|
||||
"""
|
||||
# GIVEN: A new theme manager instance, with mocked builtins.open, shutil.copyfile,
|
||||
# theme, check_directory_exists and thememanager-attributes.
|
||||
with patch('builtins.open') as mocked_open, \
|
||||
patch('openlp.core.ui.thememanager.shutil.copyfile') as mocked_copyfile, \
|
||||
patch('openlp.core.ui.thememanager.check_directory_exists') as mocked_check_directory_exists:
|
||||
mocked_open.return_value = MagicMock()
|
||||
theme_manager = ThemeManager(None)
|
||||
theme_manager.old_background_image = None
|
||||
theme_manager.generate_and_save_image = MagicMock()
|
||||
theme_manager.path = ''
|
||||
mocked_theme = MagicMock()
|
||||
mocked_theme.theme_name = 'themename'
|
||||
mocked_theme.extract_formatted_xml = MagicMock()
|
||||
mocked_theme.extract_formatted_xml.return_value = 'fake_theme_xml'.encode()
|
||||
|
||||
# WHEN: Calling _write_theme with path to different images
|
||||
file_name1 = os.path.join(TEST_RESOURCES_PATH, 'church.jpg')
|
||||
file_name2 = os.path.join(TEST_RESOURCES_PATH, 'church2.jpg')
|
||||
theme_manager._write_theme(mocked_theme, file_name1, file_name2)
|
||||
|
||||
# THEN: The mocked_copyfile should not have been called
|
||||
self.assertTrue(mocked_copyfile.called, 'shutil.copyfile should be called')
|
||||
|
@ -50,7 +50,7 @@ class TestPowerPraiseFileImport(SongImportTestHelper):
|
||||
"""
|
||||
Test that loading a PowerPraise file works correctly
|
||||
"""
|
||||
self.file_import([os.path.join(TEST_PATH, 'Näher, mein Gott zu Dir.ppl')],
|
||||
self.load_external_result_data(os.path.join(TEST_PATH, 'Näher, mein Gott zu Dir.json')))
|
||||
self.file_import([os.path.join(TEST_PATH, 'Naher, mein Gott zu Dir.ppl')],
|
||||
self.load_external_result_data(os.path.join(TEST_PATH, 'Naher, mein Gott zu Dir.json')))
|
||||
self.file_import([os.path.join(TEST_PATH, 'You are so faithful.ppl')],
|
||||
self.load_external_result_data(os.path.join(TEST_PATH, 'You are so faithful.json')))
|
||||
|
@ -52,3 +52,5 @@ class TestProPresenterFileImport(SongImportTestHelper):
|
||||
"""
|
||||
self.file_import([os.path.join(TEST_PATH, 'Amazing Grace.pro4')],
|
||||
self.load_external_result_data(os.path.join(TEST_PATH, 'Amazing Grace.json')))
|
||||
self.file_import([os.path.join(TEST_PATH, 'Vaste Grond.pro4')],
|
||||
self.load_external_result_data(os.path.join(TEST_PATH, 'Vaste Grond.json')))
|
||||
|
34
tests/resources/propresentersongs/Vaste Grond.json
Normal file
34
tests/resources/propresentersongs/Vaste Grond.json
Normal file
@ -0,0 +1,34 @@
|
||||
{
|
||||
"title": "Vaste Grond",
|
||||
"verse_order_list": [],
|
||||
"verses": [
|
||||
[
|
||||
"God voor U is niets onmogelijk\nHoe ongelofelijk\nU heeft alles in de hand",
|
||||
"v1"
|
||||
],
|
||||
[
|
||||
"U bent God en trekt Uw eigen plan\nU bent voor niemand bang\nVoor niets en niemand bang",
|
||||
"v2"
|
||||
],
|
||||
[
|
||||
"U houd me vast en geeft me moed\nOm door te gaan als ik niet durf\nIk wil van U zijn",
|
||||
"v3"
|
||||
],
|
||||
[
|
||||
"U geeft me kracht, en bent de vaste grond\nwaarop ik stevig sta\nik wil van U zijn, voor altijd van U zijn\nO God.",
|
||||
"v4"
|
||||
],
|
||||
[
|
||||
"Grote God, U bent uitzonderlijk\nen ondoorgrondelijk\nU biedt Uw liefde aan",
|
||||
"v5"
|
||||
],
|
||||
[
|
||||
"Wie ben ik, dat U mij ziet staan\nen met mij om wilt gaan?\nIk kan U niet weerstaan",
|
||||
"v6"
|
||||
],
|
||||
[
|
||||
"Onweerstaanbaar,\nonweerstaanbare God",
|
||||
"v7"
|
||||
]
|
||||
]
|
||||
}
|
1
tests/resources/propresentersongs/Vaste Grond.pro4
Normal file
1
tests/resources/propresentersongs/Vaste Grond.pro4
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user