forked from openlp/openlp
Test fixes
This commit is contained in:
parent
1523d9ffa6
commit
87216707d3
@ -336,6 +336,13 @@ class FirstTimeForm(QtWidgets.QWizard, UiFirstTimeWizard, RegistryProperties):
|
|||||||
proxy_dialog.retranslate_ui()
|
proxy_dialog.retranslate_ui()
|
||||||
proxy_dialog.exec()
|
proxy_dialog.exec()
|
||||||
|
|
||||||
|
def on_projectors_check_box_clicked(self):
|
||||||
|
# When clicking projectors_check box, change the visibility setting for Projectors panel.
|
||||||
|
if Settings().value('projector/show after wizard'):
|
||||||
|
Settings().setValue('projector/show after wizard', False)
|
||||||
|
else:
|
||||||
|
Settings().setValue('projector/show after wizard', True)
|
||||||
|
|
||||||
def on_themes_list_widget_selection_changed(self):
|
def on_themes_list_widget_selection_changed(self):
|
||||||
"""
|
"""
|
||||||
Update the `theme_combo_box` with the selected items
|
Update the `theme_combo_box` with the selected items
|
||||||
|
@ -326,10 +326,3 @@ class UiFirstTimeWizard(object):
|
|||||||
self.progress_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Downloading and Configuring'))
|
self.progress_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Downloading and Configuring'))
|
||||||
self.progress_page.setSubTitle(
|
self.progress_page.setSubTitle(
|
||||||
translate('OpenLP.FirstTimeWizard', 'Please wait while resources are downloaded and OpenLP is configured.'))
|
translate('OpenLP.FirstTimeWizard', 'Please wait while resources are downloaded and OpenLP is configured.'))
|
||||||
|
|
||||||
def on_projectors_check_box_clicked(self):
|
|
||||||
# When clicking projectors_check box, change the visibility setting for Projectors panel.
|
|
||||||
if Settings().value('projector/show after wizard'):
|
|
||||||
Settings().setValue('projector/show after wizard', False)
|
|
||||||
else:
|
|
||||||
Settings().setValue('projector/show after wizard', True)
|
|
||||||
|
@ -249,34 +249,30 @@ class TestGetProxySettings(TestCase, TestMixin):
|
|||||||
self.addCleanup(self.destroy_settings)
|
self.addCleanup(self.destroy_settings)
|
||||||
|
|
||||||
@patch('openlp.core.common.httputils.Settings')
|
@patch('openlp.core.common.httputils.Settings')
|
||||||
def test_mode_arg_specified(self, MockSettings):
|
def test_mode_arg_specified(self, mocked_settings):
|
||||||
"""
|
"""
|
||||||
Test that the argument is used rather than reading the 'advanced/proxy mode' setting
|
Test that the argument is used rather than reading the 'advanced/proxy mode' setting
|
||||||
"""
|
"""
|
||||||
# GIVEN: Mocked settings
|
# GIVEN: Mocked settings
|
||||||
mocked_settings = MagicMock()
|
|
||||||
MockSettings.return_value = mocked_settings
|
|
||||||
|
|
||||||
# WHEN: Calling `get_proxy_settings` with the mode arg specified
|
# WHEN: Calling `get_proxy_settings` with the mode arg specified
|
||||||
get_proxy_settings(mode=ProxyMode.NO_PROXY)
|
get_proxy_settings(mode=ProxyMode.NO_PROXY)
|
||||||
|
|
||||||
# THEN: The mode arg should have been used rather than looking it up in the settings
|
# THEN: The mode arg should have been used rather than looking it up in the settings
|
||||||
mocked_settings.value.assert_not_called()
|
mocked_settings().value.assert_not_called()
|
||||||
|
|
||||||
@patch('openlp.core.common.httputils.Settings')
|
@patch('openlp.core.common.httputils.Settings')
|
||||||
def test_mode_incorrect_arg_specified(self, MockSettings):
|
def test_mode_incorrect_arg_specified(self, mocked_settings):
|
||||||
"""
|
"""
|
||||||
Test that the system settings are used when the mode arg specieied is invalid
|
Test that the system settings are used when the mode arg specieied is invalid
|
||||||
"""
|
"""
|
||||||
# GIVEN: Mocked settings
|
# GIVEN: Mocked settings
|
||||||
mocked_settings = MagicMock()
|
|
||||||
MockSettings.return_value = mocked_settings
|
|
||||||
|
|
||||||
# WHEN: Calling `get_proxy_settings` with an invalid mode arg specified
|
# WHEN: Calling `get_proxy_settings` with an invalid mode arg specified
|
||||||
result = get_proxy_settings(mode='qwerty')
|
result = get_proxy_settings(mode='qwerty')
|
||||||
|
|
||||||
# THEN: An None should be returned
|
# THEN: An None should be returned
|
||||||
mocked_settings.value.assert_not_called()
|
mocked_settings().value.assert_not_called()
|
||||||
assert result is None
|
assert result is None
|
||||||
|
|
||||||
def test_no_proxy_mode(self):
|
def test_no_proxy_mode(self):
|
||||||
|
@ -126,7 +126,7 @@ class TestFirstTimeForm(TestCase, TestMixin):
|
|||||||
assert [] == frw.thumbnail_download_threads, 'The list of threads should be empty'
|
assert [] == frw.thumbnail_download_threads, 'The list of threads should be empty'
|
||||||
assert frw.has_run_wizard is False, 'has_run_wizard should be False'
|
assert frw.has_run_wizard is False, 'has_run_wizard should be False'
|
||||||
|
|
||||||
@patch('openlp.core.ui.firsttimewizard.QtWidgets.QWizard.exec')
|
@patch('openlp.core.ui.firsttimeform.QtWidgets.QWizard.exec')
|
||||||
def test_exec(self, mocked_qwizard_exec):
|
def test_exec(self, mocked_qwizard_exec):
|
||||||
|
|
||||||
# GIVEN: An instance of FirstTimeForm
|
# GIVEN: An instance of FirstTimeForm
|
||||||
@ -223,9 +223,10 @@ class TestFirstTimeForm(TestCase, TestMixin):
|
|||||||
mocked_theme_combo_box.findText.assert_called_once_with('Default Theme')
|
mocked_theme_combo_box.findText.assert_called_once_with('Default Theme')
|
||||||
mocked_theme_combo_box.setCurrentIndex(3)
|
mocked_theme_combo_box.setCurrentIndex(3)
|
||||||
|
|
||||||
@patch('openlp.core.ui.firsttimewizard.QtWidgets.QWizard.accept')
|
|
||||||
@patch('openlp.core.ui.firsttimewizard.Settings')
|
@patch('openlp.core.ui.firsttimeform.Settings')
|
||||||
def test_accept_method(self, mocked_settings, mocked_qwizard_accept):
|
@patch('openlp.core.ui.firsttimeform.QtWidgets.QWizard.accept')
|
||||||
|
def test_accept_method(self, mocked_qwizard_accept, *args):
|
||||||
"""
|
"""
|
||||||
Test the FirstTimeForm.accept method
|
Test the FirstTimeForm.accept method
|
||||||
"""
|
"""
|
||||||
@ -253,7 +254,7 @@ class TestFirstTimeForm(TestCase, TestMixin):
|
|||||||
mocked_screen_selection_widget.save.assert_called_once()
|
mocked_screen_selection_widget.save.assert_called_once()
|
||||||
mocked_qwizard_accept.assert_called_once()
|
mocked_qwizard_accept.assert_called_once()
|
||||||
|
|
||||||
@patch('openlp.core.ui.firsttimewizard.Settings')
|
@patch('openlp.core.ui.firsttimeform.Settings')
|
||||||
def test_accept_method_theme_not_selected(self, mocked_settings):
|
def test_accept_method_theme_not_selected(self, mocked_settings):
|
||||||
"""
|
"""
|
||||||
Test the FirstTimeForm.accept method when there is no default theme selected
|
Test the FirstTimeForm.accept method when there is no default theme selected
|
||||||
@ -261,14 +262,13 @@ class TestFirstTimeForm(TestCase, TestMixin):
|
|||||||
# GIVEN: An instance of FirstTimeForm
|
# GIVEN: An instance of FirstTimeForm
|
||||||
frw = FirstTimeForm(None)
|
frw = FirstTimeForm(None)
|
||||||
with patch.object(frw, '_set_plugin_status'), patch.object(frw, 'screen_selection_widget'), \
|
with patch.object(frw, '_set_plugin_status'), patch.object(frw, 'screen_selection_widget'), \
|
||||||
patch.object(frw, 'setup_ui'), \
|
patch.object(frw, 'theme_combo_box', **{'currentIndex.return_value': -1}):
|
||||||
patch.object(frw, 'theme_combo_box', **{'currentIndex.return_value': '-1'}):
|
|
||||||
|
|
||||||
# WHEN: Calling accept and the currentIndex method of the theme_combo_box returns -1
|
# WHEN: Calling accept and the currentIndex method of the theme_combo_box returns -1
|
||||||
frw.accept()
|
frw.accept()
|
||||||
|
|
||||||
# THEN: OpenLP should not try to save a theme name
|
# THEN: OpenLP should not try to save a theme name
|
||||||
mocked_settings.setValue.assert_not_called()
|
mocked_settings().setValue.assert_not_called()
|
||||||
|
|
||||||
@patch('openlp.core.ui.firsttimeform.Settings')
|
@patch('openlp.core.ui.firsttimeform.Settings')
|
||||||
def test_accept_method_theme_selected(self, mocked_settings):
|
def test_accept_method_theme_selected(self, mocked_settings):
|
||||||
@ -288,7 +288,7 @@ class TestFirstTimeForm(TestCase, TestMixin):
|
|||||||
# THEN: The 'currentItem' in the combobox should have been set as the default theme.
|
# THEN: The 'currentItem' in the combobox should have been set as the default theme.
|
||||||
mocked_settings().setValue.assert_called_once_with('themes/global theme', 'Test Item')
|
mocked_settings().setValue.assert_called_once_with('themes/global theme', 'Test Item')
|
||||||
|
|
||||||
@patch('openlp.core.ui.firsttimewizard.QtWidgets.QWizard.reject')
|
@patch('openlp.core.ui.firsttimeform.QtWidgets.QWizard.reject')
|
||||||
@patch('openlp.core.ui.firsttimeform.time')
|
@patch('openlp.core.ui.firsttimeform.time')
|
||||||
@patch('openlp.core.ui.firsttimeform.get_thread_worker')
|
@patch('openlp.core.ui.firsttimeform.get_thread_worker')
|
||||||
@patch('openlp.core.ui.firsttimeform.is_thread_finished')
|
@patch('openlp.core.ui.firsttimeform.is_thread_finished')
|
||||||
@ -383,7 +383,7 @@ class TestFirstTimeForm(TestCase, TestMixin):
|
|||||||
first_time_form, 'Network Error',
|
first_time_form, 'Network Error',
|
||||||
'There was a network error attempting to connect to retrieve initial configuration information', 'OK')
|
'There was a network error attempting to connect to retrieve initial configuration information', 'OK')
|
||||||
|
|
||||||
@patch('openlp.core.ui.firsttimewizard.Settings')
|
@patch('openlp.core.ui.firsttimeform.Settings')
|
||||||
def test_on_projectors_check_box_checked(self, MockSettings):
|
def test_on_projectors_check_box_checked(self, MockSettings):
|
||||||
"""
|
"""
|
||||||
Test that the projector panel is shown when the checkbox in the first time wizard is checked
|
Test that the projector panel is shown when the checkbox in the first time wizard is checked
|
||||||
@ -398,10 +398,10 @@ class TestFirstTimeForm(TestCase, TestMixin):
|
|||||||
frw.on_projectors_check_box_clicked()
|
frw.on_projectors_check_box_clicked()
|
||||||
|
|
||||||
# THEN: The visibility of the projects panel should have been set
|
# THEN: The visibility of the projects panel should have been set
|
||||||
mocked_settings.value.assert_called_once_with('projector/show after wizard')
|
mocked_settings().value.assert_called_once_with('projector/show after wizard')
|
||||||
mocked_settings.setValue.assert_called_once_with('projector/show after wizard', False)
|
mocked_settings().setValue.assert_called_once_with('projector/show after wizard', False)
|
||||||
|
|
||||||
@patch('openlp.core.ui.firsttimewizard.Settings')
|
@patch('openlp.core.ui.firsttimeform.Settings')
|
||||||
def test_on_projectors_check_box_unchecked(self, MockSettings):
|
def test_on_projectors_check_box_unchecked(self, MockSettings):
|
||||||
"""
|
"""
|
||||||
Test that the projector panel is shown when the checkbox in the first time wizard is checked
|
Test that the projector panel is shown when the checkbox in the first time wizard is checked
|
||||||
|
Loading…
Reference in New Issue
Block a user