Fix tests

This commit is contained in:
Tim Bentley 2018-12-11 21:20:32 +00:00
parent dd8503e435
commit 79eca4756a
2 changed files with 6 additions and 5 deletions

View File

@ -30,6 +30,7 @@ from tempfile import gettempdir
from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5 import QtCore, QtGui, QtWidgets
from openlp.core.state import State
from openlp.core.api import websockets from openlp.core.api import websockets
from openlp.core.api.http import server from openlp.core.api.http import server
from openlp.core.common import is_win, is_macosx, add_actions from openlp.core.common import is_win, is_macosx, add_actions
@ -652,7 +653,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, LogMixin, RegistryPropert
Import themes if first time Import themes if first time
""" """
self.application.process_events() self.application.process_events()
for plugin in self.plugin_manager.plugins: for plugin in State().list_plugins():
if hasattr(plugin, 'first_time'): if hasattr(plugin, 'first_time'):
self.application.process_events() self.application.process_events()
plugin.first_time() plugin.first_time()
@ -690,7 +691,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, LogMixin, RegistryPropert
self.projector_manager_dock.setVisible(True) self.projector_manager_dock.setVisible(True)
else: else:
self.projector_manager_dock.setVisible(False) self.projector_manager_dock.setVisible(False)
for plugin in self.plugin_manager.plugins: for plugin in State().list_plugins():
self.active_plugin = plugin self.active_plugin = plugin
old_status = self.active_plugin.status old_status = self.active_plugin.status
self.active_plugin.set_status() self.active_plugin.set_status()
@ -864,7 +865,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, LogMixin, RegistryPropert
setting_sections.extend([self.header_section]) setting_sections.extend([self.header_section])
setting_sections.extend(['crashreport']) setting_sections.extend(['crashreport'])
# Add plugin sections. # Add plugin sections.
setting_sections.extend([plugin.name for plugin in self.plugin_manager.plugins]) setting_sections.extend([plugin.name for plugin in State().list_plugins()])
# Copy the settings file to the tmp dir, because we do not want to change the original one. # Copy the settings file to the tmp dir, because we do not want to change the original one.
temp_dir_path = Path(gettempdir(), 'openlp') temp_dir_path = Path(gettempdir(), 'openlp')
create_paths(temp_dir_path) create_paths(temp_dir_path)

View File

@ -162,8 +162,8 @@ class TestMainWindow(TestCase, TestMixin):
# WHEN: you check the started functions # WHEN: you check the started functions
# THEN: the following registry functions should have been registered # THEN: the following registry functions should have been registered
assert len(self.registry.service_list) == 13, \ assert len(self.registry.service_list) == 8, \
'The registry should have 12 services, got {}'.format(self.registry.service_list.keys()) 'The registry should have 8 services, got {}'.format(self.registry.service_list.keys())
assert len(self.registry.functions_list) == 19, \ assert len(self.registry.functions_list) == 19, \
'The registry should have 19 functions, got {}'.format(self.registry.functions_list.keys()) 'The registry should have 19 functions, got {}'.format(self.registry.functions_list.keys())
assert 'application' in self.registry.service_list, 'The application should have been registered.' assert 'application' in self.registry.service_list, 'The application should have been registered.'