Fix tests and code

This commit is contained in:
Tim Bentley 2018-12-02 09:49:30 +00:00
parent 65fb592d1f
commit c1c8f3e75d
4 changed files with 12 additions and 2 deletions

View File

@ -24,6 +24,7 @@ from unittest.mock import MagicMock
from PyQt5 import QtCore
from openlp.core.state import State
from openlp.core.common.registry import Registry
from openlp.core.api.endpoint.controller import controller_text, controller_direction
from openlp.core.display.renderer import Renderer
@ -83,6 +84,9 @@ class TestController(TestCase):
# GIVEN: A mocked service with a dummy service item
line = convert_file_service_item(TEST_PATH, 'serviceitem_custom_1.osj')
self.mocked_live_controller.service_item = ServiceItem(None)
State().add_service("media", 0)
State().update_pre_conditions("media", True)
State().flush_preconditions()
self.mocked_live_controller.service_item.set_from_service(line)
self.mocked_live_controller.service_item.render(True)
# WHEN: I trigger the method

View File

@ -184,4 +184,4 @@ class TestRegistryBase(TestCase):
RegistryStub()
# THEN: The bootstrap methods should be registered
assert len(Registry().functions_list) == 2, 'The bootstrap functions should be in the dict.'
assert len(Registry().functions_list) == 3, 'The bootstrap functions should be in the dict.'

View File

@ -85,6 +85,9 @@ class TestMediaManagerItem(TestCase, TestMixin):
mocked_settings.value.side_effect = lambda x: x == 'advanced/double click live'
MockedSettings.return_value = mocked_settings
mmi = MediaManagerItem(None)
mmi.can_preview = True
mmi.can_make_live = True
mmi.can_add_to_service = True
# WHEN: on_double_clicked() is called
mmi.on_double_clicked()
@ -105,6 +108,9 @@ class TestMediaManagerItem(TestCase, TestMixin):
mocked_settings.value.side_effect = lambda x: x == 'advanced/single click preview'
MockedSettings.return_value = mocked_settings
mmi = MediaManagerItem(None)
mmi.can_preview = True
mmi.can_make_live = True
mmi.can_add_to_service = True
# WHEN: on_double_clicked() is called
mmi.on_double_clicked()

View File

@ -74,7 +74,7 @@ class TestState(TestCase, TestMixin):
State().add_service("test1", 1, PluginStatus.Active, "test")
State().add_service("test1", 1, PluginStatus.Active, "test")
# THEN I have a single saved service and one dependancy
# THEN I have a single saved service and one dependency
assert len(State().modules) == 2
assert len(State().modules['test'].required_by) == 1