diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 9498337d9..2504520c0 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -175,7 +175,7 @@ class MainDisplay(Display): We need to rebuild the CSS on the live display. """ for plugin in self.plugin_manager.plugins: - plugin.refreshCss(self.frame) + plugin.refresh_css(self.frame) def retranslateUi(self): """ diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 6bcad24c9..642f1543b 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -650,7 +650,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): for plugin in self.plugin_manager.plugins: self.activePlugin = plugin oldStatus = self.activePlugin.status - self.activePlugin.setStatus() + self.activePlugin.set_status() if oldStatus != self.activePlugin.status: if self.activePlugin.status == PluginStatus.Active: self.activePlugin.toggle_status(PluginStatus.Active) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 7be147b8a..0ac711492 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -84,9 +84,8 @@ class ServiceManagerList(QtGui.QTreeWidget): def mouseMoveEvent(self, event): """ - Drag and drop event does not care what data is selected - as the recipient will use events to request the data move - just tell it what plugin to call + Drag and drop event does not care what data is selected as the recipient will use events to request the data + move just tell it what plugin to call """ if event.buttons() != QtCore.Qt.LeftButton: event.ignore() @@ -284,10 +283,9 @@ class ServiceManagerDialog(object): class ServiceManager(QtGui.QWidget, ServiceManagerDialog): """ - Manages the services. This involves taking text strings from plugins and - adding them to the service. This service can then be zipped up with all - the resources used into one OSZ or oszl file for use on any OpenLP v2 - installation. Also handles the UI tasks of moving things up and down etc. + Manages the services. This involves taking text strings from plugins and adding them to the service. This service + can then be zipped up with all the resources used into one OSZ or oszl file for use on any OpenLP v2 installation. + Also handles the UI tasks of moving things up and down etc. """ def __init__(self, parent=None): """ @@ -316,8 +314,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): def set_modified(self, modified=True): """ - Setter for property "modified". Sets whether or not the current service - has been modified. + Setter for property "modified". Sets whether or not the current service has been modified. """ if modified: self.service_id += 1 @@ -361,7 +358,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): def supported_suffixes(self, suffix): """ - Adds Suffixes supported to the master list. Called from Plugins. + Adds Suffixes supported to the master list. Called from Plugins. ``suffix`` New Suffix to be supported @@ -384,12 +381,10 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): def on_load_service_clicked(self, load_file=None): """ - Loads the service file and saves the existing one it there is one - unchanged + Loads the service file and saves the existing one it there is one unchanged. ``load_file`` - The service file to the loaded. Will be None is from menu so - selection will be required. + The service file to the loaded. Will be None is from menu so selection will be required. """ if self.is_modified(): result = self.save_modified_service() @@ -445,10 +440,9 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): """ Save the current service file. - A temporary file is created so that we don't overwrite the existing one - and leave a mangled service file should there be an error when saving. - Audio files are also copied into the service manager directory, and - then packaged into the zip file. + A temporary file is created so that we don't overwrite the existing one and leave a mangled service file should + there be an error when saving. Audio files are also copied into the service manager directory, and then packaged + into the zip file. """ if not self.file_name(): return self.save_file_as() @@ -514,8 +508,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): total_size += file_size log.debug(u'ServiceManager.save_file - ZIP contents size is %i bytes' % total_size) service_content = cPickle.dumps(service) - # Usual Zip file cannot exceed 2GiB, file with Zip64 cannot be - # extracted using unzip in UNIX. + # Usual Zip file cannot exceed 2GiB, file with Zip64 cannot be extracted using unzip in UNIX. allow_zip_64 = (total_size > 2147483648 + len(service_content)) log.debug(u'ServiceManager.save_file - allowZip64 is %s' % allow_zip_64) zip_file = None @@ -523,18 +516,15 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): self.main_window.increment_progress_bar() try: zip_file = zipfile.ZipFile(temp_file_name, 'w', zipfile.ZIP_STORED, allow_zip_64) - # First we add service contents. - # We save ALL file_names into ZIP using UTF-8. + # First we add service contents. We save ALL file_names into ZIP using UTF-8. zip_file.writestr(service_file_name.encode(u'utf-8'), service_content) # Finally add all the listed media files. for write_from in write_list: zip_file.write(write_from, write_from.encode(u'utf-8')) for audio_from, audio_to in audio_files: if audio_from.startswith(u'audio'): - # When items are saved, they get new unique_identifier. Let's copy the - # file to the new location. Unused files can be ignored, - # OpenLP automatically cleans up the service manager dir on - # exit. + # When items are saved, they get new unique_identifier. Let's copy the file to the new location. + # Unused files can be ignored, OpenLP automatically cleans up the service manager dir on exit. audio_from = os.path.join(self.servicePath, audio_from) save_file = os.path.join(self.servicePath, audio_to) save_path = os.path.split(save_file)[0] @@ -587,7 +577,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): for item in self.service_items: self.main_window.increment_progress_bar() service_item = item[u'service_item'].get_service_repr(self._save_lite) - #@todo check for file item on save. + #TODO: check for file item on save. service.append({u'serviceitem': service_item}) self.main_window.increment_progress_bar() service_content = cPickle.dumps(service) @@ -622,8 +612,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): def save_file_as(self): """ - Get a file name and then call :func:`ServiceManager.save_file` to - save the file. + Get a file name and then call :func:`ServiceManager.save_file` to save the file. """ default_service_enabled = Settings().value(u'advanced/default service enabled') if default_service_enabled: @@ -645,8 +634,8 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): default_file_name = u'' directory = Settings().value(self.main_window.service_manager_settings_section + u'/last directory') path = os.path.join(directory, default_file_name) - # SaveAs from osz to oszl is not valid as the files will be deleted - # on exit which is not sensible or usable in the long term. + # SaveAs from osz to oszl is not valid as the files will be deleted on exit which is not sensible or usable in + # the long term. if self._file_name.endswith(u'oszl') or self.service_has_all_original_files: file_name = QtGui.QFileDialog.getSaveFileName(self.main_window, UiStrings().SaveService, path, translate('OpenLP.ServiceManager', @@ -764,9 +753,8 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): def load_Last_file(self): """ - Load the last service item from the service manager when the - service was last closed. Can be blank if there was no service - present. + Load the last service item from the service manager when the service was last closed. Can be blank if there was + no service present. """ file_name = Settings().value(u'servicemanager/last file') if file_name: @@ -860,8 +848,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): def toggle_auto_play_slides_once(self): """ - Toggle Auto play slide once. - Inverts auto play once option for the item + Toggle Auto play slide once. Inverts auto play once option for the item """ item = self.find_service_item()[0] service_item = self.service_items[item][u'service_item'] @@ -922,8 +909,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): def on_service_item_edit_form(self): """ - Opens a dialog to edit the service item and update the service - display if changes are saved. + Opens a dialog to edit the service item and update the service display if changes are saved. """ item = self.find_service_item()[0] self.service_item_edit_form.set_service_item(self.service_items[item][u'service_item']) @@ -933,17 +919,14 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): def preview_live(self, unique_identifier, row): """ - Called by the SlideController to request a preview item be made live - and allows the next preview to be updated if relevant. - + Called by the SlideController to request a preview item be made live and allows the next preview to be updated + if relevant. ``unique_identifier`` Reference to the service_item - ``row`` individual row number - """ for sitem in self.service_items: if sitem[u'service_item'].unique_identifier == unique_identifier: @@ -1021,8 +1004,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): def on_move_selection_up(self): """ - Moves the cursor selection up the window. - Called by the up arrow. + Moves the cursor selection up the window. Called by the up arrow. """ item = self.service_manager_list.currentItem() itemBefore = self.service_manager_list.itemAbove(item) @@ -1032,8 +1014,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): def on_move_selection_down(self): """ - Moves the cursor selection down the window. - Called by the down arrow. + Moves the cursor selection down the window. Called by the down arrow. """ item = self.service_manager_list.currentItem() itemAfter = self.service_manager_list.itemBelow(item) @@ -1051,8 +1032,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): def collapsed(self, item): """ - Record if an item is collapsed. Used when repainting the list to get the - correct state. + Record if an item is collapsed. Used when repainting the list to get the correct state. """ pos = item.data(0, QtCore.Qt.UserRole) self.service_items[pos - 1][u'expanded'] = False @@ -1067,8 +1047,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): def expanded(self, item): """ - Record if an item is collapsed. Used when repainting the list to get the - correct state. + Record if an item is collapsed. Used when repainting the list to get the correct state. """ pos = item.data(0, QtCore.Qt.UserRole) self.service_items[pos - 1][u'expanded'] = True @@ -1133,9 +1112,8 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): def repaint_service_list(self, service_item, service_item_child): """ - Clear the existing service list and prepaint all the items. This is - used when moving items as the move takes place in a supporting list, - and when regenerating all the items due to theme changes. + Clear the existing service list and prepaint all the items. This is used when moving items as the move takes + place in a supporting list, and when regenerating all the items due to theme changes. ``service_item`` The item which changed. (int) @@ -1233,8 +1211,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): def theme_change(self): """ - The theme may have changed in the settings dialog so make - sure the theme combo box is in the correct state. + The theme may have changed in the settings dialog so make sure the theme combo box is in the correct state. """ log.debug(u'theme_change') visible = self.renderer.theme_level == ThemeLevel.Global @@ -1243,8 +1220,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): def regenerate_service_Items(self, changed=False): """ - Rebuild the service list as things have changed and a - repaint is the easiest way to do this. + Rebuild the service list as things have changed and a repaint is the easiest way to do this. """ self.application.set_busy_cursor() log.debug(u'regenerate_service_Items') @@ -1272,8 +1248,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): for item in tempServiceItems: self.add_service_item(item[u'service_item'], False, expand=item[u'expanded'], repaint=False, selected=item[u'selected']) - # Set to False as items may have changed rendering - # does not impact the saved song so True may also be valid + # Set to False as items may have changed rendering does not impact the saved song so True may also be valid if changed: self.set_modified() # Repaint it once only at the end @@ -1282,8 +1257,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): def service_item_update(self, edit_id, unique_identifier, temporary=False): """ - Triggered from plugins to update service items. - Save the values as they will be used as part of the service load + Triggered from plugins to update service items. Save the values as they will be used as part of the service load """ self.load_item_unique_identifier = unique_identifier self.load_item_edit_id = int(edit_id) @@ -1291,8 +1265,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): def replace_service_item(self, newItem): """ - Using the service item passed replace the one with the same edit id - if found. + Using the service item passed replace the one with the same edit id if found. """ for item_count, item in enumerate(self.service_items): if item[u'service_item'].edit_id == newItem.edit_id and item[u'service_item'].name == newItem.name: @@ -1375,8 +1348,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): def on_make_live(self): """ - Send the current item to the Live slide controller but triggered - by a tablewidget click event. + Send the current item to the Live slide controller but triggered by a tablewidget click event. """ self.make_live() @@ -1385,8 +1357,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): Send the current item to the Live slide controller ``row`` - Row number to be displayed if from preview. - -1 is passed if the value is not set + Row number to be displayed if from preview. -1 is passed if the value is not set """ item, child = self.find_service_item() # No items in service @@ -1431,10 +1402,9 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): def find_service_item(self): """ - Finds the first selected ServiceItem in the list and returns the - position of the serviceitem and its selected child item. For example, - if the third child item (in the Slidecontroller known as slide) in the - second service item is selected this will return:: + Finds the first selected ServiceItem in the list and returns the position of the serviceitem and its selected + child item. For example, if the third child item (in the Slidecontroller known as slide) in the second service + item is selected this will return:: (1, 2) """ @@ -1456,8 +1426,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): def drop_event(self, event): """ - Receive drop event and trigger an internal event to get the - plugins to build and push the correct service item + Receive drop event and trigger an internal event to get the plugins to build and push the correct service item. The drag event payload carries the plugin name ``event`` @@ -1529,8 +1498,8 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): theme_group = QtGui.QActionGroup(self.theme_menu) theme_group.setExclusive(True) theme_group.setObjectName(u'theme_group') - # Create a "Default" theme, which allows the user to reset the item's - # theme to the service theme or global theme. + # Create a "Default" theme, which allows the user to reset the item's theme to the service theme or global + # theme. defaultTheme = create_widget_action(self.theme_menu, text=UiStrings().Default, checked=False, triggers=self.on_theme_change_action) self.theme_menu.setDefaultAction(defaultTheme) diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index 2dc7ad7b6..f0f821494 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -184,7 +184,7 @@ class ThemesTab(SettingsTab): """ self.global_theme = self.default_combo_box.currentText() self.renderer.set_global_theme() - self._previewGlobalTheme() + self._preview_global_theme() def update_theme_list(self, theme_list): """ diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index 452b45713..8d8530918 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -225,7 +225,7 @@ class AlertsPlugin(Plugin): ``frame`` The Web frame holding the page. """ - align = VerticalType.Names[self.settingsTab.location] + align = VerticalType.Names[self.settings_tab.location] frame.evaluateJavaScript(u'update_css("%s", "%s", "%s", "%s", "%s")' % - (align, self.settingsTab.font_face, self.settingsTab.font_size, - self.settingsTab.font_color, self.settingsTab.background_color)) + (align, self.settings_tab.font_face, self.settings_tab.font_size, + self.settings_tab.font_color, self.settings_tab.background_color)) diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index ab6796f94..17182d7e2 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -206,7 +206,7 @@ class BiblesTab(SettingsTab): self.layout_style = self.layout_style_combo_box.currentIndex() def on_language_selection_combo_box_changed(self): - self.language_selection = self.language_selectioncombo_box.currentIndex() + self.language_selection = self.language_selection_combo_box.currentIndex() def on_new_chapters_check_box_changed(self, check_state): self.show_new_chapters = False diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 1e49f95fe..abe3cc45a 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -516,13 +516,13 @@ class BibleMediaItem(MediaManagerItem): def onQuickStyleComboBoxChanged(self): self.settings.layout_style = self.quickStyleComboBox.currentIndex() self.advancedStyleComboBox.setCurrentIndex(self.settings.layout_style) - self.settings.layoutStyleComboBox.setCurrentIndex(self.settings.layout_style) + self.settings.layout_style_combo_box.setCurrentIndex(self.settings.layout_style) Settings().setValue(self.settings_section + u'/verse layout style', self.settings.layout_style) def onAdvancedStyleComboBoxChanged(self): self.settings.layout_style = self.advancedStyleComboBox.currentIndex() self.quickStyleComboBox.setCurrentIndex(self.settings.layout_style) - self.settings.layoutStyleComboBox.setCurrentIndex(self.settings.layout_style) + self.settings.layout_style_combo_box.setCurrentIndex(self.settings.layout_style) Settings().setValue(self.settings_section + u'/verse layout style', self.settings.layout_style) def onAdvancedVersionComboBox(self): diff --git a/openlp/plugins/custom/forms/__init__.py b/openlp/plugins/custom/forms/__init__.py index aa0d21fd1..64d028205 100644 --- a/openlp/plugins/custom/forms/__init__.py +++ b/openlp/plugins/custom/forms/__init__.py @@ -26,6 +26,3 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - -from editcustomform import EditCustomForm -from editcustomslideform import EditCustomSlideForm diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index 5146a0e05..c78baa974 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -91,8 +91,8 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): self.slide_list_view.clear() if id == 0: self.custom_slide = CustomSlide() - self.title_edit.set_text(u'') - self.credit_edit.set_text(u'') + self.title_edit.setText(u'') + self.credit_edit.setText(u'') self.theme_combo_box.setCurrentIndex(0) else: self.custom_slide = self.manager.get_object(CustomSlide, id) diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 9e3261eeb..071f68839 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -34,7 +34,7 @@ from sqlalchemy.sql import or_, func, and_ from openlp.core.lib import Registry, MediaManagerItem, ItemCapabilities, ServiceItemContext, Settings, PluginStatus,\ UiStrings, check_item_selected, translate -from openlp.plugins.custom.forms import EditCustomForm +from openlp.plugins.custom.forms.editcustomform import EditCustomForm from openlp.plugins.custom.lib import CustomXMLParser, CustomXMLBuilder from openlp.plugins.custom.lib.db import CustomSlide diff --git a/openlp/plugins/remotes/lib/remotetab.py b/openlp/plugins/remotes/lib/remotetab.py index 55c8f9bb0..483b3461b 100644 --- a/openlp/plugins/remotes/lib/remotetab.py +++ b/openlp/plugins/remotes/lib/remotetab.py @@ -150,7 +150,7 @@ class RemoteTab(SettingsTab): Settings().setValue(self.settings_section + u'/ip address', self.address_edit.text()) Settings().setValue(self.settings_section + u'/twelve hour', self.twelve_hour) if changed: - Registry().register_function(u'remotes_config_updated') + Registry().execute(u'remotes_config_updated') def onTwelveHourCheckBoxChanged(self, check_state): self.twelve_hour = False diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index f5a0f0cac..49a20762a 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -256,8 +256,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): A QtGui.QKeyEvent event. """ if event.key() in (QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return): - if self.authorsComboBox.hasFocus() and self.authorsComboBox.currentText(): - self.onAuthorAddButtonClicked() + if self.authors_combo_box.hasFocus() and self.authors_combo_box.currentText(): + self.on_author_add_button_clicked() return if self.topicsComboBox.hasFocus() and self.topicsComboBox.currentText(): self.on_topic_add_button_clicked() diff --git a/resources/images/openlp-2.qrc b/resources/images/openlp-2.qrc index 8b8456b1f..82c763c6f 100644 --- a/resources/images/openlp-2.qrc +++ b/resources/images/openlp-2.qrc @@ -18,7 +18,6 @@ author_maintenance.png topic_maintenance.png song_author_edit.png - song_topic_edit.png song_book_edit.png diff --git a/resources/images/song_topic_edit.png b/resources/images/song_topic_edit.png deleted file mode 100644 index 22b6eeb6f..000000000 Binary files a/resources/images/song_topic_edit.png and /dev/null differ diff --git a/resources/images/splash-screen-new.bmp b/resources/images/splash-screen-new.bmp deleted file mode 100644 index 9b09a1076..000000000 Binary files a/resources/images/splash-screen-new.bmp and /dev/null differ diff --git a/scripts/generate_resources.sh b/scripts/generate_resources.sh index d1717507d..e525ee29b 100755 --- a/scripts/generate_resources.sh +++ b/scripts/generate_resources.sh @@ -1,5 +1,5 @@ #!/bin/sh -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -47,8 +47,7 @@ mv openlp/core/resources.py openlp/core/resources.py.old pyrcc4 -o openlp/core/resources.py.new resources/images/openlp-2.qrc # Remove patch breaking lines -cat openlp/core/resources.py.new | sed '/# Created: /d;/# by: /d' \ - > openlp/core/resources.py +cat openlp/core/resources.py.new | sed '/# Created: /d;/# by: /d' > openlp/core/resources.py # Patch resources.py to OpenLP coding style patch --posix -s openlp/core/resources.py scripts/resources.patch diff --git a/tests/interfaces/openlp_plugins_songs_forms/__init__.py b/tests/interfaces/openlp_plugins/__init__.py similarity index 100% rename from tests/interfaces/openlp_plugins_songs_forms/__init__.py rename to tests/interfaces/openlp_plugins/__init__.py diff --git a/tests/interfaces/openlp_plugins/__init__.pyc b/tests/interfaces/openlp_plugins/__init__.pyc new file mode 100644 index 000000000..0d24c9eff Binary files /dev/null and b/tests/interfaces/openlp_plugins/__init__.pyc differ diff --git a/tests/interfaces/openlp_plugins/custom/__init__.py b/tests/interfaces/openlp_plugins/custom/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/interfaces/openlp_plugins/custom/forms/__init__.py b/tests/interfaces/openlp_plugins/custom/forms/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/interfaces/openlp_plugins/custom/forms/test_customform.py b/tests/interfaces/openlp_plugins/custom/forms/test_customform.py new file mode 100644 index 000000000..ebd12f49d --- /dev/null +++ b/tests/interfaces/openlp_plugins/custom/forms/test_customform.py @@ -0,0 +1,64 @@ +""" +Module to test the custom edit form. +""" +from unittest import TestCase +from mock import MagicMock, patch + +from PyQt4 import QtGui, QtTest, QtCore + +from openlp.core.lib import Registry +# Import needed due to import problems. +from openlp.plugins.custom.lib.mediaitem import CustomMediaItem +from openlp.plugins.custom.forms.editcustomform import EditCustomForm + + +class TestCustomFrom(TestCase): + """ + Test the EditCustomForm. + """ + def setUp(self): + """ + Create the UI + """ + Registry.create() + self.app = QtGui.QApplication([]) + self.main_window = QtGui.QMainWindow() + Registry().register(u'main_window', self.main_window) + media_item = MagicMock() + manager = MagicMock() + self.form = EditCustomForm(media_item, self.main_window, manager) + + def tearDown(self): + """ + Delete all the C++ objects at the end so that we don't have a segfault + """ + del self.form + del self.main_window + del self.app + + def load_custom_test(self): + """ + Test the load_custom() method. + """ + # GIVEN: A mocked QDialog.exec_() method + with patch(u'PyQt4.QtGui.QDialog.exec_') as mocked_exec: + # WHEN: Show the dialog and create a new custom item. + self.form.exec_() + self.form.load_custom(0) + + #THEN: The line edits should not contain any text. + self.assertEqual(self.form.title_edit.text(), u'', u'The title edit should be empty') + self.assertEqual(self.form.credit_edit.text(), u'', u'The credit edit should be empty') + + + def on_add_button_clicked_test(self): + """ + Test the on_add_button_clicked_test method / add_button button. + """ + # GIVEN: A mocked QDialog.exec_() method + with patch(u'PyQt4.QtGui.QDialog.exec_') as mocked_exec: + # WHEN: Show the dialog and add a new slide. + self.form.exec_() + QtTest.QTest.mouseClick(self.form.add_button, QtCore.Qt.LeftButton) + #THEN: One slide should be added. + assert self.form.slide_list_view.count() == 1, u'There should be one slide added.' diff --git a/tests/interfaces/openlp_plugins/songs/__init__.py b/tests/interfaces/openlp_plugins/songs/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/interfaces/openlp_plugins/songs/forms/__init__.py b/tests/interfaces/openlp_plugins/songs/forms/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/interfaces/openlp_plugins_songs_forms/test_authorsform.py b/tests/interfaces/openlp_plugins/songs/forms/test_authorsform.py similarity index 100% rename from tests/interfaces/openlp_plugins_songs_forms/test_authorsform.py rename to tests/interfaces/openlp_plugins/songs/forms/test_authorsform.py diff --git a/tests/interfaces/openlp_plugins_songs_forms/test_editsongform.py b/tests/interfaces/openlp_plugins/songs/forms/test_editsongform.py similarity index 100% rename from tests/interfaces/openlp_plugins_songs_forms/test_editsongform.py rename to tests/interfaces/openlp_plugins/songs/forms/test_editsongform.py diff --git a/tests/interfaces/openlp_plugins_songs_forms/test_editverseform.py b/tests/interfaces/openlp_plugins/songs/forms/test_editverseform.py similarity index 100% rename from tests/interfaces/openlp_plugins_songs_forms/test_editverseform.py rename to tests/interfaces/openlp_plugins/songs/forms/test_editverseform.py diff --git a/tests/interfaces/openlp_plugins_songs_forms/test_topicsform.py b/tests/interfaces/openlp_plugins/songs/forms/test_topicsform.py similarity index 100% rename from tests/interfaces/openlp_plugins_songs_forms/test_topicsform.py rename to tests/interfaces/openlp_plugins/songs/forms/test_topicsform.py