Raoul Snyman has proposed merging lp:~raoul-snyman/openlp/ui-fixes into lp:openlp.
Requested reviews: Tim Bentley (trb143) For more details, see: https://code.launchpad.net/~raoul-snyman/openlp/ui-fixes/+merge/239308 Fix up the look and feel of the wizards after I messed it up with my changes for OS X Added and updated tests: - Refactored FirstTimeForm to use an initalise() method, in order to be more testable - Rewrote FTW tests to test initialise() - Refactored TestMixin get_application() to setup_application() since it doesn't actually return an application object - Refactored ListPreviewWidget to make it more testable - Wrote tests for ListPreviewWidget - Refactored FormattingTagsForm somewhat - Updated FormattingTagsForm tests Updated setup.py with some Python3 changes. Merged HEAD Add this to your merge proposal: -------------------------------- lp:~raoul-snyman/openlp/ui-fixes (revision 2427) [SUCCESS] http://ci.openlp.org/job/Branch-01-Pull/707/ [SUCCESS] http://ci.openlp.org/job/Branch-02-Functional-Tests/650/ [SUCCESS] http://ci.openlp.org/job/Branch-03-Interface-Tests/594/ [SUCCESS] http://ci.openlp.org/job/Branch-04a-Windows_Functional_Tests/536/ [SUCCESS] http://ci.openlp.org/job/Branch-04b-Windows_Interface_Tests/145/ [SUCCESS] http://ci.openlp.org/job/Branch-05a-Code_Analysis/350/ [SUCCESS] http://ci.openlp.org/job/Branch-05b-Test_Coverage/224/ -- https://code.launchpad.net/~raoul-snyman/openlp/ui-fixes/+merge/239308 Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/__init__.py' --- openlp/core/__init__.py 2014-10-21 21:08:26 +0000 +++ openlp/core/__init__.py 2014-10-22 20:57:53 +0000 @@ -118,7 +118,9 @@ # First time checks in settings has_run_wizard = Settings().value('core/has run wizard') if not has_run_wizard: - if FirstTimeForm(screens).exec_() == QtGui.QDialog.Accepted: + ftw = FirstTimeForm() + ftw.initialize(screens) + if ftw.exec_() == QtGui.QDialog.Accepted: Settings().setValue('core/has run wizard', True) # Correct stylesheet bugs application_stylesheet = '' === modified file 'openlp/core/ui/firsttimeform.py' --- openlp/core/ui/firsttimeform.py 2014-08-22 22:12:35 +0000 +++ openlp/core/ui/firsttimeform.py 2014-10-22 20:57:53 +0000 @@ -44,7 +44,7 @@ from openlp.core.common import Registry, RegistryProperties, AppLocation, Settings, check_directory_exists, translate from openlp.core.lib import PluginStatus, build_icon from openlp.core.utils import get_web_page -from .firsttimewizard import Ui_FirstTimeWizard, FirstTimePage +from .firsttimewizard import UiFirstTimeWizard, FirstTimePage log = logging.getLogger(__name__) @@ -75,18 +75,58 @@ item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable) -class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard, RegistryProperties): +class FirstTimeForm(QtGui.QWizard, UiFirstTimeWizard, RegistryProperties): """ This is the Theme Import Wizard, which allows easy creation and editing of OpenLP themes. """ log.info('ThemeWizardForm loaded') - def __init__(self, screens, parent=None): + def __init__(self, parent=None): """ Create and set up the first time wizard. """ super(FirstTimeForm, self).__init__(parent) - self.setupUi(self) + self.setup_ui(self) + + def nextId(self): + """ + Determine the next page in the Wizard to go to. + """ + self.application.process_events() + if self.currentId() == FirstTimePage.Plugins: + if not self.web_access: + return FirstTimePage.NoInternet + else: + return FirstTimePage.Songs + elif self.currentId() == FirstTimePage.Progress: + return -1 + elif self.currentId() == FirstTimePage.NoInternet: + return FirstTimePage.Progress + elif self.currentId() == FirstTimePage.Themes: + self.application.set_busy_cursor() + while not self.theme_screenshot_thread.isFinished(): + time.sleep(0.1) + self.application.process_events() + # Build the screenshot icons, as this can not be done in the thread. + self._build_theme_screenshots() + self.application.set_normal_cursor() + return FirstTimePage.Defaults + else: + return self.currentId() + 1 + + def exec_(self): + """ + Run the wizard. + """ + self.set_defaults() + return QtGui.QWizard.exec_(self) + + def initialize(self, screens): + """ + Set up the First Time Wizard + + :param screens: The screens detected by OpenLP + """ self.screens = screens # check to see if we have web access self.web = 'http://openlp.org/files/frw/' @@ -110,13 +150,6 @@ self.currentIdChanged.connect(self.on_current_id_changed) Registry().register_function('config_screen_changed', self.update_screen_list_combo) - def exec_(self): - """ - Run the wizard. - """ - self.set_defaults() - return QtGui.QWizard.exec_(self) - def set_defaults(self): """ Set up display at start of theme edit. @@ -157,31 +190,14 @@ self.theme_screenshot_thread.start() self.application.set_normal_cursor() - def nextId(self): - """ - Determine the next page in the Wizard to go to. - """ - self.application.process_events() - if self.currentId() == FirstTimePage.Plugins: - if not self.web_access: - return FirstTimePage.NoInternet - else: - return FirstTimePage.Songs - elif self.currentId() == FirstTimePage.Progress: - return -1 - elif self.currentId() == FirstTimePage.NoInternet: - return FirstTimePage.Progress - elif self.currentId() == FirstTimePage.Themes: - self.application.set_busy_cursor() - while not self.theme_screenshot_thread.isFinished(): - time.sleep(0.1) - self.application.process_events() - # Build the screenshot icons, as this can not be done in the thread. - self._build_theme_screenshots() - self.application.set_normal_cursor() - return FirstTimePage.Defaults - else: - return self.currentId() + 1 + def update_screen_list_combo(self): + """ + The user changed screen resolution or enabled/disabled more screens, so + we need to update the combo box. + """ + self.display_combo_box.clear() + self.display_combo_box.addItems(self.screens.get_screen_list()) + self.display_combo_box.setCurrentIndex(self.display_combo_box.count() - 1) def on_current_id_changed(self, page_id): """ @@ -230,15 +246,6 @@ self._post_wizard() self.application.set_normal_cursor() - def update_screen_list_combo(self): - """ - The user changed screen resolution or enabled/disabled more screens, so - we need to update the combo box. - """ - self.display_combo_box.clear() - self.display_combo_box.addItems(self.screens.get_screen_list()) - self.display_combo_box.setCurrentIndex(self.display_combo_box.count() - 1) - def on_cancel_button_clicked(self): """ Process the triggering of the cancel button. === modified file 'openlp/core/ui/firsttimewizard.py' --- openlp/core/ui/firsttimewizard.py 2014-09-02 21:15:58 +0000 +++ openlp/core/ui/firsttimewizard.py 2014-10-22 20:57:53 +0000 @@ -50,13 +50,15 @@ Progress = 7 -class Ui_FirstTimeWizard(object): +class UiFirstTimeWizard(object): """ The UI widgets for the first time wizard. """ - def setupUi(self, first_time_wizard): + def setup_ui(self, first_time_wizard): """ Set up the UI. + + :param first_time_wizard: The wizard form """ first_time_wizard.setObjectName('first_time_wizard') first_time_wizard.setWindowIcon(build_icon(u':/icon/openlp-logo.svg')) @@ -68,6 +70,8 @@ first_time_wizard.setPixmap(QtGui.QWizard.BackgroundPixmap, QtGui.QPixmap(':/wizards/openlp-osx-wizard.png')) first_time_wizard.resize(634, 386) + else: + first_time_wizard.setWizardStyle(QtGui.QWizard.ModernStyle) self.finish_button = self.button(QtGui.QWizard.FinishButton) self.no_internet_finish_button = self.button(QtGui.QWizard.CustomButton1) self.cancel_button = self.button(QtGui.QWizard.CancelButton) @@ -202,19 +206,21 @@ self.progress_bar.setObjectName('progress_bar') self.progress_layout.addWidget(self.progress_bar) first_time_wizard.setPage(FirstTimePage.Progress, self.progress_page) - self.retranslateUi(first_time_wizard) + self.retranslate_ui(first_time_wizard) - def retranslateUi(self, first_time_wizard): + def retranslate_ui(self, first_time_wizard): """ Translate the UI on the fly + + :param first_time_wizard: The wizard form """ first_time_wizard.setWindowTitle(translate('OpenLP.FirstTimeWizard', 'First Time Wizard')) - self.title_label.setText('<span style="font-size:14pt; font-weight:600;">%s</span>' % - translate('OpenLP.FirstTimeWizard', 'Welcome to the First Time Wizard')) - self.information_label.setText( + first_time_wizard.title_label.setText('<span style="font-size:14pt; font-weight:600;">%s</span>' % + translate('OpenLP.FirstTimeWizard', 'Welcome to the First Time Wizard')) + first_time_wizard.information_label.setText( translate('OpenLP.FirstTimeWizard', 'This wizard will help you to configure OpenLP for initial use. ' 'Click the %s button below to start.') % - self.buttonText(QtGui.QWizard.NextButton)) + first_time_wizard.buttonText(QtGui.QWizard.NextButton)) self.plugin_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Activate required Plugins')) self.plugin_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Select the Plugins you wish to use. ')) self.songs_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Songs')) @@ -236,9 +242,10 @@ 'no sample data.\n\nTo re-run the First Time Wizard and import this sample ' 'data at a later time, check your Internet connection and re-run this ' 'wizard by selecting "Tools/Re-run First Time Wizard" from OpenLP.') - self.cancelWizardText = translate('OpenLP.FirstTimeWizard', - '\n\nTo cancel the First Time Wizard completely (and not start OpenLP), ' - 'click the %s button now.') % self.buttonText(QtGui.QWizard.CancelButton) + self.cancel_wizard_text = translate('OpenLP.FirstTimeWizard', + '\n\nTo cancel the First Time Wizard completely (and not start OpenLP), ' + 'click the %s button now.') % \ + first_time_wizard.buttonText(QtGui.QWizard.CancelButton) self.songs_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Sample Songs')) self.songs_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Select and download public domain songs.')) self.bibles_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Sample Bibles')) === modified file 'openlp/core/ui/listpreviewwidget.py' --- openlp/core/ui/listpreviewwidget.py 2014-07-11 11:35:56 +0000 +++ openlp/core/ui/listpreviewwidget.py 2014-10-22 20:57:53 +0000 @@ -38,17 +38,30 @@ class ListPreviewWidget(QtGui.QTableWidget, RegistryProperties): + """ + A special type of QTableWidget which lists the slides in the slide controller + + :param parent: + :param screen_ratio: + """ + def __init__(self, parent, screen_ratio): """ Initializes the widget to default state. - An empty ServiceItem is used per default. - One needs to call replace_service_manager_item() to make this widget display something. + + An empty ``ServiceItem`` is used by default. replace_service_manager_item() needs to be called to make this + widget display something. """ super(QtGui.QTableWidget, self).__init__(parent) - # Set up the widget. + self._setup(screen_ratio) + + def _setup(self, screen_ratio): + """ + Set up the widget + """ self.setColumnCount(1) self.horizontalHeader().setVisible(False) - self.setColumnWidth(0, parent.width()) + self.setColumnWidth(0, self.parent().width()) self.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) self.setSelectionMode(QtGui.QAbstractItemView.SingleSelection) self.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers) @@ -58,7 +71,7 @@ self.service_item = ServiceItem() self.screen_ratio = screen_ratio - def resizeEvent(self, QResizeEvent): + def resizeEvent(self, event): """ Overloaded method from QTableWidget. Will recalculate the layout. """ @@ -82,16 +95,20 @@ def screen_size_changed(self, screen_ratio): """ - To be called whenever the live screen size changes. - Because this makes a layout recalculation necessary. + This method is called whenever the live screen size changes, which then makes a layout recalculation necessary + + :param screen_ratio: The new screen ratio """ self.screen_ratio = screen_ratio self.__recalculate_layout() def replace_service_item(self, service_item, width, slide_number): """ - Replaces the current preview items with the ones in service_item. - Displays the given slide. + Replace the current preview items with the ones in service_item and display the given slide + + :param service_item: The service item to insert + :param width: The width of the column + :param slide_number: The slide number to pre-select """ self.service_item = service_item self.setRowCount(0) === modified file 'openlp/core/ui/mainwindow.py' --- openlp/core/ui/mainwindow.py 2014-10-21 05:13:22 +0000 +++ openlp/core/ui/mainwindow.py 2014-10-22 20:57:53 +0000 @@ -656,8 +656,8 @@ QtGui.QMessageBox.No) if answer == QtGui.QMessageBox.No: return - screens = ScreenList() - first_run_wizard = FirstTimeForm(screens, self) + first_run_wizard = FirstTimeForm(self) + first_run_wizard.initialize(ScreenList()) first_run_wizard.exec_() if first_run_wizard.was_download_cancelled: return === modified file 'openlp/core/ui/themewizard.py' --- openlp/core/ui/themewizard.py 2014-09-07 22:30:21 +0000 +++ openlp/core/ui/themewizard.py 2014-10-22 20:57:53 +0000 @@ -53,6 +53,8 @@ if is_macosx(): theme_wizard.setPixmap(QtGui.QWizard.BackgroundPixmap, QtGui.QPixmap(':/wizards/openlp-osx-wizard.png')) theme_wizard.resize(646, 400) + else: + theme_wizard.setWizardStyle(QtGui.QWizard.ModernStyle) self.spacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum) # Welcome Page add_welcome_page(theme_wizard, ':/wizards/wizard_createtheme.bmp') === modified file 'openlp/core/ui/wizard.py' --- openlp/core/ui/wizard.py 2014-09-07 22:30:21 +0000 +++ openlp/core/ui/wizard.py 2014-10-22 20:57:53 +0000 @@ -125,6 +125,8 @@ QtGui.QWizard.NoBackButtonOnStartPage | QtGui.QWizard.NoBackButtonOnLastPage) if is_macosx(): self.setPixmap(QtGui.QWizard.BackgroundPixmap, QtGui.QPixmap(':/wizards/openlp-osx-wizard.png')) + else: + self.setWizardStyle(QtGui.QWizard.ModernStyle) add_welcome_page(self, image) self.add_custom_pages() if self.with_progress_page: === modified file 'openlp/core/utils/__init__.py' --- openlp/core/utils/__init__.py 2014-10-21 20:05:08 +0000 +++ openlp/core/utils/__init__.py 2014-10-22 20:57:53 +0000 @@ -52,6 +52,7 @@ from xdg import BaseDirectory XDG_BASE_AVAILABLE = True except ImportError: + BaseDirectory = None XDG_BASE_AVAILABLE = False from openlp.core.common import translate @@ -125,14 +126,25 @@ Special HTTPRedirectHandler used to work around http://bugs.python.org/issue22248 (Redirecting to urls with special chars) """ - def redirect_request(self, req, fp, code, msg, headers, newurl): - # Test if the newurl can be decoded to ascii + def redirect_request(self, req, fp, code, msg, headers, new_url): + # + """ + Test if the new_url can be decoded to ascii + + :param req: + :param fp: + :param code: + :param msg: + :param headers: + :param new_url: + :return: + """ try: - test_url = newurl.encode('latin1').decode('ascii') - fixed_url = newurl + new_url.encode('latin1').decode('ascii') + fixed_url = new_url except Exception: # The url could not be decoded to ascii, so we do some url encoding - fixed_url = urllib.parse.quote(newurl.encode('latin1').decode('utf-8', 'replace'), safe='/:') + fixed_url = urllib.parse.quote(new_url.encode('latin1').decode('utf-8', 'replace'), safe='/:') return super(HTTPRedirectHandlerFixed, self).redirect_request(req, fp, code, msg, headers, fixed_url) @@ -181,18 +193,18 @@ full_version = '%s-bzr%s' % (tag_version.decode('utf-8'), tree_revision.decode('utf-8')) else: # We're not running the development version, let's use the file. - filepath = AppLocation.get_directory(AppLocation.VersionDir) - filepath = os.path.join(filepath, '.version') - fversion = None + file_path = AppLocation.get_directory(AppLocation.VersionDir) + file_path = os.path.join(file_path, '.version') + version_file = None try: - fversion = open(filepath, 'r') - full_version = str(fversion.read()).rstrip() + version_file = open(file_path, 'r') + full_version = str(version_file.read()).rstrip() except IOError: log.exception('Error in version file.') full_version = '0.0.0-bzr000' finally: - if fversion: - fversion.close() + if version_file: + version_file.close() bits = full_version.split('-') APPLICATION_VERSION = { 'full': full_version, @@ -211,13 +223,13 @@ Check the latest version of OpenLP against the version file on the OpenLP site. - :param current_version: The current version of OpenLP. - **Rules around versions and version files:** * If a version number has a build (i.e. -bzr1234), then it is a nightly. * If a version number's minor version is an odd number, it is a development release. * If a version number's minor version is an even number, it is a stable release. + + :param current_version: The current version of OpenLP. """ version_string = current_version['full'] # set to prod in the distribution config file. === removed file 'resources/__init__.py' --- resources/__init__.py 2014-04-02 18:51:21 +0000 +++ resources/__init__.py 1970-01-01 00:00:00 +0000 @@ -1,34 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2014 Raoul Snyman # -# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # -# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # -# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # -# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # -# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # -# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # -# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # -# --------------------------------------------------------------------------- # -# This program is free software; you can redistribute it and/or modify it # -# under the terms of the GNU General Public License as published by the Free # -# Software Foundation; version 2 of the License. # -# # -# This program is distributed in the hope that it will be useful, but WITHOUT # -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # -# more details. # -# # -# You should have received a copy of the GNU General Public License along # -# with this program; if not, write to the Free Software Foundation, Inc., 59 # -# Temple Place, Suite 330, Boston, MA 02111-1307 USA # -############################################################################### -""" -The :mod:`resources` module contains a bunch of resources for OpenLP. - -DO NOT REMOVE THIS FILE, IT IS REQUIRED FOR INCLUDING THE RESOURCES ON SOME -PLATFORMS! -""" === modified file 'setup.py' --- setup.py 2014-07-02 19:34:28 +0000 +++ setup.py 2014-10-22 20:57:53 +0000 @@ -45,7 +45,7 @@ """ try: return int(s) - except Exception: + except (TypeError, ValueError): return s @@ -58,27 +58,23 @@ return list(map(try_int, SPLIT_ALPHA_DIGITS.findall(s))) -def natural_compare(a, b): - """ - Compare two strings naturally and return the result. - - :param a: A string to compare. - :param b: A string to compare. - """ - return cmp(natural_sort_key(a), natural_sort_key(b)) - - -def natural_sort(seq, compare=natural_compare): +def natural_sort(seq): """ Returns a copy of seq, sorted by natural string sort. + + :param seq: The sequence to sort. + :param compare: The comparison method to use + :return: The sorted sequence """ import copy temp = copy.copy(seq) - temp.sort(compare) + temp.sort(key=natural_sort_key) return temp + # NOTE: The following code is a duplicate of the code in openlp/core/utils/__init__.py. Any fix applied here should also # be applied there. +ver_file = None try: # Get the revision of this tree. bzr = Popen(('bzr', 'revno'), stdout=PIPE) === modified file 'tests/functional/openlp_core_common/test_settings.py' --- tests/functional/openlp_core_common/test_settings.py 2014-03-14 22:08:44 +0000 +++ tests/functional/openlp_core_common/test_settings.py 2014-10-22 20:57:53 +0000 @@ -43,7 +43,7 @@ """ Create the UI """ - self.get_application() + self.setup_application() self.build_settings() def tearDown(self): === modified file 'tests/functional/openlp_core_lib/test_image_manager.py' --- tests/functional/openlp_core_lib/test_image_manager.py 2014-07-15 18:52:59 +0000 +++ tests/functional/openlp_core_lib/test_image_manager.py 2014-10-22 20:57:53 +0000 @@ -52,7 +52,7 @@ Create the UI """ Registry.create() - self.get_application() + self.setup_application() ScreenList.create(self.app.desktop()) self.image_manager = ImageManager() self.lock = Lock() === modified file 'tests/functional/openlp_core_ui/test_firsttimeform.py' --- tests/functional/openlp_core_ui/test_firsttimeform.py 2014-09-07 22:17:20 +0000 +++ tests/functional/openlp_core_ui/test_firsttimeform.py 2014-10-22 20:57:53 +0000 @@ -29,44 +29,78 @@ """ Package to test the openlp.core.ui.firsttimeform package. """ +from configparser import ConfigParser from unittest import TestCase from openlp.core.common import Registry from openlp.core.ui.firsttimeform import FirstTimeForm -from tests.functional import MagicMock +from tests.functional import MagicMock, patch from tests.helpers.testmixin import TestMixin +FAKE_CONFIG = b""" +[general] +base url = http://example.com/frw/ +[songs] +directory = songs +[bibles] +directory = bibles +[themes] +directory = themes +""" + class TestFirstTimeForm(TestCase, TestMixin): def setUp(self): - screens = MagicMock() - self.get_application() + self.setup_application() + self.app.setApplicationVersion('0.0') Registry.create() Registry().register('application', self.app) - self.first_time_form = FirstTimeForm(screens) - - def access_to_config_test(self): - """ - Test if we can access the First Time Form's config file - """ - # GIVEN A new First Time Form instance. - - # WHEN The default First Time Form is built. - - # THEN The First Time Form web configuration file should be accessable. - self.assertTrue(self.first_time_form.web_access, - 'First Time Wizard\'s web configuration file should be available') - - def parsable_config_test(self): - """ - Test if the First Time Form's config file is parsable - """ - # GIVEN A new First Time Form instance. - - # WHEN The default First Time Form is built. - - # THEN The First Time Form web configuration file should be parsable - self.assertTrue(self.first_time_form.songs_url, - 'First Time Wizard\'s web configuration file should be parsable') + + def basic_initialise_test(self): + """ + Test if we can intialise the FirstTimeForm without a config file + """ + # GIVEN: A mocked get_web_page, a First Time Wizard and an expected screen object + with patch('openlp.core.ui.firsttimeform.get_web_page') as mocked_get_web_page: + first_time_form = FirstTimeForm(None) + expected_screens = MagicMock() + expected_web_url = 'http://openlp.org/files/frw/' + expected_user_agent = 'OpenLP/0.0' + mocked_get_web_page.return_value = None + + # WHEN: The First Time Wizard is initialised + first_time_form.initialize(expected_screens) + + # THEN: The First Time Form web configuration file should be accessible and parseable + self.assertEqual(expected_screens, first_time_form.screens, 'The screens should be correct') + self.assertEqual(expected_web_url, first_time_form.web, 'The base path of the URL should be correct') + self.assertIsInstance(first_time_form.config, ConfigParser, 'The config object should be a ConfigParser') + mocked_get_web_page.assert_called_with(expected_web_url + 'download.cfg', + header=('User-Agent', expected_user_agent)) + + def config_initialise_test(self): + """ + Test if we can intialise the FirstTimeForm with a config file + """ + # GIVEN: A mocked get_web_page, a First Time Wizard and an expected screen object + with patch('openlp.core.ui.firsttimeform.get_web_page') as mocked_get_web_page: + first_time_form = FirstTimeForm(None) + expected_web_url = 'http://openlp.org/files/frw/' + expected_songs_url = 'http://example.com/frw/songs/' + expected_bibles_url = 'http://example.com/frw/bibles/' + expected_themes_url = 'http://example.com/frw/themes/' + expected_user_agent = 'OpenLP/0.0' + mocked_get_web_page.return_value.read.return_value = FAKE_CONFIG + + # WHEN: The First Time Wizard is initialised + first_time_form.initialize(MagicMock()) + + # THEN: The First Time Form web configuration file should be accessible and parseable + self.assertIsInstance(first_time_form.config, ConfigParser, 'The config object should be a ConfigParser') + mocked_get_web_page.assert_called_with(expected_web_url + 'download.cfg', + header=('User-Agent', expected_user_agent)) + self.assertEqual(expected_songs_url, first_time_form.songs_url, 'The songs URL should be correct') + self.assertEqual(expected_bibles_url, first_time_form.bibles_url, 'The bibles URL should be correct') + self.assertEqual(expected_themes_url, first_time_form.themes_url, 'The themes URL should be correct') === modified file 'tests/functional/openlp_core_ui/test_formattingtagsform.py' --- tests/functional/openlp_core_ui/test_formattingtagsform.py 2014-09-07 22:17:20 +0000 +++ tests/functional/openlp_core_ui/test_formattingtagsform.py 2014-10-22 20:57:53 +0000 @@ -29,9 +29,7 @@ """ Package to test the openlp.core.ui.formattingtagsform package. """ -from PyQt4 import QtGui from unittest import TestCase -from openlp.core.common import translate from tests.functional import MagicMock, patch, call === added file 'tests/functional/openlp_core_ui/test_listpreviewwidget.py' --- tests/functional/openlp_core_ui/test_listpreviewwidget.py 1970-01-01 00:00:00 +0000 +++ tests/functional/openlp_core_ui/test_listpreviewwidget.py 2014-10-22 20:57:53 +0000 @@ -0,0 +1,64 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### +""" +Package to test the openlp.core.ui.listpreviewwidget package. +""" +from unittest import TestCase +from openlp.core.ui.listpreviewwidget import ListPreviewWidget + +from tests.functional import patch + + +class TestListPreviewWidget(TestCase): + + def setUp(self): + """ + Mock out stuff for all the tests + """ + self.setup_patcher = patch('openlp.core.ui.listpreviewwidget.ListPreviewWidget._setup') + self.mocked_setup = self.setup_patcher.start() + + def tearDown(self): + """ + Remove the mocks + """ + self.setup_patcher.stop() + + def new_list_preview_widget_test(self): + """ + Test that creating an instance of ListPreviewWidget works + """ + # GIVEN: A ListPreviewWidget class + + # WHEN: An object is created + list_preview_widget = ListPreviewWidget(None, 1) + + # THEN: The object is not None, and the _setup() method was called. + self.assertIsNotNone(list_preview_widget, 'The ListPreviewWidget object should not be None') + self.mocked_setup.assert_called_with(1) === modified file 'tests/functional/openlp_core_ui/test_mainwindow.py' --- tests/functional/openlp_core_ui/test_mainwindow.py 2014-05-08 14:57:26 +0000 +++ tests/functional/openlp_core_ui/test_mainwindow.py 2014-10-22 20:57:53 +0000 @@ -46,7 +46,7 @@ def setUp(self): Registry.create() self.registry = Registry() - self.get_application() + self.setup_application() # Mock cursor busy/normal methods. self.app.set_busy_cursor = MagicMock() self.app.set_normal_cursor = MagicMock() === modified file 'tests/functional/openlp_plugins/presentations/test_impresscontroller.py' --- tests/functional/openlp_plugins/presentations/test_impresscontroller.py 2014-09-22 21:19:02 +0000 +++ tests/functional/openlp_plugins/presentations/test_impresscontroller.py 2014-10-22 20:57:53 +0000 @@ -51,7 +51,7 @@ """ Set up the patches and mocks need for all tests. """ - self.get_application() + self.setup_application() self.build_settings() self.mock_plugin = MagicMock() self.temp_folder = mkdtemp() === modified file 'tests/functional/openlp_plugins/presentations/test_mediaitem.py' --- tests/functional/openlp_plugins/presentations/test_mediaitem.py 2014-09-29 20:11:07 +0000 +++ tests/functional/openlp_plugins/presentations/test_mediaitem.py 2014-10-22 20:57:53 +0000 @@ -51,7 +51,7 @@ with patch('openlp.plugins.presentations.lib.mediaitem.MediaManagerItem._setup'), \ patch('openlp.plugins.presentations.lib.mediaitem.PresentationMediaItem.setup_item'): self.media_item = PresentationMediaItem(None, MagicMock, MagicMock()) - self.get_application() + self.setup_application() def build_file_mask_string_test(self): """ === modified file 'tests/functional/openlp_plugins/presentations/test_pdfcontroller.py' --- tests/functional/openlp_plugins/presentations/test_pdfcontroller.py 2014-04-04 20:24:11 +0000 +++ tests/functional/openlp_plugins/presentations/test_pdfcontroller.py 2014-10-22 20:57:53 +0000 @@ -61,7 +61,7 @@ """ Set up the components need for all tests. """ - self.get_application() + self.setup_application() self.build_settings() # Mocked out desktop object self.desktop = MagicMock() === modified file 'tests/functional/openlp_plugins/presentations/test_powerpointcontroller.py' --- tests/functional/openlp_plugins/presentations/test_powerpointcontroller.py 2014-09-08 21:48:49 +0000 +++ tests/functional/openlp_plugins/presentations/test_powerpointcontroller.py 2014-10-22 20:57:53 +0000 @@ -55,7 +55,7 @@ """ Set up the patches and mocks need for all tests. """ - self.get_application() + self.setup_application() self.build_settings() self.mock_plugin = MagicMock() self.temp_folder = mkdtemp() @@ -92,7 +92,7 @@ """ Set up the patches and mocks need for all tests. """ - self.get_application() + self.setup_application() self.build_settings() self.mock_plugin = MagicMock() self.temp_folder = mkdtemp() === modified file 'tests/functional/openlp_plugins/presentations/test_pptviewcontroller.py' --- tests/functional/openlp_plugins/presentations/test_pptviewcontroller.py 2014-09-08 21:48:49 +0000 +++ tests/functional/openlp_plugins/presentations/test_pptviewcontroller.py 2014-10-22 20:57:53 +0000 @@ -59,7 +59,7 @@ """ Set up the patches and mocks need for all tests. """ - self.get_application() + self.setup_application() self.build_settings() self.mock_plugin = MagicMock() self.temp_folder = mkdtemp() === modified file 'tests/functional/openlp_plugins/remotes/test_remotetab.py' --- tests/functional/openlp_plugins/remotes/test_remotetab.py 2014-08-25 20:31:35 +0000 +++ tests/functional/openlp_plugins/remotes/test_remotetab.py 2014-10-22 20:57:53 +0000 @@ -63,7 +63,7 @@ """ Create the UI """ - self.get_application() + self.setup_application() self.build_settings() Settings().extend_default_settings(__default_settings__) self.parent = QtGui.QMainWindow() === modified file 'tests/functional/openlp_plugins/remotes/test_router.py' --- tests/functional/openlp_plugins/remotes/test_router.py 2014-10-21 21:06:02 +0000 +++ tests/functional/openlp_plugins/remotes/test_router.py 2014-10-22 20:57:53 +0000 @@ -61,7 +61,7 @@ """ Create the UI """ - self.get_application() + self.setup_application() self.build_settings() Settings().extend_default_settings(__default_settings__) self.router = HttpRouter() === modified file 'tests/functional/openlp_plugins/songs/test_mediaitem.py' --- tests/functional/openlp_plugins/songs/test_mediaitem.py 2014-07-12 20:00:58 +0000 +++ tests/functional/openlp_plugins/songs/test_mediaitem.py 2014-10-22 20:57:53 +0000 @@ -29,7 +29,7 @@ self.media_item = SongMediaItem(None, MagicMock()) self.media_item.display_songbook = False self.media_item.display_copyright_symbol = False - self.get_application() + self.setup_application() self.build_settings() QtCore.QLocale.setDefault(QtCore.QLocale('en_GB')) === modified file 'tests/functional/openlp_plugins/songs/test_openlyricsimport.py' --- tests/functional/openlp_plugins/songs/test_openlyricsimport.py 2014-09-25 20:46:09 +0000 +++ tests/functional/openlp_plugins/songs/test_openlyricsimport.py 2014-10-22 20:57:53 +0000 @@ -41,7 +41,6 @@ from openlp.plugins.songs.lib.importers.songimport import SongImport from openlp.plugins.songs.lib.openlyricsxml import OpenLyrics from openlp.core.common import Registry, Settings -from openlp.core.lib import FormattingTags TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), @@ -83,7 +82,7 @@ """ Create the registry """ - self.get_application() + self.setup_application() Registry.create() self.build_settings() === modified file 'tests/helpers/testmixin.py' --- tests/helpers/testmixin.py 2014-05-31 20:10:59 +0000 +++ tests/helpers/testmixin.py 2014-10-22 20:57:53 +0000 @@ -37,8 +37,11 @@ class TestMixin(object): + """ + The :class:`TestMixin` class provides test with extra functionality + """ - def get_application(self): + def setup_application(self): """ Build or reuse the Application object """ === modified file 'tests/interfaces/openlp_core_common/test_historycombobox.py' --- tests/interfaces/openlp_core_common/test_historycombobox.py 2014-05-03 19:32:19 +0000 +++ tests/interfaces/openlp_core_common/test_historycombobox.py 2014-10-22 20:57:53 +0000 @@ -43,7 +43,7 @@ class TestHistoryComboBox(TestCase, TestMixin): def setUp(self): Registry.create() - self.get_application() + self.setup_application() self.main_window = QtGui.QMainWindow() Registry().register('main_window', self.main_window) self.combo = HistoryComboBox(self.main_window) === modified file 'tests/interfaces/openlp_core_lib/test_pluginmanager.py' --- tests/interfaces/openlp_core_lib/test_pluginmanager.py 2014-05-30 09:21:26 +0000 +++ tests/interfaces/openlp_core_lib/test_pluginmanager.py 2014-10-22 20:57:53 +0000 @@ -58,7 +58,7 @@ Settings().setValue('advanced/data path', self.temp_dir) Registry.create() Registry().register('service_list', MagicMock()) - self.get_application() + self.setup_application() self.main_window = QtGui.QMainWindow() Registry().register('main_window', self.main_window) === modified file 'tests/interfaces/openlp_core_lib/test_searchedit.py' --- tests/interfaces/openlp_core_lib/test_searchedit.py 2014-05-01 16:57:45 +0000 +++ tests/interfaces/openlp_core_lib/test_searchedit.py 2014-10-22 20:57:53 +0000 @@ -57,7 +57,7 @@ Create the UI """ Registry.create() - self.get_application() + self.setup_application() self.main_window = QtGui.QMainWindow() Registry().register('main_window', self.main_window) === modified file 'tests/interfaces/openlp_core_ui/test_filerenamedialog.py' --- tests/interfaces/openlp_core_ui/test_filerenamedialog.py 2014-05-01 16:58:32 +0000 +++ tests/interfaces/openlp_core_ui/test_filerenamedialog.py 2014-10-22 20:57:53 +0000 @@ -46,7 +46,7 @@ Create the UI """ Registry.create() - self.get_application() + self.setup_application() self.main_window = QtGui.QMainWindow() Registry().register('main_window', self.main_window) self.form = filerenameform.FileRenameForm() === modified file 'tests/interfaces/openlp_core_ui/test_listpreviewwidget.py' --- tests/interfaces/openlp_core_ui/test_listpreviewwidget.py 2014-03-14 22:08:44 +0000 +++ tests/interfaces/openlp_core_ui/test_listpreviewwidget.py 2014-10-22 20:57:53 +0000 @@ -49,7 +49,7 @@ Create the UI. """ Registry.create() - self.get_application() + self.setup_application() self.main_window = QtGui.QMainWindow() self.image = QtGui.QImage(1, 1, QtGui.QImage.Format_RGB32) self.image_manager = MagicMock() === modified file 'tests/interfaces/openlp_core_ui/test_mainwindow.py' --- tests/interfaces/openlp_core_ui/test_mainwindow.py 2014-04-02 19:35:09 +0000 +++ tests/interfaces/openlp_core_ui/test_mainwindow.py 2014-10-22 20:57:53 +0000 @@ -46,7 +46,7 @@ """ Registry.create() self.registry = Registry() - self.get_application() + self.setup_application() # Mock cursor busy/normal methods. self.app.set_busy_cursor = MagicMock() self.app.set_normal_cursor = MagicMock() === modified file 'tests/interfaces/openlp_core_ui/test_servicemanager.py' --- tests/interfaces/openlp_core_ui/test_servicemanager.py 2014-03-31 19:07:54 +0000 +++ tests/interfaces/openlp_core_ui/test_servicemanager.py 2014-10-22 20:57:53 +0000 @@ -46,7 +46,7 @@ Create the UI """ Registry.create() - self.get_application() + self.setup_application() ScreenList.create(self.app.desktop()) Registry().register('application', MagicMock()) with patch('openlp.core.lib.PluginManager'): === modified file 'tests/interfaces/openlp_core_ui/test_servicenotedialog.py' --- tests/interfaces/openlp_core_ui/test_servicenotedialog.py 2014-04-02 19:35:09 +0000 +++ tests/interfaces/openlp_core_ui/test_servicenotedialog.py 2014-10-22 20:57:53 +0000 @@ -46,7 +46,7 @@ Create the UI """ Registry.create() - self.get_application() + self.setup_application() self.main_window = QtGui.QMainWindow() Registry().register('main_window', self.main_window) self.form = servicenoteform.ServiceNoteForm() === modified file 'tests/interfaces/openlp_core_ui/test_settings_form.py' --- tests/interfaces/openlp_core_ui/test_settings_form.py 2014-03-14 22:08:44 +0000 +++ tests/interfaces/openlp_core_ui/test_settings_form.py 2014-10-22 20:57:53 +0000 @@ -59,7 +59,7 @@ self.dummy2 = MagicMock() self.dummy3 = MagicMock() self.desktop = MagicMock() - self.get_application() + self.setup_application() self.desktop.primaryScreen.return_value = SCREEN['primary'] self.desktop.screenCount.return_value = SCREEN['number'] self.desktop.screenGeometry.return_value = SCREEN['size'] === modified file 'tests/interfaces/openlp_core_ui/test_shortcutlistform.py' --- tests/interfaces/openlp_core_ui/test_shortcutlistform.py 2014-05-03 19:32:19 +0000 +++ tests/interfaces/openlp_core_ui/test_shortcutlistform.py 2014-10-22 20:57:53 +0000 @@ -46,7 +46,7 @@ Create the UI """ Registry.create() - self.get_application() + self.setup_application() self.main_window = QtGui.QMainWindow() Registry().register('main_window', self.main_window) self.form = ShortcutListForm() === modified file 'tests/interfaces/openlp_core_ui/test_starttimedialog.py' --- tests/interfaces/openlp_core_ui/test_starttimedialog.py 2014-03-14 22:08:44 +0000 +++ tests/interfaces/openlp_core_ui/test_starttimedialog.py 2014-10-22 20:57:53 +0000 @@ -46,7 +46,7 @@ Create the UI """ Registry.create() - self.get_application() + self.setup_application() self.main_window = QtGui.QMainWindow() Registry().register('main_window', self.main_window) self.form = starttimeform.StartTimeForm() === modified file 'tests/interfaces/openlp_core_ui/test_thememanager.py' --- tests/interfaces/openlp_core_ui/test_thememanager.py 2014-03-14 17:37:28 +0000 +++ tests/interfaces/openlp_core_ui/test_thememanager.py 2014-10-22 20:57:53 +0000 @@ -46,7 +46,7 @@ Create the UI """ self.build_settings() - self.get_application() + self.setup_application() Registry.create() self.theme_manager = ThemeManager() === modified file 'tests/interfaces/openlp_core_utils/test_utils.py' --- tests/interfaces/openlp_core_utils/test_utils.py 2014-04-02 19:35:09 +0000 +++ tests/interfaces/openlp_core_utils/test_utils.py 2014-10-22 20:57:53 +0000 @@ -46,7 +46,7 @@ """ Some pre-test setup required. """ - self.get_application() + self.setup_application() def is_not_image_empty_test(self): """ === modified file 'tests/interfaces/openlp_plugins/custom/forms/test_customform.py' --- tests/interfaces/openlp_plugins/custom/forms/test_customform.py 2014-04-02 19:35:09 +0000 +++ tests/interfaces/openlp_plugins/custom/forms/test_customform.py 2014-10-22 20:57:53 +0000 @@ -50,7 +50,7 @@ Create the UI """ Registry.create() - self.get_application() + self.setup_application() self.main_window = QtGui.QMainWindow() Registry().register('main_window', self.main_window) media_item = MagicMock() === modified file 'tests/interfaces/openlp_plugins/custom/forms/test_customslideform.py' --- tests/interfaces/openlp_plugins/custom/forms/test_customslideform.py 2014-04-02 19:35:09 +0000 +++ tests/interfaces/openlp_plugins/custom/forms/test_customslideform.py 2014-10-22 20:57:53 +0000 @@ -48,7 +48,7 @@ Create the UI """ Registry.create() - self.get_application() + self.setup_application() self.main_window = QtGui.QMainWindow() Registry().register('main_window', self.main_window) self.form = EditCustomSlideForm() === modified file 'tests/interfaces/openlp_plugins/media/forms/test_mediaclipselectorform.py' --- tests/interfaces/openlp_plugins/media/forms/test_mediaclipselectorform.py 2014-09-08 20:58:42 +0000 +++ tests/interfaces/openlp_plugins/media/forms/test_mediaclipselectorform.py 2014-10-22 20:57:53 +0000 @@ -54,7 +54,7 @@ Create the UI """ Registry.create() - self.get_application() + self.setup_application() self.main_window = QtGui.QMainWindow() Registry().register('main_window', self.main_window) # Mock VLC so we don't actually use it === modified file 'tests/interfaces/openlp_plugins/songs/forms/test_authorsform.py' --- tests/interfaces/openlp_plugins/songs/forms/test_authorsform.py 2014-04-02 19:35:09 +0000 +++ tests/interfaces/openlp_plugins/songs/forms/test_authorsform.py 2014-10-22 20:57:53 +0000 @@ -48,7 +48,7 @@ Create the UI """ Registry.create() - self.get_application() + self.setup_application() self.main_window = QtGui.QMainWindow() Registry().register('main_window', self.main_window) self.form = AuthorsForm() === modified file 'tests/interfaces/openlp_plugins/songs/forms/test_editsongform.py' --- tests/interfaces/openlp_plugins/songs/forms/test_editsongform.py 2014-03-14 22:08:44 +0000 +++ tests/interfaces/openlp_plugins/songs/forms/test_editsongform.py 2014-10-22 20:57:53 +0000 @@ -49,7 +49,7 @@ Create the UI """ Registry.create() - self.get_application() + self.setup_application() self.main_window = QtGui.QMainWindow() Registry().register('main_window', self.main_window) Registry().register('theme_manager', MagicMock()) === modified file 'tests/interfaces/openlp_plugins/songs/forms/test_editverseform.py' --- tests/interfaces/openlp_plugins/songs/forms/test_editverseform.py 2014-04-02 19:35:09 +0000 +++ tests/interfaces/openlp_plugins/songs/forms/test_editverseform.py 2014-10-22 20:57:53 +0000 @@ -48,7 +48,7 @@ Create the UI """ Registry.create() - self.get_application() + self.setup_application() self.main_window = QtGui.QMainWindow() Registry().register('main_window', self.main_window) self.form = EditVerseForm() === modified file 'tests/interfaces/openlp_plugins/songs/forms/test_topicsform.py' --- tests/interfaces/openlp_plugins/songs/forms/test_topicsform.py 2014-03-14 22:08:44 +0000 +++ tests/interfaces/openlp_plugins/songs/forms/test_topicsform.py 2014-10-22 20:57:53 +0000 @@ -48,7 +48,7 @@ Create the UI """ Registry.create() - self.get_application() + self.setup_application() self.main_window = QtGui.QMainWindow() Registry().register('main_window', self.main_window) self.form = TopicsForm()
_______________________________________________ Mailing list: https://launchpad.net/~openlp-core Post to : openlp-core@lists.launchpad.net Unsubscribe : https://launchpad.net/~openlp-core More help : https://help.launchpad.net/ListHelp