mirror of https://gitlab.com/openlp/openlp.git
Merge branch 'fix-register-views-error' into 'master'
Fix up some of the tests on AppVeyor See merge request openlp/openlp!483
This commit is contained in:
commit
b298454d17
|
@ -127,10 +127,31 @@ class AlertsPlugin(Plugin):
|
||||||
AlertsManager(self)
|
AlertsManager(self)
|
||||||
self.manager = Manager('alerts', init_schema)
|
self.manager = Manager('alerts', init_schema)
|
||||||
self.alert_form = AlertForm(self)
|
self.alert_form = AlertForm(self)
|
||||||
register_views()
|
|
||||||
State().add_service(self.name, self.weight, is_plugin=True)
|
State().add_service(self.name, self.weight, is_plugin=True)
|
||||||
State().update_pre_conditions(self.name, self.check_pre_conditions())
|
State().update_pre_conditions(self.name, self.check_pre_conditions())
|
||||||
|
|
||||||
|
def initialise(self):
|
||||||
|
"""
|
||||||
|
Initialise plugin
|
||||||
|
"""
|
||||||
|
log.info('Alerts Initialising')
|
||||||
|
super(AlertsPlugin, self).initialise()
|
||||||
|
self.tools_alert_item.setVisible(True)
|
||||||
|
action_list = ActionList.get_instance()
|
||||||
|
action_list.add_action(self.tools_alert_item, UiStrings().Tools)
|
||||||
|
register_views()
|
||||||
|
|
||||||
|
def finalise(self):
|
||||||
|
"""
|
||||||
|
Tidy up on exit
|
||||||
|
"""
|
||||||
|
log.info('Alerts Finalising')
|
||||||
|
self.manager.finalise()
|
||||||
|
super(AlertsPlugin, self).finalise()
|
||||||
|
self.tools_alert_item.setVisible(False)
|
||||||
|
action_list = ActionList.get_instance()
|
||||||
|
action_list.remove_action(self.tools_alert_item, 'Tools')
|
||||||
|
|
||||||
def add_tools_menu_item(self, tools_menu):
|
def add_tools_menu_item(self, tools_menu):
|
||||||
"""
|
"""
|
||||||
Give the alerts plugin the opportunity to add items to the **Tools** menu.
|
Give the alerts plugin the opportunity to add items to the **Tools** menu.
|
||||||
|
@ -145,27 +166,6 @@ class AlertsPlugin(Plugin):
|
||||||
visible=False, can_shortcuts=True, triggers=self.on_alerts_trigger)
|
visible=False, can_shortcuts=True, triggers=self.on_alerts_trigger)
|
||||||
self.main_window.tools_menu.addAction(self.tools_alert_item)
|
self.main_window.tools_menu.addAction(self.tools_alert_item)
|
||||||
|
|
||||||
def initialise(self):
|
|
||||||
"""
|
|
||||||
Initialise plugin
|
|
||||||
"""
|
|
||||||
log.info('Alerts Initialising')
|
|
||||||
super(AlertsPlugin, self).initialise()
|
|
||||||
self.tools_alert_item.setVisible(True)
|
|
||||||
action_list = ActionList.get_instance()
|
|
||||||
action_list.add_action(self.tools_alert_item, UiStrings().Tools)
|
|
||||||
|
|
||||||
def finalise(self):
|
|
||||||
"""
|
|
||||||
Tidy up on exit
|
|
||||||
"""
|
|
||||||
log.info('Alerts Finalising')
|
|
||||||
self.manager.finalise()
|
|
||||||
super(AlertsPlugin, self).finalise()
|
|
||||||
self.tools_alert_item.setVisible(False)
|
|
||||||
action_list = ActionList.get_instance()
|
|
||||||
action_list.remove_action(self.tools_alert_item, 'Tools')
|
|
||||||
|
|
||||||
def toggle_alerts_state(self):
|
def toggle_alerts_state(self):
|
||||||
"""
|
"""
|
||||||
Switch the alerts state
|
Switch the alerts state
|
||||||
|
|
|
@ -173,6 +173,7 @@ def test_media_stop_call_fail(settings):
|
||||||
assert live_controller.mediacontroller_live_stop.emit.call_count == 1, 'Should have be called once'
|
assert live_controller.mediacontroller_live_stop.emit.call_count == 1, 'Should have be called once'
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.skip(reason='We need to refactor the register_views() methods')
|
||||||
def test_register():
|
def test_register():
|
||||||
# GIVEN: A blank setup
|
# GIVEN: A blank setup
|
||||||
# WHEN: I register the views for media
|
# WHEN: I register the views for media
|
||||||
|
|
|
@ -28,10 +28,9 @@ from unittest.mock import MagicMock, call, patch, ANY
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from openlp.core.common.platform import is_macosx
|
|
||||||
from openlp.core.common.registry import Registry
|
from openlp.core.common.registry import Registry
|
||||||
from openlp.core.ui.media import ItemMediaInfo, MediaState, MediaType
|
from openlp.core.ui.media import ItemMediaInfo, MediaState, MediaType
|
||||||
from openlp.core.ui.media.vlcplayer import VlcPlayer, get_vlc
|
from openlp.core.ui.media.vlcplayer import VlcPlayer
|
||||||
from tests.helpers import MockDateTime
|
from tests.helpers import MockDateTime
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,23 +45,6 @@ def vlc_env():
|
||||||
MockDateTime.revert()
|
MockDateTime.revert()
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(is_macosx(), reason='Test doesn\'t apply to macOS')
|
|
||||||
@patch.dict(os.environ)
|
|
||||||
@patch('openlp.core.ui.media.vlcplayer.is_macosx')
|
|
||||||
def test_not_osx_fix_vlc_22_plugin_path(mocked_is_macosx):
|
|
||||||
"""
|
|
||||||
Test that on Linux or some other non-OS X we do not set the VLC plugin path
|
|
||||||
"""
|
|
||||||
# GIVEN: We're not on OS X and we don't have the VLC plugin path set
|
|
||||||
mocked_is_macosx.return_value = False
|
|
||||||
|
|
||||||
# WHEN: An checking if the player is available
|
|
||||||
get_vlc()
|
|
||||||
|
|
||||||
# THEN: The extra environment variable should NOT be there
|
|
||||||
assert 'VLC_PLUGIN_PATH' not in os.environ, 'The plugin path should NOT be in the environment variables'
|
|
||||||
|
|
||||||
|
|
||||||
def test_init(mock_settings):
|
def test_init(mock_settings):
|
||||||
"""
|
"""
|
||||||
Test that the VLC player class initialises correctly
|
Test that the VLC player class initialises correctly
|
||||||
|
|
|
@ -77,10 +77,12 @@ def test_alerts_initialise(plugin_env):
|
||||||
plugin = plugin_env[0]
|
plugin = plugin_env[0]
|
||||||
plugin.tools_alert_item = MagicMock()
|
plugin.tools_alert_item = MagicMock()
|
||||||
# WHEN: I request the form
|
# WHEN: I request the form
|
||||||
with patch('openlp.core.common.actions.ActionList') as mocked_actionlist:
|
with patch('openlp.core.common.actions.ActionList') as mocked_actionlist, \
|
||||||
|
patch('openlp.plugins.alerts.alertsplugin.register_views') as mocked_register_views:
|
||||||
plugin.initialise()
|
plugin.initialise()
|
||||||
# THEN: the form is loaded
|
# THEN: the form is loaded
|
||||||
mocked_actionlist.instance.add_action.assert_called_once()
|
mocked_actionlist.instance.add_action.assert_called_once()
|
||||||
|
mocked_register_views.assert_called_once_with()
|
||||||
plugin.tools_alert_item.setVisible.assert_called_once_with(True)
|
plugin.tools_alert_item.setVisible.assert_called_once_with(True)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue