forked from openlp/openlp
Fix tests
This commit is contained in:
parent
e224352846
commit
47236b0238
@ -47,6 +47,7 @@ class TestPluginManager(TestCase):
|
||||
self.mocked_main_window.file_export_menu.return_value = None
|
||||
self.mocked_settings_form = MagicMock()
|
||||
Registry.create()
|
||||
State().load_settings()
|
||||
Registry().register('service_list', MagicMock())
|
||||
Registry().register('main_window', self.mocked_main_window)
|
||||
Registry().register('settings_form', self.mocked_settings_form)
|
||||
@ -365,9 +366,11 @@ class TestPluginManager(TestCase):
|
||||
mocked_plugin.status = PluginStatus.Disabled
|
||||
mocked_plugin.is_active.return_value = False
|
||||
plugin_manager = PluginManager()
|
||||
plugin_manager.plugins = [mocked_plugin]
|
||||
Registry().register('mock_plugin', mocked_plugin)
|
||||
|
||||
# WHEN: We run finalise_plugins()
|
||||
State().add_service("mock", 1, is_plugin=True, status=PluginStatus.Active)
|
||||
State().flush_preconditions()
|
||||
plugin_manager.finalise_plugins()
|
||||
|
||||
# THEN: The is_active() method should have been called, and initialise() method should NOT have been called
|
||||
@ -383,10 +386,11 @@ class TestPluginManager(TestCase):
|
||||
mocked_plugin.status = PluginStatus.Active
|
||||
mocked_plugin.is_active.return_value = True
|
||||
plugin_manager = PluginManager()
|
||||
plugin_manager.plugins = [mocked_plugin]
|
||||
Registry().register('mock_plugin', mocked_plugin)
|
||||
|
||||
# WHEN: We run finalise_plugins()
|
||||
State().add_service("mock_plugin", 1, is_plugin=True, status=PluginStatus.Active)
|
||||
State().add_service("mock", 1, is_plugin=True, status=PluginStatus.Active)
|
||||
State().flush_preconditions()
|
||||
plugin_manager.finalise_plugins()
|
||||
|
||||
# THEN: The is_active() and finalise() methods should have been called
|
||||
|
@ -20,6 +20,7 @@
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
from unittest import TestCase
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from openlp.core.state import State
|
||||
from openlp.core.common.registry import Registry
|
||||
@ -112,6 +113,7 @@ class TestState(TestCase, TestMixin):
|
||||
def test_basic_preconditions_fail(self):
|
||||
# GIVEN a new state
|
||||
State().load_settings()
|
||||
plugin = Registry().register('test_plugin', MagicMock())
|
||||
|
||||
# WHEN I add a new services with dependencies and a failed pre condition
|
||||
State().add_service("test", 1, 1, PluginStatus.Inactive)
|
||||
@ -131,6 +133,7 @@ class TestState(TestCase, TestMixin):
|
||||
def test_basic_preconditions_pass(self):
|
||||
# GIVEN a new state
|
||||
State().load_settings()
|
||||
Registry().register('test_plugin', MagicMock())
|
||||
|
||||
# WHEN I add a new services with dependencies and a failed pre condition
|
||||
State().add_service("test", 1, 1, PluginStatus.Inactive)
|
||||
|
Loading…
Reference in New Issue
Block a user