forked from openlp/openlp
Fix up tests
This commit is contained in:
parent
e0d8198626
commit
05be4e606c
@ -22,7 +22,7 @@
|
||||
|
||||
import json
|
||||
|
||||
from openlp.core.common import RegistryProperties, Settings, OpenLPMixin
|
||||
from openlp.core.common import RegistryProperties, Settings
|
||||
|
||||
|
||||
class OpenLPPoll(RegistryProperties):
|
||||
|
@ -149,7 +149,7 @@ class TestMainWindow(TestCase, TestMixin):
|
||||
# WHEN: you check the started functions
|
||||
|
||||
# THEN: the following registry functions should have been registered
|
||||
self.assertEqual(len(self.registry.service_list), 6, 'The registry should have 6 services.')
|
||||
self.assertEqual(len(self.registry.service_list), 7, 'The registry should have 7 services.')
|
||||
self.assertEqual(len(self.registry.functions_list), 17, 'The registry should have 17 functions')
|
||||
self.assertTrue('application' in self.registry.service_list, 'The application should have been registered.')
|
||||
self.assertTrue('main_window' in self.registry.service_list, 'The main_window should have been registered.')
|
||||
|
@ -37,8 +37,6 @@ from tests.helpers.testmixin import TestMixin
|
||||
__default_settings__ = {
|
||||
'remotes/twelve hour': True,
|
||||
'remotes/port': 4316,
|
||||
'remotes/https port': 4317,
|
||||
'remotes/https enabled': False,
|
||||
'remotes/user id': 'openlp',
|
||||
'remotes/password': 'password',
|
||||
'remotes/authentication enabled': False,
|
||||
@ -114,36 +112,5 @@ class TestRemoteTab(TestCase, TestMixin):
|
||||
self.form.set_urls()
|
||||
# THEN: the following screen values should be set
|
||||
self.assertEqual(self.form.address_edit.text(), ZERO_URL, 'The default URL should be set on the screen')
|
||||
self.assertEqual(self.form.https_settings_group_box.isEnabled(), False,
|
||||
'The Https box should not be enabled')
|
||||
self.assertEqual(self.form.https_settings_group_box.isChecked(), False,
|
||||
'The Https checked box should note be Checked')
|
||||
self.assertEqual(self.form.user_login_group_box.isChecked(), False,
|
||||
'The authentication box should not be enabled')
|
||||
|
||||
def set_certificate_urls_test(self):
|
||||
"""
|
||||
Test the set_urls function with certificate available
|
||||
"""
|
||||
# GIVEN: A mocked location
|
||||
with patch('openlp.core.common.Settings') as mocked_class, \
|
||||
patch('openlp.core.common.applocation.AppLocation.get_directory') as mocked_get_directory, \
|
||||
patch('openlp.core.common.check_directory_exists') as mocked_check_directory_exists, \
|
||||
patch('openlp.core.common.applocation.os') as mocked_os:
|
||||
# GIVEN: A mocked out Settings class and a mocked out AppLocation.get_directory()
|
||||
mocked_settings = mocked_class.return_value
|
||||
mocked_settings.contains.return_value = False
|
||||
mocked_get_directory.return_value = TEST_PATH
|
||||
mocked_check_directory_exists.return_value = True
|
||||
mocked_os.path.normpath.return_value = TEST_PATH
|
||||
|
||||
# WHEN: when the set_urls is called having reloaded the form.
|
||||
self.form.load()
|
||||
self.form.set_urls()
|
||||
# THEN: the following screen values should be set
|
||||
self.assertEqual(self.form.http_settings_group_box.isEnabled(), True,
|
||||
'The Http group box should be enabled')
|
||||
self.assertEqual(self.form.https_settings_group_box.isChecked(), False,
|
||||
'The Https checked box should be Checked')
|
||||
self.assertEqual(self.form.https_settings_group_box.isEnabled(), True,
|
||||
'The Https box should be enabled')
|
||||
|
@ -28,6 +28,7 @@ from unittest import TestCase
|
||||
|
||||
from openlp.core.common import Settings, Registry
|
||||
from openlp.core.ui import ServiceManager
|
||||
from openlp.core.lib.remote import OpenLPPoll
|
||||
from openlp.plugins.remotes.lib.httpserver import HttpRouter
|
||||
from tests.functional import MagicMock, patch, mock_open
|
||||
from tests.helpers.testmixin import TestMixin
|
||||
@ -35,8 +36,6 @@ from tests.helpers.testmixin import TestMixin
|
||||
__default_settings__ = {
|
||||
'remotes/twelve hour': True,
|
||||
'remotes/port': 4316,
|
||||
'remotes/https port': 4317,
|
||||
'remotes/https enabled': False,
|
||||
'remotes/user id': 'openlp',
|
||||
'remotes/password': 'password',
|
||||
'remotes/authentication enabled': False,
|
||||
@ -74,6 +73,8 @@ class TestRouter(TestCase, TestMixin):
|
||||
# GIVEN: A default configuration
|
||||
Settings().setValue('remotes/user id', 'openlp')
|
||||
Settings().setValue('remotes/password', 'password')
|
||||
poll = MagicMock()
|
||||
Registry().register('OpenLPPoll', poll)
|
||||
|
||||
# WHEN: called with the defined userid
|
||||
router = HttpRouter()
|
||||
@ -157,15 +158,13 @@ class TestRouter(TestCase, TestMixin):
|
||||
"""
|
||||
# GIVEN: a defined router with two slides
|
||||
Registry.create()
|
||||
Registry().register('live_controller', MagicMock)
|
||||
router = HttpRouter()
|
||||
router.send_response = MagicMock()
|
||||
router.send_header = MagicMock()
|
||||
router.end_headers = MagicMock()
|
||||
router.live_controller.slide_count = 2
|
||||
live_controller = MagicMock()
|
||||
Registry().register('live_controller', live_controller)
|
||||
poll = OpenLPPoll()
|
||||
live_controller.slide_count = 2
|
||||
|
||||
# WHEN: main poll called
|
||||
results = router.main_poll()
|
||||
results = poll.main_poll()
|
||||
|
||||
# THEN: the correct response should be returned
|
||||
self.assertEqual(results.decode('utf-8'), '{"results": {"slide_count": 2}}',
|
||||
|
Loading…
Reference in New Issue
Block a user