forked from openlp/openlp
HEAD
This commit is contained in:
commit
ca581d00bd
|
@ -80,6 +80,7 @@ def extension_loader(glob_pattern, excluded_files=[]):
|
|||
extension_path = extension_path.relative_to(app_dir)
|
||||
if extension_path.name in excluded_files:
|
||||
continue
|
||||
log.debug('Attempting to import %s', extension_path)
|
||||
module_name = path_to_module(extension_path)
|
||||
try:
|
||||
importlib.import_module(module_name)
|
||||
|
|
|
@ -25,7 +25,6 @@ OpenLP work.
|
|||
"""
|
||||
import html
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import math
|
||||
|
||||
|
|
|
@ -23,13 +23,12 @@
|
|||
Provides the generic functions for interfacing plugins with the Media Manager.
|
||||
"""
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
|
||||
from PyQt5 import QtCore, QtWidgets
|
||||
|
||||
from openlp.core.common.i18n import UiStrings, translate
|
||||
from openlp.core.common.path import Path, path_to_str, str_to_path
|
||||
from openlp.core.common.path import path_to_str, str_to_path
|
||||
from openlp.core.common.mixins import RegistryProperties
|
||||
from openlp.core.common.registry import Registry
|
||||
from openlp.core.common.settings import Settings
|
||||
|
|
|
@ -71,7 +71,7 @@ class PluginManager(RegistryBase, LogMixin, RegistryProperties):
|
|||
"""
|
||||
Scan a directory for objects inheriting from the ``Plugin`` class.
|
||||
"""
|
||||
glob_pattern = os.path.join('plugins', '*', '*plugin.py')
|
||||
glob_pattern = os.path.join('plugins', '*', '[!.]*plugin.py')
|
||||
extension_loader(glob_pattern)
|
||||
plugin_classes = Plugin.__subclasses__()
|
||||
plugin_objects = []
|
||||
|
|
|
@ -181,7 +181,8 @@ class MediaController(RegistryBase, LogMixin, RegistryProperties):
|
|||
"""
|
||||
log.debug('_check_available_media_players')
|
||||
controller_dir = os.path.join('core', 'ui', 'media')
|
||||
glob_pattern = os.path.join(controller_dir, '*player.py')
|
||||
# Find all files that do not begin with '.' (lp:#1738047) and end with player.py
|
||||
glob_pattern = os.path.join(controller_dir, '[!.]*player.py')
|
||||
extension_loader(glob_pattern, ['mediaplayer.py'])
|
||||
player_classes = MediaPlayer.__subclasses__()
|
||||
for player_class in player_classes:
|
||||
|
|
|
@ -370,7 +370,7 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi
|
|||
:rtype: None
|
||||
"""
|
||||
self._service_path = file_path
|
||||
self.main_window.set_service_modified(self.is_modified(), file_path.name)
|
||||
self.set_modified(self.is_modified())
|
||||
Settings().setValue('servicemanager/last file', file_path)
|
||||
if file_path and file_path.suffix == '.oszl':
|
||||
self._save_lite = True
|
||||
|
|
|
@ -336,6 +336,7 @@ class BibleImportForm(OpenLPWizard):
|
|||
self.sword_layout.addWidget(self.sword_tab_widget)
|
||||
self.sword_disabled_label = QtWidgets.QLabel(self.sword_widget)
|
||||
self.sword_disabled_label.setObjectName('SwordDisabledLabel')
|
||||
self.sword_disabled_label.setWordWrap(True)
|
||||
self.sword_layout.addWidget(self.sword_disabled_label)
|
||||
self.select_stack.addWidget(self.sword_widget)
|
||||
self.wordproject_widget = QtWidgets.QWidget(self.select_page)
|
||||
|
|
|
@ -129,7 +129,8 @@ class PresentationPlugin(Plugin):
|
|||
"""
|
||||
log.debug('check_pre_conditions')
|
||||
controller_dir = os.path.join('plugins', 'presentations', 'lib')
|
||||
glob_pattern = os.path.join(controller_dir, '*controller.py')
|
||||
# Find all files that do not begin with '.' (lp:#1738047) and end with controller.py
|
||||
glob_pattern = os.path.join(controller_dir, '[!.]*controller.py')
|
||||
extension_loader(glob_pattern, ['presentationcontroller.py'])
|
||||
controller_classes = PresentationController.__subclasses__()
|
||||
for controller_class in controller_classes:
|
||||
|
|
|
@ -57,16 +57,17 @@ class OpenLPJobs(object):
|
|||
This class holds any jobs we have on jenkins and we actually need in this script.
|
||||
"""
|
||||
Branch_Pull = 'Branch-01-Pull'
|
||||
Branch_Functional = 'Branch-02-Functional-Tests'
|
||||
Branch_Interface = 'Branch-03-Interface-Tests'
|
||||
Branch_PEP = 'Branch-04a-Code_Analysis'
|
||||
Branch_Coverage = 'Branch-04b-Test_Coverage'
|
||||
Branch_Pylint = 'Branch-04c-Code_Analysis2'
|
||||
Branch_AppVeyor = 'Branch-05-AppVeyor-Tests'
|
||||
Branch_macOS = 'Branch-07-macOS-Tests'
|
||||
Branch_Linux_Tests = 'Branch-02a-Linux-Tests'
|
||||
Branch_macOS_Tests = 'Branch-02b-macOS-Tests'
|
||||
Branch_Build_Source = 'Branch-03a-Build-Source'
|
||||
Branch_Build_macOS = 'Branch-03b-Build-macOS'
|
||||
Branch_Code_Analysis = 'Branch-04a-Code-Analysis'
|
||||
Branch_Test_Coverage = 'Branch-04b-Test-Coverage'
|
||||
Branch_Lint_Check = 'Branch-04c-Lint-Check'
|
||||
Branch_AppVeyor_Tests = 'Branch-05-AppVeyor-Tests'
|
||||
|
||||
Jobs = [Branch_Pull, Branch_Functional, Branch_Interface, Branch_PEP, Branch_Coverage, Branch_Pylint,
|
||||
Branch_AppVeyor, Branch_macOS]
|
||||
Jobs = [Branch_Pull, Branch_Linux_Tests, Branch_macOS_Tests, Branch_Build_Source, Branch_Build_macOS,
|
||||
Branch_Code_Analysis, Branch_Test_Coverage, Branch_AppVeyor_Tests]
|
||||
|
||||
|
||||
class Colour(object):
|
||||
|
|
|
@ -42,8 +42,8 @@ class TestApiError(TestCase):
|
|||
raise NotFound()
|
||||
|
||||
# THEN: we get an error and a status
|
||||
self.assertEquals('Not Found', context.exception.message, 'A Not Found exception should be thrown')
|
||||
self.assertEquals(404, context.exception.status, 'A 404 status should be thrown')
|
||||
assert 'Not Found' == context.exception.message, 'A Not Found exception should be thrown'
|
||||
assert 404 == context.exception.status, 'A 404 status should be thrown'
|
||||
|
||||
def test_server_error(self):
|
||||
"""
|
||||
|
@ -55,5 +55,5 @@ class TestApiError(TestCase):
|
|||
raise ServerError()
|
||||
|
||||
# THEN: we get an error and a status
|
||||
self.assertEquals('Server Error', context.exception.message, 'A Not Found exception should be thrown')
|
||||
self.assertEquals(500, context.exception.status, 'A 500 status should be thrown')
|
||||
assert'Server Error' == context.exception.message, 'A Not Found exception should be thrown'
|
||||
assert 500 == context.exception.status, 'A 500 status should be thrown'
|
||||
|
|
|
@ -53,8 +53,8 @@ class TestHttpServer(TestCase):
|
|||
HttpServer()
|
||||
|
||||
# THEN: the api environment should have been created
|
||||
self.assertEquals(1, mock_qthread.call_count, 'The qthread should have been called once')
|
||||
self.assertEquals(1, mock_thread.call_count, 'The http thread should have been called once')
|
||||
assert mock_qthread.call_count == 1, 'The qthread should have been called once'
|
||||
assert mock_thread.call_count == 1, 'The http thread should have been called once'
|
||||
|
||||
@patch('openlp.core.api.http.server.HttpWorker')
|
||||
@patch('openlp.core.api.http.server.QtCore.QThread')
|
||||
|
@ -68,5 +68,5 @@ class TestHttpServer(TestCase):
|
|||
HttpServer()
|
||||
|
||||
# THEN: the api environment should have been created
|
||||
self.assertEquals(0, mock_qthread.call_count, 'The qthread should not have have been called')
|
||||
self.assertEquals(0, mock_thread.call_count, 'The http thread should not have been called')
|
||||
assert mock_qthread.call_count == 0, 'The qthread should not have have been called'
|
||||
assert mock_thread.call_count == 0, 'The http thread should not have been called'
|
||||
|
|
|
@ -61,7 +61,7 @@ class TestRouting(TestCase):
|
|||
application.dispatch(rqst)
|
||||
|
||||
# THEN: the not found returned
|
||||
self.assertEqual(context.exception.args[0], 'Not Found', 'URL not found in dispatcher')
|
||||
assert context.exception.args[0] == 'Not Found', 'URL not found in dispatcher'
|
||||
|
||||
# WHEN: when the URL is correct and dispatch called
|
||||
rqst = MagicMock()
|
||||
|
@ -69,8 +69,8 @@ class TestRouting(TestCase):
|
|||
rqst.method = 'GET'
|
||||
application.dispatch(rqst)
|
||||
# THEN: the not found id called
|
||||
self.assertEqual(1, application.route_map['^\\/test\\/image$']['GET'].call_count,
|
||||
'main_index function should have been called')
|
||||
assert 1 == application.route_map['^\\/test\\/image$']['GET'].call_count, \
|
||||
'main_index function should have been called'
|
||||
|
||||
|
||||
@test_endpoint.route('image')
|
||||
|
|
|
@ -58,4 +58,4 @@ class TestRemoteDeploy(TestCase):
|
|||
deploy_zipfile(self.app_root_path, 'site.zip')
|
||||
|
||||
# THEN: test if www directory has been created
|
||||
self.assertTrue((self.app_root_path / 'www').is_dir(), 'We should have a www directory')
|
||||
assert (self.app_root_path / 'www').is_dir(), 'We should have a www directory'
|
||||
|
|
|
@ -81,8 +81,8 @@ class TestApiTab(TestCase, TestMixin):
|
|||
# WHEN: the default ip address is given
|
||||
ip_address = self.form.get_ip_address(ZERO_URL)
|
||||
# THEN: the default ip address will be returned
|
||||
self.assertTrue(re.match('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', ip_address),
|
||||
'The return value should be a valid ip address')
|
||||
assert re.match('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', ip_address), \
|
||||
'The return value should be a valid ip address'
|
||||
|
||||
def test_get_ip_address_with_ip(self):
|
||||
"""
|
||||
|
@ -93,7 +93,7 @@ class TestApiTab(TestCase, TestMixin):
|
|||
# WHEN: the default ip address is given
|
||||
ip_address = self.form.get_ip_address(given_ip)
|
||||
# THEN: the default ip address will be returned
|
||||
self.assertEqual(ip_address, given_ip, 'The return value should be %s' % given_ip)
|
||||
assert ip_address == given_ip, 'The return value should be %s' % given_ip
|
||||
|
||||
def test_set_urls(self):
|
||||
"""
|
||||
|
@ -104,12 +104,11 @@ class TestApiTab(TestCase, TestMixin):
|
|||
# WHEN: the urls are generated
|
||||
self.form.set_urls()
|
||||
# THEN: the following links are returned
|
||||
self.assertEqual(self.form.remote_url.text(),
|
||||
"<a href=\"http://192.168.1.1:4316/\">http://192.168.1.1:4316/</a>",
|
||||
'The return value should be a fully formed link')
|
||||
self.assertEqual(self.form.stage_url.text(),
|
||||
"<a href=\"http://192.168.1.1:4316/stage\">http://192.168.1.1:4316/stage</a>",
|
||||
'The return value should be a fully formed stage link')
|
||||
self.assertEqual(self.form.live_url.text(),
|
||||
"<a href=\"http://192.168.1.1:4316/main\">http://192.168.1.1:4316/main</a>",
|
||||
'The return value should be a fully formed main link')
|
||||
assert self.form.remote_url.text() == "<a href=\"http://192.168.1.1:4316/\">http://192.168.1.1:4316/</a>", \
|
||||
'The return value should be a fully formed link'
|
||||
assert self.form.stage_url.text() == \
|
||||
"<a href=\"http://192.168.1.1:4316/stage\">http://192.168.1.1:4316/stage</a>", \
|
||||
'The return value should be a fully formed stage link'
|
||||
assert self.form.live_url.text() == \
|
||||
"<a href=\"http://192.168.1.1:4316/main\">http://192.168.1.1:4316/main</a>", \
|
||||
'The return value should be a fully formed main link'
|
||||
|
|
|
@ -74,8 +74,8 @@ class TestWSServer(TestCase, TestMixin):
|
|||
WebSocketServer()
|
||||
|
||||
# THEN: the api environment should have been created
|
||||
self.assertEquals(1, mock_qthread.call_count, 'The qthread should have been called once')
|
||||
self.assertEquals(1, mock_worker.call_count, 'The http thread should have been called once')
|
||||
assert mock_qthread.call_count == 1, 'The qthread should have been called once'
|
||||
assert mock_worker.call_count == 1, 'The http thread should have been called once'
|
||||
|
||||
@patch('openlp.core.api.websockets.WebSocketWorker')
|
||||
@patch('openlp.core.api.websockets.QtCore.QThread')
|
||||
|
@ -89,8 +89,8 @@ class TestWSServer(TestCase, TestMixin):
|
|||
WebSocketServer()
|
||||
|
||||
# THEN: the api environment should have been created
|
||||
self.assertEquals(0, mock_qthread.call_count, 'The qthread should not have been called')
|
||||
self.assertEquals(0, mock_worker.call_count, 'The http thread should not have been called')
|
||||
assert mock_qthread.call_count == 0, 'The qthread should not have been called'
|
||||
assert mock_worker.call_count == 0, 'The http thread should not have been called'
|
||||
|
||||
def test_main_poll(self):
|
||||
"""
|
||||
|
@ -102,8 +102,7 @@ class TestWSServer(TestCase, TestMixin):
|
|||
Registry().register('live_controller', mocked_live_controller)
|
||||
# THEN: the live json should be generated
|
||||
main_json = self.poll.main_poll()
|
||||
self.assertEquals(b'{"results": {"slide_count": 5}}', main_json,
|
||||
'The return value should match the defined json')
|
||||
assert b'{"results": {"slide_count": 5}}' == main_json, 'The return value should match the defined json'
|
||||
|
||||
def test_poll(self):
|
||||
"""
|
||||
|
@ -130,13 +129,13 @@ class TestWSServer(TestCase, TestMixin):
|
|||
mocked_is_chords_active.return_value = True
|
||||
poll_json = self.poll.poll()
|
||||
# THEN: the live json should be generated and match expected results
|
||||
self.assertTrue(poll_json['results']['blank'], 'The blank return value should be True')
|
||||
self.assertFalse(poll_json['results']['theme'], 'The theme return value should be False')
|
||||
self.assertFalse(poll_json['results']['display'], 'The display return value should be False')
|
||||
self.assertFalse(poll_json['results']['isSecure'], 'The isSecure return value should be False')
|
||||
self.assertFalse(poll_json['results']['isAuthorised'], 'The isAuthorised return value should be False')
|
||||
self.assertTrue(poll_json['results']['twelve'], 'The twelve return value should be False')
|
||||
self.assertEquals(poll_json['results']['version'], 3, 'The version return value should be 3')
|
||||
self.assertEquals(poll_json['results']['slide'], 5, 'The slide return value should be 5')
|
||||
self.assertEquals(poll_json['results']['service'], 21, 'The version return value should be 21')
|
||||
self.assertEquals(poll_json['results']['item'], '23-34-45', 'The item return value should match 23-34-45')
|
||||
assert poll_json['results']['blank'] is True, 'The blank return value should be True'
|
||||
assert poll_json['results']['theme'] is False, 'The theme return value should be False'
|
||||
assert poll_json['results']['display'] is False, 'The display return value should be False'
|
||||
assert poll_json['results']['isSecure'] is False, 'The isSecure return value should be False'
|
||||
assert poll_json['results']['isAuthorised'] is False, 'The isAuthorised return value should be False'
|
||||
assert poll_json['results']['twelve'] is True, 'The twelve return value should be True'
|
||||
assert poll_json['results']['version'] == 3, 'The version return value should be 3'
|
||||
assert poll_json['results']['slide'] == 5, 'The slide return value should be 5'
|
||||
assert poll_json['results']['service'] == 21, 'The version return value should be 21'
|
||||
assert poll_json['results']['item'] == '23-34-45', 'The item return value should match 23-34-45'
|
||||
|
|
|
@ -59,8 +59,8 @@ class TestCategoryActionList(TestCase):
|
|||
self.list.append(self.action1)
|
||||
|
||||
# THEN: The actions should (not) be in the list.
|
||||
self.assertTrue(self.action1 in self.list)
|
||||
self.assertFalse(self.action2 in self.list)
|
||||
assert self.action1 in self.list
|
||||
assert self.action2 not in self.list
|
||||
|
||||
def test_len(self):
|
||||
"""
|
||||
|
@ -69,14 +69,14 @@ class TestCategoryActionList(TestCase):
|
|||
# GIVEN: The list.
|
||||
# WHEN: Do nothing.
|
||||
# THEN: Check the length.
|
||||
self.assertEqual(len(self.list), 0, "The length should be 0.")
|
||||
assert len(self.list) == 0, "The length should be 0."
|
||||
|
||||
# GIVEN: The list.
|
||||
# WHEN: Append an action.
|
||||
self.list.append(self.action1)
|
||||
|
||||
# THEN: Check the length.
|
||||
self.assertEqual(len(self.list), 1, "The length should be 1.")
|
||||
assert len(self.list) == 1, "The length should be 1."
|
||||
|
||||
def test_append(self):
|
||||
"""
|
||||
|
@ -88,10 +88,10 @@ class TestCategoryActionList(TestCase):
|
|||
self.list.append(self.action2)
|
||||
|
||||
# THEN: Check if the actions are in the list and check if they have the correct weights.
|
||||
self.assertTrue(self.action1 in self.list)
|
||||
self.assertTrue(self.action2 in self.list)
|
||||
self.assertEqual(self.list.actions[0], (0, self.action1))
|
||||
self.assertEqual(self.list.actions[1], (1, self.action2))
|
||||
assert self.action1 in self.list
|
||||
assert self.action2 in self.list
|
||||
assert self.list.actions[0] == (0, self.action1)
|
||||
assert self.list.actions[1] == (1, self.action2)
|
||||
|
||||
def test_add(self):
|
||||
"""
|
||||
|
@ -106,11 +106,11 @@ class TestCategoryActionList(TestCase):
|
|||
self.list.add(self.action2, action2_weight)
|
||||
|
||||
# THEN: Check if they were added and have the specified weights.
|
||||
self.assertTrue(self.action1 in self.list)
|
||||
self.assertTrue(self.action2 in self.list)
|
||||
assert self.action1 in self.list
|
||||
assert self.action2 in self.list
|
||||
# Now check if action1 is second and action2 is first (due to their weights).
|
||||
self.assertEqual(self.list.actions[0], (41, self.action2))
|
||||
self.assertEqual(self.list.actions[1], (42, self.action1))
|
||||
assert self.list.actions[0] == (41, self.action2)
|
||||
assert self.list.actions[1] == (42, self.action1)
|
||||
|
||||
def test_iterator(self):
|
||||
"""
|
||||
|
@ -121,11 +121,11 @@ class TestCategoryActionList(TestCase):
|
|||
self.list.add(self.action2)
|
||||
|
||||
# WHEN: Iterating over the list
|
||||
list = [a for a in self.list]
|
||||
local_list = [a for a in self.list]
|
||||
# THEN: Make sure they are returned in correct order
|
||||
self.assertEquals(len(self.list), 2)
|
||||
self.assertIs(list[0], self.action1)
|
||||
self.assertIs(list[1], self.action2)
|
||||
assert len(self.list) == 2
|
||||
assert local_list[0] is self.action1
|
||||
assert local_list[1] is self.action2
|
||||
|
||||
def test_remove(self):
|
||||
"""
|
||||
|
@ -138,7 +138,7 @@ class TestCategoryActionList(TestCase):
|
|||
self.list.remove(self.action1)
|
||||
|
||||
# THEN: Now the element should not be in the list anymore.
|
||||
self.assertFalse(self.action1 in self.list)
|
||||
assert self.action1 not in self.list
|
||||
|
||||
# THEN: Check if an exception is raised when trying to remove a not present action.
|
||||
self.assertRaises(ValueError, self.list.remove, self.action2)
|
||||
|
|
|
@ -48,7 +48,7 @@ class TestCommonFunctions(TestCase):
|
|||
extension_loader('glob', ['file2.py', 'file3.py'])
|
||||
|
||||
# THEN: `extension_loader` should not try to import any files
|
||||
self.assertFalse(mocked_import_module.called)
|
||||
assert mocked_import_module.called is False
|
||||
|
||||
def test_extension_loader_files_found(self):
|
||||
"""
|
||||
|
@ -69,7 +69,8 @@ class TestCommonFunctions(TestCase):
|
|||
|
||||
# THEN: `extension_loader` should only try to import the files that are matched by the blob, excluding the
|
||||
# files listed in the `excluded_files` argument
|
||||
mocked_import_module.assert_has_calls([call('openlp.import_dir.file1'), call('openlp.import_dir.file4')])
|
||||
mocked_import_module.assert_has_calls([call('openlp.import_dir.file1'),
|
||||
call('openlp.import_dir.file4')])
|
||||
|
||||
def test_extension_loader_import_error(self):
|
||||
"""
|
||||
|
@ -87,7 +88,7 @@ class TestCommonFunctions(TestCase):
|
|||
extension_loader('glob')
|
||||
|
||||
# THEN: The `ImportError` should be caught and logged
|
||||
self.assertTrue(mocked_logger.warning.called)
|
||||
assert mocked_logger.warning.called
|
||||
|
||||
def test_extension_loader_os_error(self):
|
||||
"""
|
||||
|
@ -105,7 +106,7 @@ class TestCommonFunctions(TestCase):
|
|||
extension_loader('glob')
|
||||
|
||||
# THEN: The `OSError` should be caught and logged
|
||||
self.assertTrue(mocked_logger.warning.called)
|
||||
assert mocked_logger.warning.called
|
||||
|
||||
def test_de_hump_conversion(self):
|
||||
"""
|
||||
|
@ -118,7 +119,7 @@ class TestCommonFunctions(TestCase):
|
|||
new_string = de_hump(string)
|
||||
|
||||
# THEN: the new string should be converted to python format
|
||||
self.assertEqual(new_string, "my_class", 'The class name should have been converted')
|
||||
assert new_string == "my_class", 'The class name should have been converted'
|
||||
|
||||
def test_de_hump_static(self):
|
||||
"""
|
||||
|
@ -131,7 +132,7 @@ class TestCommonFunctions(TestCase):
|
|||
new_string = de_hump(string)
|
||||
|
||||
# THEN: the new string should be converted to python format
|
||||
self.assertEqual(new_string, "my_class", 'The class name should have been preserved')
|
||||
assert new_string == "my_class", 'The class name should have been preserved'
|
||||
|
||||
def test_path_to_module(self):
|
||||
"""
|
||||
|
@ -144,7 +145,7 @@ class TestCommonFunctions(TestCase):
|
|||
result = path_to_module(path)
|
||||
|
||||
# THEN: path_to_module should return the module name
|
||||
self.assertEqual(result, 'openlp.core.ui.media.webkitplayer')
|
||||
assert result == 'openlp.core.ui.media.webkitplayer'
|
||||
|
||||
def test_trace_error_handler(self):
|
||||
"""
|
||||
|
@ -174,9 +175,9 @@ class TestCommonFunctions(TestCase):
|
|||
mocked_sys.platform = 'win32'
|
||||
|
||||
# THEN: The three platform functions should perform properly
|
||||
self.assertTrue(is_win(), 'is_win() should return True')
|
||||
self.assertFalse(is_macosx(), 'is_macosx() should return False')
|
||||
self.assertFalse(is_linux(), 'is_linux() should return False')
|
||||
assert is_win() is True, 'is_win() should return True'
|
||||
assert is_macosx() is False, 'is_macosx() should return False'
|
||||
assert is_linux() is False, 'is_linux() should return False'
|
||||
|
||||
def test_is_macosx(self):
|
||||
"""
|
||||
|
@ -190,9 +191,9 @@ class TestCommonFunctions(TestCase):
|
|||
mocked_sys.platform = 'darwin'
|
||||
|
||||
# THEN: The three platform functions should perform properly
|
||||
self.assertTrue(is_macosx(), 'is_macosx() should return True')
|
||||
self.assertFalse(is_win(), 'is_win() should return False')
|
||||
self.assertFalse(is_linux(), 'is_linux() should return False')
|
||||
assert is_macosx() is True, 'is_macosx() should return True'
|
||||
assert is_win() is False, 'is_win() should return False'
|
||||
assert is_linux() is False, 'is_linux() should return False'
|
||||
|
||||
def test_is_linux(self):
|
||||
"""
|
||||
|
@ -206,9 +207,9 @@ class TestCommonFunctions(TestCase):
|
|||
mocked_sys.platform = 'linux3'
|
||||
|
||||
# THEN: The three platform functions should perform properly
|
||||
self.assertTrue(is_linux(), 'is_linux() should return True')
|
||||
self.assertFalse(is_win(), 'is_win() should return False')
|
||||
self.assertFalse(is_macosx(), 'is_macosx() should return False')
|
||||
assert is_linux() is True, 'is_linux() should return True'
|
||||
assert is_win() is False, 'is_win() should return False'
|
||||
assert is_macosx() is False, 'is_macosx() should return False'
|
||||
|
||||
def test_clean_button_text(self):
|
||||
"""
|
||||
|
@ -222,4 +223,4 @@ class TestCommonFunctions(TestCase):
|
|||
actual_text = clean_button_text(input_text)
|
||||
|
||||
# THEN: The text should have been cleaned
|
||||
self.assertEqual(expected_text, actual_text, 'The text should be clean')
|
||||
assert expected_text == actual_text, 'The text should be clean'
|
||||
|
|
|
@ -59,7 +59,7 @@ class TestHttpUtils(TestCase, TestMixin):
|
|||
|
||||
# THEN: The user agent is a Linux (or ChromeOS) user agent
|
||||
result = 'Linux' in user_agent or 'CrOS' in user_agent
|
||||
self.assertTrue(result, 'The user agent should be a valid Linux user agent')
|
||||
assert result is True, 'The user agent should be a valid Linux user agent'
|
||||
|
||||
def test_get_user_agent_windows(self):
|
||||
"""
|
||||
|
@ -74,7 +74,7 @@ class TestHttpUtils(TestCase, TestMixin):
|
|||
user_agent = get_user_agent()
|
||||
|
||||
# THEN: The user agent is a Linux (or ChromeOS) user agent
|
||||
self.assertIn('Windows', user_agent, 'The user agent should be a valid Windows user agent')
|
||||
assert 'Windows' in user_agent, 'The user agent should be a valid Windows user agent'
|
||||
|
||||
def test_get_user_agent_macos(self):
|
||||
"""
|
||||
|
@ -89,7 +89,7 @@ class TestHttpUtils(TestCase, TestMixin):
|
|||
user_agent = get_user_agent()
|
||||
|
||||
# THEN: The user agent is a Linux (or ChromeOS) user agent
|
||||
self.assertIn('Mac OS X', user_agent, 'The user agent should be a valid OS X user agent')
|
||||
assert 'Mac OS X' in user_agent, 'The user agent should be a valid OS X user agent'
|
||||
|
||||
def test_get_user_agent_default(self):
|
||||
"""
|
||||
|
@ -104,7 +104,7 @@ class TestHttpUtils(TestCase, TestMixin):
|
|||
user_agent = get_user_agent()
|
||||
|
||||
# THEN: The user agent is a Linux (or ChromeOS) user agent
|
||||
self.assertIn('NetBSD', user_agent, 'The user agent should be the default user agent')
|
||||
assert 'NetBSD'in user_agent, 'The user agent should be the default user agent'
|
||||
|
||||
def test_get_web_page_no_url(self):
|
||||
"""
|
||||
|
@ -117,7 +117,7 @@ class TestHttpUtils(TestCase, TestMixin):
|
|||
result = get_web_page(test_url)
|
||||
|
||||
# THEN: None should be returned
|
||||
self.assertIsNone(result, 'The return value of get_web_page should be None')
|
||||
assert result is None, 'The return value of get_web_page should be None'
|
||||
|
||||
@patch('openlp.core.common.httputils.requests')
|
||||
@patch('openlp.core.common.httputils.get_user_agent')
|
||||
|
@ -240,4 +240,4 @@ class TestHttpUtils(TestCase, TestMixin):
|
|||
|
||||
# THEN: socket.timeout should have been caught
|
||||
# NOTE: Test is if $tmpdir/tempfile is still there, then test fails since ftw deletes bad downloaded files
|
||||
assert not os.path.exists(self.tempfile), 'tempfile should have been deleted'
|
||||
assert os.path.exists(self.tempfile) is False, 'tempfile should have been deleted'
|
||||
|
|
|
@ -63,8 +63,8 @@ class TestInit(TestCase, TestMixin):
|
|||
add_actions(mocked_target, empty_list)
|
||||
|
||||
# THEN: The add method on the mocked target is never called
|
||||
self.assertEqual(0, mocked_target.addSeparator.call_count, 'addSeparator method should not have been called')
|
||||
self.assertEqual(0, mocked_target.addAction.call_count, 'addAction method should not have been called')
|
||||
assert mocked_target.addSeparator.call_count == 0, 'addSeparator method should not have been called'
|
||||
assert mocked_target.addAction.call_count == 0, 'addAction method should not have been called'
|
||||
|
||||
def test_add_actions_none_action(self):
|
||||
"""
|
||||
|
@ -79,7 +79,7 @@ class TestInit(TestCase, TestMixin):
|
|||
|
||||
# THEN: The addSeparator method is called, but the addAction method is never called
|
||||
mocked_target.addSeparator.assert_called_with()
|
||||
self.assertEqual(0, mocked_target.addAction.call_count, 'addAction method should not have been called')
|
||||
assert mocked_target.addAction.call_count == 0, 'addAction method should not have been called'
|
||||
|
||||
def test_add_actions_add_action(self):
|
||||
"""
|
||||
|
@ -93,7 +93,7 @@ class TestInit(TestCase, TestMixin):
|
|||
add_actions(mocked_target, action_list)
|
||||
|
||||
# THEN: The addSeparator method is not called, and the addAction method is called
|
||||
self.assertEqual(0, mocked_target.addSeparator.call_count, 'addSeparator method should not have been called')
|
||||
assert mocked_target.addSeparator.call_count == 0, 'addSeparator method should not have been called'
|
||||
mocked_target.addAction.assert_called_with('action')
|
||||
|
||||
def test_add_actions_action_and_none(self):
|
||||
|
@ -150,9 +150,8 @@ class TestInit(TestCase, TestMixin):
|
|||
result = get_uno_command()
|
||||
|
||||
# THEN: The command 'libreoffice' should be called with the appropriate parameters
|
||||
self.assertEquals(result,
|
||||
'libreoffice --nologo --norestore --minimized --nodefault --nofirststartwizard'
|
||||
' "--accept=pipe,name=openlp_pipe;urp;"')
|
||||
assert result == 'libreoffice --nologo --norestore --minimized --nodefault --nofirststartwizard' \
|
||||
' "--accept=pipe,name=openlp_pipe;urp;"'
|
||||
|
||||
def test_get_uno_command_only_soffice_command_exists(self):
|
||||
"""
|
||||
|
@ -169,8 +168,8 @@ class TestInit(TestCase, TestMixin):
|
|||
result = get_uno_command()
|
||||
|
||||
# THEN: The command 'soffice' should be called with the appropriate parameters
|
||||
self.assertEquals(result, 'soffice --nologo --norestore --minimized --nodefault --nofirststartwizard'
|
||||
' "--accept=pipe,name=openlp_pipe;urp;"')
|
||||
assert result == 'soffice --nologo --norestore --minimized --nodefault --nofirststartwizard' \
|
||||
' "--accept=pipe,name=openlp_pipe;urp;"'
|
||||
|
||||
def test_get_uno_command_when_no_command_exists(self):
|
||||
"""
|
||||
|
@ -198,8 +197,8 @@ class TestInit(TestCase, TestMixin):
|
|||
result = get_uno_command('socket')
|
||||
|
||||
# THEN: The connection parameters should be set for socket
|
||||
self.assertEqual(result, 'libreoffice --nologo --norestore --minimized --nodefault --nofirststartwizard'
|
||||
' "--accept=socket,host=localhost,port=2002;urp;"')
|
||||
assert result == 'libreoffice --nologo --norestore --minimized --nodefault --nofirststartwizard' \
|
||||
' "--accept=socket,host=localhost,port=2002;urp;"'
|
||||
|
||||
def test_get_filesystem_encoding_sys_function_not_called(self):
|
||||
"""
|
||||
|
@ -215,8 +214,8 @@ class TestInit(TestCase, TestMixin):
|
|||
|
||||
# THEN: getdefaultencoding should have been called
|
||||
mocked_getfilesystemencoding.assert_called_with()
|
||||
self.assertEqual(0, mocked_getdefaultencoding.called, 'getdefaultencoding should not have been called')
|
||||
self.assertEqual('cp1252', result, 'The result should be "cp1252"')
|
||||
assert mocked_getdefaultencoding.called == 0, 'getdefaultencoding should not have been called'
|
||||
assert 'cp1252' == result, 'The result should be "cp1252"'
|
||||
|
||||
def test_get_filesystem_encoding_sys_function_is_called(self):
|
||||
"""
|
||||
|
@ -234,7 +233,7 @@ class TestInit(TestCase, TestMixin):
|
|||
# THEN: getdefaultencoding should have been called
|
||||
mocked_getfilesystemencoding.assert_called_with()
|
||||
mocked_getdefaultencoding.assert_called_with()
|
||||
self.assertEqual('utf-8', result, 'The result should be "utf-8"')
|
||||
assert 'utf-8' == result, 'The result should be "utf-8"'
|
||||
|
||||
def test_clean_filename(self):
|
||||
"""
|
||||
|
@ -248,7 +247,7 @@ class TestInit(TestCase, TestMixin):
|
|||
result = clean_filename(invalid_name)
|
||||
|
||||
# THEN: The file name should be cleaned.
|
||||
self.assertEqual(wanted_name, result, 'The file name should not contain any special characters.')
|
||||
assert wanted_name == result, 'The file name should not contain any special characters.'
|
||||
|
||||
def test_delete_file_no_path(self):
|
||||
"""
|
||||
|
@ -259,7 +258,7 @@ class TestInit(TestCase, TestMixin):
|
|||
result = delete_file(None)
|
||||
|
||||
# THEN: delete_file should return False
|
||||
self.assertFalse(result, "delete_file should return False when called with None")
|
||||
assert result is False, "delete_file should return False when called with None"
|
||||
|
||||
def test_delete_file_path_success(self):
|
||||
"""
|
||||
|
@ -272,7 +271,7 @@ class TestInit(TestCase, TestMixin):
|
|||
result = delete_file(Path('path', 'file.ext'))
|
||||
|
||||
# THEN: delete_file should return True
|
||||
self.assertTrue(result, 'delete_file should return True when it successfully deletes a file')
|
||||
assert result is True, 'delete_file should return True when it successfully deletes a file'
|
||||
|
||||
def test_delete_file_path_no_file_exists(self):
|
||||
"""
|
||||
|
@ -286,8 +285,8 @@ class TestInit(TestCase, TestMixin):
|
|||
result = delete_file(Path('path', 'file.ext'))
|
||||
|
||||
# THEN: The function should not attempt to delete the file and it should return True
|
||||
self.assertFalse(mocked_unlink.called)
|
||||
self.assertTrue(result, 'delete_file should return True when the file doesnt exist')
|
||||
assert mocked_unlink.called is False
|
||||
assert result is True, 'delete_file should return True when the file doesnt exist'
|
||||
|
||||
def test_delete_file_path_exception(self):
|
||||
"""
|
||||
|
@ -303,8 +302,8 @@ class TestInit(TestCase, TestMixin):
|
|||
result = delete_file(Path('path', 'file.ext'))
|
||||
|
||||
# THEN: The exception should be logged and `delete_file` should return False
|
||||
self.assertTrue(mocked_log.exception.called)
|
||||
self.assertFalse(result, 'delete_file should return False when an OSError is raised')
|
||||
assert mocked_log.exception.called
|
||||
assert result is False, 'delete_file should return False when an OSError is raised'
|
||||
|
||||
def test_get_file_encoding_done(self):
|
||||
"""
|
||||
|
@ -323,9 +322,9 @@ class TestInit(TestCase, TestMixin):
|
|||
|
||||
# THEN: The feed method of UniversalDetector should only br called once before returning a result
|
||||
mocked_open.assert_called_once_with('rb')
|
||||
self.assertEqual(mocked_universal_detector_inst.feed.mock_calls, [call(b"data" * 256)])
|
||||
assert mocked_universal_detector_inst.feed.mock_calls == [call(b"data" * 256)]
|
||||
mocked_universal_detector_inst.close.assert_called_once_with()
|
||||
self.assertEqual(result, encoding_result)
|
||||
assert result == encoding_result
|
||||
|
||||
def test_get_file_encoding_eof(self):
|
||||
"""
|
||||
|
@ -345,9 +344,9 @@ class TestInit(TestCase, TestMixin):
|
|||
|
||||
# THEN: The feed method of UniversalDetector should have been called twice before returning a result
|
||||
mocked_open.assert_called_once_with('rb')
|
||||
self.assertEqual(mocked_universal_detector_inst.feed.mock_calls, [call(b"data" * 256), call(b"data" * 4)])
|
||||
assert mocked_universal_detector_inst.feed.mock_calls == [call(b"data" * 256), call(b"data" * 4)]
|
||||
mocked_universal_detector_inst.close.assert_called_once_with()
|
||||
self.assertEqual(result, encoding_result)
|
||||
assert result == encoding_result
|
||||
|
||||
def test_get_file_encoding_oserror(self):
|
||||
"""
|
||||
|
@ -364,4 +363,4 @@ class TestInit(TestCase, TestMixin):
|
|||
|
||||
# THEN: log.exception should be called and get_file_encoding should return None
|
||||
mocked_log.exception.assert_called_once_with('Error detecting file encoding')
|
||||
self.assertIsNone(result)
|
||||
assert result is None
|
||||
|
|
|
@ -45,7 +45,7 @@ class TestOpenLPJsonDecoder(TestCase):
|
|||
result = instance.object_hook({'__Path__': ['test', 'path']})
|
||||
|
||||
# THEN: A Path object should be returned
|
||||
self.assertEqual(result, Path('test', 'path'))
|
||||
assert result == Path('test', 'path')
|
||||
|
||||
def test_object_hook_non_path_object(self):
|
||||
"""
|
||||
|
@ -59,8 +59,8 @@ class TestOpenLPJsonDecoder(TestCase):
|
|||
result = instance.object_hook({'key': 'value'})
|
||||
|
||||
# THEN: The object should be returned unchanged and a Path object should not have been initiated
|
||||
self.assertEqual(result, {'key': 'value'})
|
||||
self.assertFalse(mocked_path.called)
|
||||
assert result == {'key': 'value'}
|
||||
assert mocked_path.called is False
|
||||
|
||||
def test_json_decode(self):
|
||||
"""
|
||||
|
@ -73,7 +73,7 @@ class TestOpenLPJsonDecoder(TestCase):
|
|||
obj = json.loads(json_string, cls=OpenLPJsonDecoder)
|
||||
|
||||
# THEN: The object returned should be a python version of the JSON string
|
||||
self.assertEqual(obj, [Path('test', 'path1'), Path('test', 'path2')])
|
||||
assert obj == [Path('test', 'path1'), Path('test', 'path2')]
|
||||
|
||||
|
||||
class TestOpenLPJsonEncoder(TestCase):
|
||||
|
@ -91,7 +91,7 @@ class TestOpenLPJsonEncoder(TestCase):
|
|||
result = instance.default(Path('test', 'path'))
|
||||
|
||||
# THEN: A dictionary object that can be JSON encoded should be returned
|
||||
self.assertEqual(result, {'__Path__': ('test', 'path')})
|
||||
assert result == {'__Path__': ('test', 'path')}
|
||||
|
||||
def test_default_non_path_object(self):
|
||||
"""
|
||||
|
@ -119,4 +119,4 @@ class TestOpenLPJsonEncoder(TestCase):
|
|||
json_string = json.dumps(obj, cls=OpenLPJsonEncoder)
|
||||
|
||||
# THEN: The JSON string return should be a representation of the object encoded
|
||||
self.assertEqual(json_string, '[{"__Path__": ["test", "path1"]}, {"__Path__": ["test", "path2"]}]')
|
||||
assert json_string == '[{"__Path__": ["test", "path1"]}, {"__Path__": ["test", "path2"]}]'
|
||||
|
|
|
@ -46,7 +46,7 @@ class TestRegistryProperties(TestCase, RegistryProperties):
|
|||
# GIVEN an Empty Registry
|
||||
# WHEN there is no Application
|
||||
# THEN the application should be none
|
||||
self.assertEqual(self.application, None, 'The application value should be None')
|
||||
assert self.application is None, 'The application value should be None'
|
||||
|
||||
def test_application(self):
|
||||
"""
|
||||
|
@ -59,7 +59,7 @@ class TestRegistryProperties(TestCase, RegistryProperties):
|
|||
Registry().register('application', application)
|
||||
|
||||
# THEN the application should be none
|
||||
self.assertEqual(self.application, application, 'The application value should match')
|
||||
assert self.application == application, 'The application value should match'
|
||||
|
||||
@patch('openlp.core.common.mixins.is_win')
|
||||
def test_application_on_windows(self, mocked_is_win):
|
||||
|
@ -74,7 +74,7 @@ class TestRegistryProperties(TestCase, RegistryProperties):
|
|||
Registry().register('application', application)
|
||||
|
||||
# THEN the application should be none
|
||||
self.assertEqual(self.application, application, 'The application value should match')
|
||||
assert self.application == application, 'The application value should match'
|
||||
|
||||
@patch('openlp.core.common.mixins.is_win')
|
||||
def test_get_application_on_windows(self, mocked_is_win):
|
||||
|
@ -93,6 +93,6 @@ class TestRegistryProperties(TestCase, RegistryProperties):
|
|||
actual_application = reg_props.application
|
||||
|
||||
# THEN the application should be the mock object, and the correct function should have been called
|
||||
self.assertEqual(mock_application, actual_application, 'The application value should match')
|
||||
assert mock_application == actual_application, 'The application value should match'
|
||||
mocked_is_win.assert_called_with()
|
||||
mocked_get.assert_called_with('application')
|
||||
|
|
|
@ -47,8 +47,8 @@ class TestShutil(TestCase):
|
|||
result_args, result_kwargs = replace_params(test_args, test_kwargs, test_params)
|
||||
|
||||
# THEN: The positional and keyword args should not have changed
|
||||
self.assertEqual(test_args, result_args)
|
||||
self.assertEqual(test_kwargs, result_kwargs)
|
||||
assert test_args == result_args
|
||||
assert test_kwargs == result_kwargs
|
||||
|
||||
def test_replace_params_params(self):
|
||||
"""
|
||||
|
@ -63,8 +63,8 @@ class TestShutil(TestCase):
|
|||
result_args, result_kwargs = replace_params(test_args, test_kwargs, test_params)
|
||||
|
||||
# THEN: The positional and keyword args should have have changed
|
||||
self.assertEqual(result_args, (1, '2'))
|
||||
self.assertEqual(result_kwargs, {'arg3': '3', 'arg4': 4})
|
||||
assert result_args == (1, '2')
|
||||
assert result_kwargs == {'arg3': '3', 'arg4': 4}
|
||||
|
||||
def test_copy(self):
|
||||
"""
|
||||
|
@ -82,7 +82,7 @@ class TestShutil(TestCase):
|
|||
# :func:`shutil.copy` as a Path object.
|
||||
mocked_shutil_copy.assert_called_once_with(os.path.join('source', 'test', 'path'),
|
||||
os.path.join('destination', 'test', 'path'))
|
||||
self.assertEqual(result, Path('destination', 'test', 'path'))
|
||||
assert result == Path('destination', 'test', 'path')
|
||||
|
||||
def test_copy_follow_optional_params(self):
|
||||
"""
|
||||
|
@ -114,7 +114,7 @@ class TestShutil(TestCase):
|
|||
# :func:`shutil.copyfile` as a Path object.
|
||||
mocked_shutil_copyfile.assert_called_once_with(os.path.join('source', 'test', 'path'),
|
||||
os.path.join('destination', 'test', 'path'))
|
||||
self.assertEqual(result, Path('destination', 'test', 'path'))
|
||||
assert result == Path('destination', 'test', 'path')
|
||||
|
||||
def test_copyfile_optional_params(self):
|
||||
"""
|
||||
|
@ -147,7 +147,7 @@ class TestShutil(TestCase):
|
|||
# :func:`shutil.copytree` as a Path object.
|
||||
mocked_shutil_copytree.assert_called_once_with(os.path.join('source', 'test', 'path'),
|
||||
os.path.join('destination', 'test', 'path'))
|
||||
self.assertEqual(result, Path('destination', 'test', 'path'))
|
||||
assert result == Path('destination', 'test', 'path')
|
||||
|
||||
def test_copytree_optional_params(self):
|
||||
"""
|
||||
|
@ -177,12 +177,11 @@ class TestShutil(TestCase):
|
|||
path = Path('test', 'path')
|
||||
|
||||
# WHEN: Calling :func:`openlp.core.common.path.rmtree` with the path parameter as Path object type
|
||||
result = path.rmtree()
|
||||
path.rmtree()
|
||||
|
||||
# THEN: :func:`shutil.rmtree` should have been called with the str equivalents of the Path object.
|
||||
mocked_shutil_rmtree.assert_called_once_with(
|
||||
os.path.join('test', 'path'), False, None)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_rmtree_optional_params(self):
|
||||
"""
|
||||
|
@ -214,7 +213,7 @@ class TestShutil(TestCase):
|
|||
|
||||
# THEN: :func:`shutil.which` should have been called with the command, and :func:`which` should return None.
|
||||
mocked_shutil_which.assert_called_once_with('no_command')
|
||||
self.assertIsNone(result)
|
||||
assert result is None
|
||||
|
||||
def test_which_command(self):
|
||||
"""
|
||||
|
@ -230,7 +229,7 @@ class TestShutil(TestCase):
|
|||
# THEN: :func:`shutil.which` should have been called with the command, and :func:`which` should return a
|
||||
# Path object equivalent of the command path.
|
||||
mocked_shutil_which.assert_called_once_with('command')
|
||||
self.assertEqual(result, Path('path', 'to', 'command'))
|
||||
assert result == Path('path', 'to', 'command')
|
||||
|
||||
|
||||
class TestPath(TestCase):
|
||||
|
@ -257,7 +256,7 @@ class TestPath(TestCase):
|
|||
result = path_to_str(None)
|
||||
|
||||
# THEN: `path_to_str` should return an empty string
|
||||
self.assertEqual(result, '')
|
||||
assert result == ''
|
||||
|
||||
def test_path_to_str_path_object(self):
|
||||
"""
|
||||
|
@ -268,7 +267,7 @@ class TestPath(TestCase):
|
|||
result = path_to_str(Path('test/path'))
|
||||
|
||||
# THEN: `path_to_str` should return a string representation of the Path object
|
||||
self.assertEqual(result, os.path.join('test', 'path'))
|
||||
assert result == os.path.join('test', 'path')
|
||||
|
||||
def test_str_to_path_type_error(self):
|
||||
"""
|
||||
|
@ -289,7 +288,7 @@ class TestPath(TestCase):
|
|||
result = str_to_path('')
|
||||
|
||||
# THEN: `path_to_str` should return None
|
||||
self.assertEqual(result, None)
|
||||
assert result is None
|
||||
|
||||
def test_path_encode_json(self):
|
||||
"""
|
||||
|
@ -301,7 +300,7 @@ class TestPath(TestCase):
|
|||
path = Path.encode_json({'__Path__': ['path', 'to', 'fi.le']}, extra=1, args=2)
|
||||
|
||||
# THEN: A Path object should have been returned
|
||||
self.assertEqual(path, Path('path', 'to', 'fi.le'))
|
||||
assert path == Path('path', 'to', 'fi.le')
|
||||
|
||||
def test_path_encode_json_base_path(self):
|
||||
"""
|
||||
|
@ -313,7 +312,7 @@ class TestPath(TestCase):
|
|||
path = Path.encode_json({'__Path__': ['path', 'to', 'fi.le']}, base_path=Path('/base'))
|
||||
|
||||
# THEN: A Path object should have been returned with an absolute path
|
||||
self.assertEqual(path, Path('/', 'base', 'path', 'to', 'fi.le'))
|
||||
assert path == Path('/', 'base', 'path', 'to', 'fi.le')
|
||||
|
||||
def test_path_json_object(self):
|
||||
"""
|
||||
|
@ -326,7 +325,7 @@ class TestPath(TestCase):
|
|||
obj = path.json_object(extra=1, args=2)
|
||||
|
||||
# THEN: A JSON decodable object should have been returned.
|
||||
self.assertEqual(obj, {'__Path__': ('/', 'base', 'path', 'to', 'fi.le')})
|
||||
assert obj == {'__Path__': ('/', 'base', 'path', 'to', 'fi.le')}
|
||||
|
||||
def test_path_json_object_base_path(self):
|
||||
"""
|
||||
|
@ -340,7 +339,7 @@ class TestPath(TestCase):
|
|||
obj = path.json_object(base_path=Path('/', 'base'))
|
||||
|
||||
# THEN: A JSON decodable object should have been returned.
|
||||
self.assertEqual(obj, {'__Path__': ('path', 'to', 'fi.le')})
|
||||
assert obj == {'__Path__': ('path', 'to', 'fi.le')}
|
||||
|
||||
def test_create_paths_dir_exists(self):
|
||||
"""
|
||||
|
|
|
@ -45,7 +45,7 @@ ip6_link_local = 'fe80::223:14ff:fe99:d315'
|
|||
ip6_bad = 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'
|
||||
|
||||
|
||||
class testProjectorUtilities(TestCase):
|
||||
class TestProjectorUtilities(TestCase):
|
||||
"""
|
||||
Validate functions in the projector utilities module
|
||||
"""
|
||||
|
@ -57,7 +57,7 @@ class testProjectorUtilities(TestCase):
|
|||
valid = verify_ip_address(addr=ip4_loopback)
|
||||
|
||||
# THEN: Verify we received True
|
||||
self.assertTrue(valid, 'IPv4 loopback address should have been valid')
|
||||
assert valid, 'IPv4 loopback address should have been valid'
|
||||
|
||||
def test_ip4_local_valid(self):
|
||||
"""
|
||||
|
@ -67,7 +67,7 @@ class testProjectorUtilities(TestCase):
|
|||
valid = verify_ip_address(addr=ip4_local)
|
||||
|
||||
# THEN: Verify we received True
|
||||
self.assertTrue(valid, 'IPv4 local address should have been valid')
|
||||
assert valid is True, 'IPv4 local address should have been valid'
|
||||
|
||||
def test_ip4_broadcast_valid(self):
|
||||
"""
|
||||
|
@ -77,7 +77,7 @@ class testProjectorUtilities(TestCase):
|
|||
valid = verify_ip_address(addr=ip4_broadcast)
|
||||
|
||||
# THEN: Verify we received True
|
||||
self.assertTrue(valid, 'IPv4 broadcast address should have been valid')
|
||||
assert valid is True, 'IPv4 broadcast address should have been valid'
|
||||
|
||||
def test_ip4_address_invalid(self):
|
||||
"""
|
||||
|
@ -87,7 +87,7 @@ class testProjectorUtilities(TestCase):
|
|||
valid = verify_ip_address(addr=ip4_bad)
|
||||
|
||||
# THEN: Verify we received True
|
||||
self.assertFalse(valid, 'Bad IPv4 address should not have been valid')
|
||||
assert valid is False, 'Bad IPv4 address should not have been valid'
|
||||
|
||||
def test_ip6_loopback_valid(self):
|
||||
"""
|
||||
|
@ -97,7 +97,7 @@ class testProjectorUtilities(TestCase):
|
|||
valid = verify_ip_address(addr=ip6_loopback)
|
||||
|
||||
# THEN: Validate return
|
||||
self.assertTrue(valid, 'IPv6 loopback address should have been valid')
|
||||
assert valid is True, 'IPv6 loopback address should have been valid'
|
||||
|
||||
def test_ip6_local_valid(self):
|
||||
"""
|
||||
|
@ -107,7 +107,7 @@ class testProjectorUtilities(TestCase):
|
|||
valid = verify_ip_address(addr=ip6_link_local)
|
||||
|
||||
# THEN: Validate return
|
||||
self.assertTrue(valid, 'IPv6 link-local address should have been valid')
|
||||
assert valid is True, 'IPv6 link-local address should have been valid'
|
||||
|
||||
def test_ip6_address_invalid(self):
|
||||
"""
|
||||
|
@ -117,7 +117,7 @@ class testProjectorUtilities(TestCase):
|
|||
valid = verify_ip_address(addr=ip6_bad)
|
||||
|
||||
# THEN: Validate bad return
|
||||
self.assertFalse(valid, 'IPv6 bad address should have been invalid')
|
||||
assert valid is False, 'IPv6 bad address should have been invalid'
|
||||
|
||||
def test_md5_hash(self):
|
||||
"""
|
||||
|
@ -127,7 +127,7 @@ class testProjectorUtilities(TestCase):
|
|||
hash_ = md5_hash(salt=salt.encode('utf-8'), data=pin.encode('utf-8'))
|
||||
|
||||
# THEN: Validate return has is same
|
||||
self.assertEquals(hash_, test_hash, 'MD5 should have returned a good hash')
|
||||
assert hash_ == test_hash, 'MD5 should have returned a good hash'
|
||||
|
||||
def test_md5_hash_bad(self):
|
||||
"""
|
||||
|
@ -137,7 +137,7 @@ class testProjectorUtilities(TestCase):
|
|||
hash_ = md5_hash(salt=pin.encode('utf-8'), data=salt.encode('utf-8'))
|
||||
|
||||
# THEN: return data is different
|
||||
self.assertNotEquals(hash_, test_hash, 'MD5 should have returned a bad hash')
|
||||
assert hash_ is not test_hash, 'MD5 should have returned a bad hash'
|
||||
|
||||
def test_qmd5_hash(self):
|
||||
"""
|
||||
|
@ -147,7 +147,7 @@ class testProjectorUtilities(TestCase):
|
|||
hash_ = qmd5_hash(salt=salt.encode('utf-8'), data=pin.encode('utf-8'))
|
||||
|
||||
# THEN: Validate return has is same
|
||||
self.assertEquals(hash_, test_hash, 'Qt-MD5 should have returned a good hash')
|
||||
assert hash_ == test_hash, 'Qt-MD5 should have returned a good hash'
|
||||
|
||||
def test_qmd5_hash_bad(self):
|
||||
"""
|
||||
|
@ -157,7 +157,7 @@ class testProjectorUtilities(TestCase):
|
|||
hash_ = qmd5_hash(salt=pin.encode('utf-8'), data=salt.encode('utf-8'))
|
||||
|
||||
# THEN: return data is different
|
||||
self.assertNotEquals(hash_, test_hash, 'Qt-MD5 should have returned a bad hash')
|
||||
assert hash_ is not test_hash, 'Qt-MD5 should have returned a bad hash'
|
||||
|
||||
def test_md5_non_ascii_string(self):
|
||||
"""
|
||||
|
@ -167,7 +167,7 @@ class testProjectorUtilities(TestCase):
|
|||
hash_ = md5_hash(salt=test_non_ascii_string.encode('utf-8'), data=None)
|
||||
|
||||
# THEN: Valid MD5 hash should be returned
|
||||
self.assertEqual(hash_, test_non_ascii_hash, 'MD5 should have returned a valid hash')
|
||||
assert hash_ == test_non_ascii_hash, 'MD5 should have returned a valid hash'
|
||||
|
||||
def test_qmd5_non_ascii_string(self):
|
||||
"""
|
||||
|
@ -177,4 +177,4 @@ class testProjectorUtilities(TestCase):
|
|||
hash_ = md5_hash(data=test_non_ascii_string.encode('utf-8'))
|
||||
|
||||
# THEN: Valid MD5 hash should be returned
|
||||
self.assertEqual(hash_, test_non_ascii_hash, 'Qt-MD5 should have returned a valid hash')
|
||||
assert hash_ == test_non_ascii_hash, 'Qt-MD5 should have returned a valid hash'
|
||||
|
|
|
@ -51,19 +51,19 @@ class TestRegistry(TestCase):
|
|||
# THEN and I will get an exception
|
||||
with self.assertRaises(KeyError) as context:
|
||||
Registry().register('test1', mock_1)
|
||||
self.assertEqual(context.exception.args[0], 'Duplicate service exception test1',
|
||||
'KeyError exception should have been thrown for duplicate service')
|
||||
assert context.exception.args[0] == 'Duplicate service exception test1', \
|
||||
'KeyError exception should have been thrown for duplicate service'
|
||||
|
||||
# WHEN I try to get back a non existent component
|
||||
# THEN I will get an exception
|
||||
temp = Registry().get('test2')
|
||||
self.assertEqual(temp, None, 'None should have been returned for missing service')
|
||||
assert temp is None, 'None should have been returned for missing service'
|
||||
|
||||
# WHEN I try to replace a component I should be allowed
|
||||
Registry().remove('test1')
|
||||
# THEN I will get an exception
|
||||
temp = Registry().get('test1')
|
||||
self.assertEqual(temp, None, 'None should have been returned for deleted service')
|
||||
assert temp is None, 'None should have been returned for deleted service'
|
||||
|
||||
def test_registry_function(self):
|
||||
"""
|
||||
|
@ -77,21 +77,21 @@ class TestRegistry(TestCase):
|
|||
return_value = Registry().execute('test1')
|
||||
|
||||
# THEN: I expect then function to have been called and a return given
|
||||
self.assertEqual(return_value[0], 'function_1', 'A return value is provided and matches')
|
||||
assert return_value[0] == 'function_1', 'A return value is provided and matches'
|
||||
|
||||
# WHEN: I execute the a function with the same reference and execute the function
|
||||
Registry().register_function('test1', self.dummy_function_1)
|
||||
return_value = Registry().execute('test1')
|
||||
|
||||
# THEN: I expect then function to have been called and a return given
|
||||
self.assertEqual(return_value, ['function_1', 'function_1'], 'A return value list is provided and matches')
|
||||
assert return_value == ['function_1', 'function_1'], 'A return value list is provided and matches'
|
||||
|
||||
# WHEN: I execute the a 2nd function with the different reference and execute the function
|
||||
Registry().register_function('test2', self.dummy_function_2)
|
||||
return_value = Registry().execute('test2')
|
||||
|
||||
# THEN: I expect then function to have been called and a return given
|
||||
self.assertEqual(return_value[0], 'function_2', 'A return value is provided and matches')
|
||||
assert return_value[0] == 'function_2', 'A return value is provided and matches'
|
||||
|
||||
def test_registry_working_flags(self):
|
||||
"""
|
||||
|
@ -107,28 +107,28 @@ class TestRegistry(TestCase):
|
|||
|
||||
# THEN: we should be able retrieve the saved component
|
||||
temp = Registry().get_flag('test1')
|
||||
self.assertEquals(temp, my_data, 'The value should have been saved')
|
||||
assert temp == my_data, 'The value should have been saved'
|
||||
|
||||
# WHEN: I add a component for the second time I am not mad.
|
||||
# THEN and I will not get an exception
|
||||
Registry().set_flag('test1', my_data2)
|
||||
temp = Registry().get_flag('test1')
|
||||
self.assertEquals(temp, my_data2, 'The value should have been updated')
|
||||
assert temp == my_data2, 'The value should have been updated'
|
||||
|
||||
# WHEN I try to get back a non existent Working Flag
|
||||
# THEN I will get an exception
|
||||
with self.assertRaises(KeyError) as context1:
|
||||
temp = Registry().get_flag('test2')
|
||||
self.assertEqual(context1.exception.args[0], 'Working Flag test2 not found in list',
|
||||
'KeyError exception should have been thrown for missing working flag')
|
||||
assert context1.exception.args[0] == 'Working Flag test2 not found in list', \
|
||||
'KeyError exception should have been thrown for missing working flag'
|
||||
|
||||
# WHEN I try to replace a working flag I should be allowed
|
||||
Registry().remove_flag('test1')
|
||||
# THEN I will get an exception
|
||||
with self.assertRaises(KeyError) as context:
|
||||
temp = Registry().get_flag('test1')
|
||||
self.assertEqual(context.exception.args[0], 'Working Flag test1 not found in list',
|
||||
'KeyError exception should have been thrown for duplicate working flag')
|
||||
assert context.exception.args[0] == 'Working Flag test1 not found in list', \
|
||||
'KeyError exception should have been thrown for duplicate working flag'
|
||||
|
||||
def test_remove_function(self):
|
||||
"""
|
||||
|
@ -142,7 +142,7 @@ class TestRegistry(TestCase):
|
|||
Registry().remove_function('test1', self.dummy_function_1)
|
||||
|
||||
# THEN: The method should not be available.
|
||||
assert not Registry().functions_list['test1'], 'The function should not be in the dict anymore.'
|
||||
assert Registry().functions_list['test1'] == [], 'The function should not be in the dict anymore.'
|
||||
|
||||
def dummy_function_1(self):
|
||||
return "function_1"
|
||||
|
@ -174,7 +174,7 @@ class TestRegistryBase(TestCase):
|
|||
PlainStub()
|
||||
|
||||
# THEN: Nothing is registered with the registry
|
||||
self.assertEqual(len(Registry().functions_list), 0), 'The function should not be in the dict anymore.'
|
||||
assert len(Registry().functions_list) == 0, 'The function should not be in the dict anymore.'
|
||||
|
||||
def test_registry_mixin_present(self):
|
||||
"""
|
||||
|
@ -187,4 +187,4 @@ class TestRegistryBase(TestCase):
|
|||
RegistryStub()
|
||||
|
||||
# THEN: The bootstrap methods should be registered
|
||||
self.assertEqual(len(Registry().functions_list), 2), 'The bootstrap functions should be in the dict.'
|
||||
assert len(Registry().functions_list) == 2, 'The bootstrap functions should be in the dict.'
|
||||
|
|
|
@ -139,13 +139,13 @@ class TestSettings(TestCase, TestMixin):
|
|||
extend = settings.value('extend')
|
||||
|
||||
# THEN the default value is returned
|
||||
self.assertEqual('very wide', extend, 'The default value defined should be returned')
|
||||
assert 'very wide' == extend, 'The default value defined should be returned'
|
||||
|
||||
# WHEN a new value is saved into config
|
||||
Settings().setValue('test/extend', 'very short')
|
||||
|
||||
# THEN the new value is returned when re-read
|
||||
self.assertEqual('very short', Settings().value('test/extend'), 'The saved value should be returned')
|
||||
assert 'very short' == Settings().value('test/extend'), 'The saved value should be returned'
|
||||
|
||||
def test_settings_nonexisting(self):
|
||||
"""Test the Settings on query for non-existing value"""
|
||||
|
@ -155,7 +155,7 @@ class TestSettings(TestCase, TestMixin):
|
|||
Settings().value('core/does not exists')
|
||||
|
||||
# THEN: An exception with the non-existing key should be thrown
|
||||
self.assertEqual(str(cm.exception), "'core/does not exists'", 'We should get an exception')
|
||||
assert str(cm.exception) == "'core/does not exists'", 'We should get an exception'
|
||||
|
||||
def test_extend_default_settings(self):
|
||||
"""Test that the extend_default_settings method extends the default settings"""
|
||||
|
@ -167,9 +167,8 @@ class TestSettings(TestCase, TestMixin):
|
|||
Settings.extend_default_settings({'test/setting 3': 4, 'test/extended 1': 1, 'test/extended 2': 2})
|
||||
|
||||
# THEN: The _default_settings__ dictionary_ should have the new keys
|
||||
self.assertEqual(
|
||||
Settings.__default_settings__, {'test/setting 1': 1, 'test/setting 2': 2, 'test/setting 3': 4,
|
||||
'test/extended 1': 1, 'test/extended 2': 2})
|
||||
assert Settings.__default_settings__ == {'test/setting 1': 1, 'test/setting 2': 2, 'test/setting 3': 4,
|
||||
'test/extended 1': 1, 'test/extended 2': 2}
|
||||
|
||||
@patch('openlp.core.common.settings.QtCore.QSettings.contains')
|
||||
@patch('openlp.core.common.settings.QtCore.QSettings.value')
|
||||
|
|
|
@ -113,7 +113,7 @@ class TestRenderer(TestCase):
|
|||
result = get_start_tags(given_raw_text)
|
||||
|
||||
# THEN: Check if the correct tuple is returned.
|
||||
self.assertEqual(result, expected_tuple), 'A tuple should be returned containing the text with correct ' \
|
||||
assert result == expected_tuple, 'A tuple should be returned containing the text with correct ' \
|
||||
'tags, the opening tags, and the opening html tags.'
|
||||
|
||||
def test_word_split(self):
|
||||
|
@ -128,7 +128,7 @@ class TestRenderer(TestCase):
|
|||
result_words = words_split(given_line)
|
||||
|
||||
# THEN: The word lists should be the same.
|
||||
self.assertListEqual(result_words, expected_words)
|
||||
assert result_words == expected_words
|
||||
|
||||
def test_format_slide_logical_split(self):
|
||||
"""
|
||||
|
@ -145,7 +145,7 @@ class TestRenderer(TestCase):
|
|||
result_words = renderer.format_slide(given_line, service_item)
|
||||
|
||||
# THEN: The word lists should be the same.
|
||||
self.assertListEqual(result_words, expected_words)
|
||||
assert result_words == expected_words
|
||||
|
||||
def test_format_slide_blank_before_split(self):
|
||||
"""
|
||||
|
@ -162,7 +162,7 @@ class TestRenderer(TestCase):
|
|||
result_words = renderer.format_slide(given_line, service_item)
|
||||
|
||||
# THEN: The blanks have been removed.
|
||||
self.assertListEqual(result_words, expected_words)
|
||||
assert result_words == expected_words
|
||||
|
||||
def test_format_slide_blank_after_split(self):
|
||||
"""
|
||||
|
@ -179,7 +179,7 @@ class TestRenderer(TestCase):
|
|||
result_words = renderer.format_slide(given_line, service_item)
|
||||
|
||||
# THEN: The blanks have been removed.
|
||||
self.assertListEqual(result_words, expected_words)
|
||||
assert result_words == expected_words
|
||||
|
||||
@patch('openlp.core.display.renderer.QtWebKitWidgets.QWebView')
|
||||
@patch('openlp.core.display.renderer.build_lyrics_format_css')
|
||||
|
|
|
@ -75,6 +75,6 @@ class TestScreenList(TestCase):
|
|||
|
||||
# THEN: The screen should have been added and the screens should be identical
|
||||
new_screen_count = len(self.screens.screen_list)
|
||||
self.assertEqual(old_screen_count + 1, new_screen_count, 'The new_screens list should be bigger')
|
||||
self.assertEqual(SCREEN, self.screens.screen_list.pop(),
|
||||
'The 2nd screen should be identical to the first screen')
|
||||
assert old_screen_count + 1 == new_screen_count, 'The new_screens list should be bigger'
|
||||
assert SCREEN == self.screens.screen_list.pop(), \
|
||||
'The 2nd screen should be identical to the first screen'
|
||||
|
|
|
@ -80,8 +80,8 @@ class TestDB(TestCase):
|
|||
MockedMetaData.assert_called_with(bind=mocked_engine)
|
||||
mocked_sessionmaker.assert_called_with(autoflush=True, autocommit=False, bind=mocked_engine)
|
||||
mocked_scoped_session.assert_called_with(mocked_sessionmaker_object)
|
||||
self.assertIs(session, mocked_scoped_session_object, 'The ``session`` object should be the mock')
|
||||
self.assertIs(metadata, mocked_metadata, 'The ``metadata`` object should be the mock')
|
||||
assert session is mocked_scoped_session_object, 'The ``session`` object should be the mock'
|
||||
assert metadata is mocked_metadata, 'The ``metadata`` object should be the mock'
|
||||
|
||||
def test_init_db_defaults(self):
|
||||
"""
|
||||
|
@ -94,8 +94,8 @@ class TestDB(TestCase):
|
|||
session, metadata = init_db(db_url)
|
||||
|
||||
# THEN: Valid session and metadata objects should be returned
|
||||
self.assertIsInstance(session, ScopedSession, 'The ``session`` object should be a ``ScopedSession`` instance')
|
||||
self.assertIsInstance(metadata, MetaData, 'The ``metadata`` object should be a ``MetaData`` instance')
|
||||
assert isinstance(session, ScopedSession), 'The ``session`` object should be a ``ScopedSession`` instance'
|
||||
assert isinstance(metadata, MetaData), 'The ``metadata`` object should be a ``MetaData`` instance'
|
||||
|
||||
def test_get_upgrade_op(self):
|
||||
"""
|
||||
|
@ -116,7 +116,7 @@ class TestDB(TestCase):
|
|||
op = get_upgrade_op(mocked_session)
|
||||
|
||||
# THEN: The op object should be mocked_op, and the correction function calls should have been made
|
||||
self.assertIs(op, mocked_op, 'The return value should be the mocked object')
|
||||
assert op is mocked_op, 'The return value should be the mocked object'
|
||||
mocked_session.bind.connect.assert_called_with()
|
||||
MockedMigrationContext.configure.assert_called_with(mocked_connection)
|
||||
MockedOperations.assert_called_with(mocked_context)
|
||||
|
@ -139,7 +139,7 @@ class TestDB(TestCase):
|
|||
# THEN: The AppLocation.get_section_data_path and delete_file methods should have been called
|
||||
MockedAppLocation.get_section_data_path.assert_called_with(test_plugin)
|
||||
mocked_delete_file.assert_called_with(test_location)
|
||||
self.assertTrue(result, 'The result of delete_file should be True (was rigged that way)')
|
||||
assert result is True, 'The result of delete_file should be True (was rigged that way)'
|
||||
|
||||
def test_delete_database_with_db_file_name(self):
|
||||
"""
|
||||
|
@ -160,7 +160,7 @@ class TestDB(TestCase):
|
|||
# THEN: The AppLocation.get_section_data_path and delete_file methods should have been called
|
||||
MockedAppLocation.get_section_data_path.assert_called_with(test_plugin)
|
||||
mocked_delete_file.assert_called_with(test_location)
|
||||
self.assertFalse(result, 'The result of delete_file should be False (was rigged that way)')
|
||||
assert result is False, 'The result of delete_file should be False (was rigged that way)'
|
||||
|
||||
def test_skip_db_upgrade_with_no_database(self):
|
||||
"""
|
||||
|
@ -174,4 +174,4 @@ class TestDB(TestCase):
|
|||
upgrade_db(url, mocked_upgrade)
|
||||
|
||||
# THEN: upgrade should NOT have been called
|
||||
self.assertFalse(mocked_upgrade.called, 'Database upgrade function should NOT have been called')
|
||||
assert mocked_upgrade.called is False, 'Database upgrade function should NOT have been called'
|
||||
|
|
|
@ -309,7 +309,7 @@ class Htmbuilder(TestCase, TestMixin):
|
|||
html = build_html(item, screen, is_live, background, plugins=plugins)
|
||||
|
||||
# THEN: The returned html should match.
|
||||
self.assertEqual(html, HTML, 'The returned html should match')
|
||||
assert html == HTML, 'The returned html should match'
|
||||
|
||||
def test_build_background_css_radial(self):
|
||||
"""
|
||||
|
@ -325,7 +325,7 @@ class Htmbuilder(TestCase, TestMixin):
|
|||
css = build_background_css(item, width)
|
||||
|
||||
# THEN: The returned css should match.
|
||||
self.assertEqual(BACKGROUND_CSS_RADIAL, css, 'The background css should be equal.')
|
||||
assert BACKGROUND_CSS_RADIAL == css, 'The background css should be equal.'
|
||||
|
||||
def test_build_lyrics_css(self):
|
||||
"""
|
||||
|
@ -346,7 +346,7 @@ class Htmbuilder(TestCase, TestMixin):
|
|||
css = build_lyrics_css(item)
|
||||
|
||||
# THEN: The css should be equal.
|
||||
self.assertEqual(LYRICS_CSS, css, 'The lyrics css should be equal.')
|
||||
assert LYRICS_CSS == css, 'The lyrics css should be equal.'
|
||||
|
||||
def test_build_lyrics_outline_css(self):
|
||||
"""
|
||||
|
@ -363,7 +363,7 @@ class Htmbuilder(TestCase, TestMixin):
|
|||
css = build_lyrics_outline_css(theme_data)
|
||||
|
||||
# THEN: The css should be equal.
|
||||
self.assertEqual(LYRICS_OUTLINE_CSS, css, 'The outline css should be equal.')
|
||||
assert LYRICS_OUTLINE_CSS == css, 'The outline css should be equal.'
|
||||
|
||||
def test_build_lyrics_format_css(self):
|
||||
"""
|
||||
|
@ -386,7 +386,7 @@ class Htmbuilder(TestCase, TestMixin):
|
|||
css = build_lyrics_format_css(theme_data, width, height)
|
||||
|
||||
# THEN: They should be equal.
|
||||
self.assertEqual(LYRICS_FORMAT_CSS, css, 'The lyrics format css should be equal.')
|
||||
assert LYRICS_FORMAT_CSS == css, 'The lyrics format css should be equal.'
|
||||
|
||||
def test_build_footer_css(self):
|
||||
"""
|
||||
|
@ -404,7 +404,7 @@ class Htmbuilder(TestCase, TestMixin):
|
|||
css = build_footer_css(item, height)
|
||||
|
||||
# THEN: THE css should be the same.
|
||||
self.assertEqual(FOOTER_CSS, css, 'The footer strings should be equal.')
|
||||
assert FOOTER_CSS == css, 'The footer strings should be equal.'
|
||||
|
||||
def test_build_footer_css_wrap(self):
|
||||
"""
|
||||
|
@ -423,7 +423,7 @@ class Htmbuilder(TestCase, TestMixin):
|
|||
css = build_footer_css(item, height)
|
||||
|
||||
# THEN: Footer should wrap
|
||||
self.assertEqual(FOOTER_CSS_WRAP, css, 'The footer strings should be equal.')
|
||||
assert FOOTER_CSS_WRAP == css, 'The footer strings should be equal.'
|
||||
|
||||
def test_build_footer_invalid(self):
|
||||
"""
|
||||
|
@ -443,8 +443,8 @@ class Htmbuilder(TestCase, TestMixin):
|
|||
css.append(build_footer_css(item, height))
|
||||
|
||||
# THEN: Footer should wrap
|
||||
self.assertEqual(FOOTER_CSS_INVALID, css[0], 'The footer strings should be blank.')
|
||||
self.assertEqual(FOOTER_CSS_INVALID, css[1], 'The footer strings should be blank.')
|
||||
assert FOOTER_CSS_INVALID == css[0], 'The footer strings should be blank.'
|
||||
assert FOOTER_CSS_INVALID == css[1], 'The footer strings should be blank.'
|
||||
|
||||
def test_webkit_version(self):
|
||||
"""
|
||||
|
@ -454,7 +454,7 @@ class Htmbuilder(TestCase, TestMixin):
|
|||
webkit_ver = float(QtWebKit.qWebKitVersion())
|
||||
# WHEN: Retrieving the webkit version
|
||||
# THEN: Webkit versions should match
|
||||
self.assertEquals(webkit_version(), webkit_ver, "The returned webkit version doesn't match the installed one")
|
||||
assert webkit_version() == webkit_ver, "The returned webkit version doesn't match the installed one"
|
||||
|
||||
def test_build_chords_css(self):
|
||||
"""
|
||||
|
@ -468,4 +468,4 @@ class Htmbuilder(TestCase, TestMixin):
|
|||
chord_css = build_chords_css()
|
||||
|
||||
# THEN: The build css should look as expected
|
||||
self.assertEqual(CHORD_CSS_ENABLED, chord_css, 'The chord CSS should look as expected')
|
||||
assert CHORD_CSS_ENABLED == chord_css, 'The chord CSS should look as expected'
|
||||
|
|
|
@ -84,7 +84,7 @@ class TestImageManager(TestCase, TestMixin):
|
|||
# THEN a KeyError is thrown
|
||||
with self.assertRaises(KeyError) as context:
|
||||
self.image_manager.get_image(TEST_PATH, 'church1.jpg')
|
||||
self.assertNotEquals(context.exception, '', 'KeyError exception should have been thrown for missing image')
|
||||
assert context.exception is not '', 'KeyError exception should have been thrown for missing image'
|
||||
|
||||
def test_different_dimension_image(self):
|
||||
"""
|
||||
|
@ -98,7 +98,7 @@ class TestImageManager(TestCase, TestMixin):
|
|||
image = self.image_manager.get_image(full_path, 'church.jpg', 80, 80)
|
||||
|
||||
# THEN: The return should be of type image
|
||||
self.assertEqual(isinstance(image, QtGui.QImage), True, 'The returned object should be a QImage')
|
||||
assert isinstance(image, QtGui.QImage), 'The returned object should be a QImage'
|
||||
|
||||
# WHEN: adding the same image with different dimensions
|
||||
self.image_manager.add_image(full_path, 'church.jpg', None, 100, 100)
|
||||
|
@ -116,7 +116,7 @@ class TestImageManager(TestCase, TestMixin):
|
|||
# WHEN: calling with correct image, but wrong dimensions
|
||||
with self.assertRaises(KeyError) as context:
|
||||
self.image_manager.get_image(full_path, 'church.jpg', 120, 120)
|
||||
self.assertNotEquals(context.exception, '', 'KeyError exception should have been thrown for missing dimension')
|
||||
assert context.exception is not '', 'KeyError exception should have been thrown for missing dimension'
|
||||
|
||||
def test_process_cache(self):
|
||||
"""
|
||||
|
@ -141,10 +141,8 @@ class TestImageManager(TestCase, TestMixin):
|
|||
# is being processed (see mocked methods/functions).
|
||||
# Note: Priority.Normal means, that the resize_image() was not completed yet (because afterwards the #
|
||||
# priority is adjusted to Priority.Lowest).
|
||||
self.assertEqual(self.get_image_priority(image1), Priority.Normal,
|
||||
"image1's priority should be 'Priority.Normal'")
|
||||
self.assertEqual(self.get_image_priority(image2), Priority.Normal,
|
||||
"image2's priority should be 'Priority.Normal'")
|
||||
assert self.get_image_priority(image1) == Priority.Normal, "image1's priority should be 'Priority.Normal'"
|
||||
assert self.get_image_priority(image2) == Priority.Normal, "image2's priority should be 'Priority.Normal'"
|
||||
|
||||
# WHEN: Add more images.
|
||||
self.image_manager.add_image(TEST_PATH, image3, None)
|
||||
|
@ -162,15 +160,15 @@ class TestImageManager(TestCase, TestMixin):
|
|||
# Because empty() is not reliable, wait a litte; just to make sure.
|
||||
time.sleep(0.1)
|
||||
# THEN: The images' priority reflect how they were processed.
|
||||
self.assertEqual(self.image_manager._conversion_queue.qsize(), 0, "The queue should be empty.")
|
||||
self.assertEqual(self.get_image_priority(image1), Priority.Lowest,
|
||||
"The image should have not been requested (=Lowest)")
|
||||
self.assertEqual(self.get_image_priority(image2), Priority.Lowest,
|
||||
"The image should have not been requested (=Lowest)")
|
||||
self.assertEqual(self.get_image_priority(image3), Priority.Low,
|
||||
"Only the QImage should have been requested (=Low).")
|
||||
self.assertEqual(self.get_image_priority(image4), Priority.Urgent,
|
||||
"The image bytes should have been requested (=Urgent).")
|
||||
assert self.image_manager._conversion_queue.qsize() == 0, "The queue should be empty."
|
||||
assert self.get_image_priority(image1) == Priority.Lowest, \
|
||||
"The image should have not been requested (=Lowest)"
|
||||
assert self.get_image_priority(image2) == Priority.Lowest, \
|
||||
"The image should have not been requested (=Lowest)"
|
||||
assert self.get_image_priority(image3) == Priority.Low, \
|
||||
"Only the QImage should have been requested (=Low)."
|
||||
assert self.get_image_priority(image4) == Priority.Urgent, \
|
||||
"The image bytes should have been requested (=Urgent)."
|
||||
|
||||
def get_image_priority(self, image):
|
||||
"""
|
||||
|
|
|
@ -49,8 +49,8 @@ class TestLib(TestCase):
|
|||
true_result = str_to_bool(true_boolean)
|
||||
|
||||
# THEN: We should get back a True bool
|
||||
self.assertIsInstance(true_result, bool, 'The result should be a boolean')
|
||||
self.assertTrue(true_result, 'The result should be True')
|
||||
assert isinstance(true_result, bool), 'The result should be a boolean'
|
||||
assert true_result is True, 'The result should be True'
|
||||
|
||||
def test_str_to_bool_with_bool_false(self):
|
||||
"""
|
||||
|
@ -63,8 +63,8 @@ class TestLib(TestCase):
|
|||
false_result = str_to_bool(false_boolean)
|
||||
|
||||
# THEN: We should get back a True bool
|
||||
self.assertIsInstance(false_result, bool, 'The result should be a boolean')
|
||||
self.assertFalse(false_result, 'The result should be True')
|
||||
assert isinstance(false_result, bool), 'The result should be a boolean'
|
||||
assert false_result is False, 'The result should be True'
|
||||
|
||||
def test_str_to_bool_with_integer(self):
|
||||
"""
|
||||
|
@ -77,7 +77,7 @@ class TestLib(TestCase):
|
|||
int_result = str_to_bool(int_string)
|
||||
|
||||
# THEN: we should get back a false
|
||||
self.assertFalse(int_result, 'The result should be False')
|
||||
assert int_result is False, 'The result should be False'
|
||||
|
||||
def test_str_to_bool_with_invalid_string(self):
|
||||
"""
|
||||
|
@ -90,7 +90,7 @@ class TestLib(TestCase):
|
|||
str_result = str_to_bool(invalid_string)
|
||||
|
||||
# THEN: we should get back a false
|
||||
self.assertFalse(str_result, 'The result should be False')
|
||||
assert str_result is False, 'The result should be False'
|
||||
|
||||
def test_str_to_bool_with_string_false(self):
|
||||
"""
|
||||
|
@ -103,7 +103,7 @@ class TestLib(TestCase):
|
|||
false_result = str_to_bool(false_string)
|
||||
|
||||
# THEN: we should get back a false
|
||||
self.assertFalse(false_result, 'The result should be False')
|
||||
assert false_result is False, 'The result should be False'
|
||||
|
||||
def test_str_to_bool_with_string_no(self):
|
||||
"""
|
||||
|
@ -116,7 +116,7 @@ class TestLib(TestCase):
|
|||
str_result = str_to_bool(no_string)
|
||||
|
||||
# THEN: we should get back a false
|
||||
self.assertFalse(str_result, 'The result should be False')
|
||||
assert str_result is False, 'The result should be False'
|
||||
|
||||
def test_str_to_bool_with_true_string_value(self):
|
||||
"""
|
||||
|
@ -129,7 +129,7 @@ class TestLib(TestCase):
|
|||
true_result = str_to_bool(true_string)
|
||||
|
||||
# THEN: we should get back a true
|
||||
self.assertTrue(true_result, 'The result should be True')
|
||||
assert true_result is True, 'The result should be True'
|
||||
|
||||
def test_str_to_bool_with_yes_string_value(self):
|
||||
"""
|
||||
|
@ -142,7 +142,7 @@ class TestLib(TestCase):
|
|||
str_result = str_to_bool(yes_string)
|
||||
|
||||
# THEN: we should get back a true
|
||||
self.assertTrue(str_result, 'The result should be True')
|
||||
assert str_result is True, 'The result should be True'
|
||||
|
||||
def test_get_text_file_string_no_file(self):
|
||||
"""
|
||||
|
@ -157,7 +157,7 @@ class TestLib(TestCase):
|
|||
|
||||
# THEN: The result should be False
|
||||
file_path.is_file.assert_called_with()
|
||||
self.assertFalse(result, 'False should be returned if no file exists')
|
||||
assert result is False, 'False should be returned if no file exists'
|
||||
|
||||
def test_get_text_file_string_read_error(self):
|
||||
"""
|
||||
|
@ -176,7 +176,7 @@ class TestLib(TestCase):
|
|||
# THEN: None should be returned
|
||||
file_path.is_file.assert_called_once_with()
|
||||
file_path.open.assert_called_once_with('r', encoding='utf-8')
|
||||
self.assertIsNone(result, 'None should be returned if the file cannot be opened')
|
||||
assert result is None, 'None should be returned if the file cannot be opened'
|
||||
|
||||
def test_get_text_file_string_decode_error(self):
|
||||
"""
|
||||
|
@ -195,7 +195,7 @@ class TestLib(TestCase):
|
|||
result = build_icon(icon)
|
||||
|
||||
# THEN: The result should be the same icon as we passed in
|
||||
self.assertIs(icon, result, 'The result should be the same icon as we passed in')
|
||||
assert icon is result, 'The result should be the same icon as we passed in'
|
||||
|
||||
def test_build_icon_with_resource(self):
|
||||
"""
|
||||
|
@ -217,7 +217,7 @@ class TestLib(TestCase):
|
|||
MockedQPixmap.assert_called_with(resource_uri)
|
||||
# There really should be more assert statements here but due to type checking and things they all break. The
|
||||
# best we can do is to assert that we get back a MagicMock object.
|
||||
self.assertIsInstance(result, MagicMock, 'The result should be a MagicMock, because we mocked it out')
|
||||
assert isinstance(result, MagicMock), 'The result should be a MagicMock, because we mocked it out'
|
||||
|
||||
def test_image_to_byte(self):
|
||||
"""
|
||||
|
@ -240,8 +240,8 @@ class TestLib(TestCase):
|
|||
MockedQtCore.QBuffer.assert_called_with(mocked_byte_array)
|
||||
mocked_buffer.open.assert_called_with('writeonly')
|
||||
mocked_image.save.assert_called_with(mocked_buffer, "PNG")
|
||||
self.assertFalse(mocked_byte_array.toBase64.called)
|
||||
self.assertEqual(mocked_byte_array, result, 'The mocked out byte array should be returned')
|
||||
assert mocked_byte_array.toBase64.called is False
|
||||
assert mocked_byte_array == result, 'The mocked out byte array should be returned'
|
||||
|
||||
def test_image_to_byte_base_64(self):
|
||||
"""
|
||||
|
@ -266,8 +266,7 @@ class TestLib(TestCase):
|
|||
mocked_buffer.open.assert_called_with('writeonly')
|
||||
mocked_image.save.assert_called_with(mocked_buffer, "PNG")
|
||||
mocked_byte_array.toBase64.assert_called_with()
|
||||
self.assertEqual('base64mock', result, 'The result should be the return value of the mocked out '
|
||||
'base64 method')
|
||||
assert 'base64mock' == result, 'The result should be the return value of the mocked out base64 method'
|
||||
|
||||
def test_create_thumb_with_size(self):
|
||||
"""
|
||||
|
@ -286,16 +285,16 @@ class TestLib(TestCase):
|
|||
pass
|
||||
|
||||
# Only continue when the thumb does not exist.
|
||||
self.assertFalse(thumb_path.exists(), 'Test was not run, because the thumb already exists.')
|
||||
assert thumb_path.exists() is False, 'Test was not run, because the thumb already exists.'
|
||||
|
||||
# WHEN: Create the thumb.
|
||||
icon = create_thumb(image_path, thumb_path, size=thumb_size)
|
||||
|
||||
# THEN: Check if the thumb was created and scaled to the given size.
|
||||
self.assertTrue(thumb_path.exists(), 'Test was not ran, because the thumb already exists')
|
||||
self.assertIsInstance(icon, QtGui.QIcon, 'The icon should be a QIcon')
|
||||
self.assertFalse(icon.isNull(), 'The icon should not be null')
|
||||
self.assertEqual(thumb_size, QtGui.QImageReader(str(thumb_path)).size(), 'The thumb should have the given size')
|
||||
assert isinstance(icon, QtGui.QIcon), 'The icon should be a QIcon'
|
||||
assert icon.isNull() is False, 'The icon should not be null'
|
||||
assert thumb_size == QtGui.QImageReader(str(thumb_path)).size(), 'The thumb should have the given size'
|
||||
|
||||
# Remove the thumb so that the test actually tests if the thumb will be created.
|
||||
try:
|
||||
|
@ -320,17 +319,16 @@ class TestLib(TestCase):
|
|||
pass
|
||||
|
||||
# Only continue when the thumb does not exist.
|
||||
self.assertFalse(thumb_path.exists(), 'Test was not run, because the thumb already exists.')
|
||||
assert thumb_path.exists() is False, 'Test was not run, because the thumb already exists.'
|
||||
|
||||
# WHEN: Create the thumb.
|
||||
icon = create_thumb(image_path, thumb_path)
|
||||
|
||||
# THEN: Check if the thumb was created, retaining its aspect ratio.
|
||||
self.assertTrue(thumb_path.exists(), 'Test was not ran, because the thumb already exists')
|
||||
self.assertIsInstance(icon, QtGui.QIcon, 'The icon should be a QIcon')
|
||||
self.assertFalse(icon.isNull(), 'The icon should not be null')
|
||||
self.assertEqual(expected_size, QtGui.QImageReader(str(thumb_path)).size(),
|
||||
'The thumb should have the given size')
|
||||
assert isinstance(icon, QtGui.QIcon), 'The icon should be a QIcon'
|
||||
assert icon.isNull() is False, 'The icon should not be null'
|
||||
assert expected_size == QtGui.QImageReader(str(thumb_path)).size(), 'The thumb should have the given size'
|
||||
|
||||
# Remove the thumb so that the test actually tests if the thumb will be created.
|
||||
try:
|
||||
|
@ -356,17 +354,16 @@ class TestLib(TestCase):
|
|||
pass
|
||||
|
||||
# Only continue when the thumb does not exist.
|
||||
self.assertFalse(thumb_path.exists(), 'Test was not run, because the thumb already exists.')
|
||||
assert thumb_path.exists() is False, 'Test was not run, because the thumb already exists.'
|
||||
|
||||
# WHEN: Create the thumb.
|
||||
icon = create_thumb(image_path, thumb_path, size=thumb_size)
|
||||
|
||||
# THEN: Check if the thumb was created, retaining its aspect ratio.
|
||||
self.assertTrue(thumb_path.exists(), 'Test was not ran, because the thumb already exists')
|
||||
self.assertIsInstance(icon, QtGui.QIcon, 'The icon should be a QIcon')
|
||||
self.assertFalse(icon.isNull(), 'The icon should not be null')
|
||||
self.assertEqual(expected_size, QtGui.QImageReader(str(thumb_path)).size(),
|
||||
'The thumb should have the given size')
|
||||
assert thumb_path.exists() is True, 'Test was not ran, because the thumb already exists'
|
||||
assert isinstance(icon, QtGui.QIcon), 'The icon should be a QIcon'
|
||||
assert icon.isNull() is False, 'The icon should not be null'
|
||||
assert expected_size == QtGui.QImageReader(str(thumb_path)).size(), 'The thumb should have the given size'
|
||||
|
||||
# Remove the thumb so that the test actually tests if the thumb will be created.
|
||||
try:
|
||||
|
@ -392,17 +389,16 @@ class TestLib(TestCase):
|
|||
pass
|
||||
|
||||
# Only continue when the thumb does not exist.
|
||||
self.assertFalse(thumb_path.exists(), 'Test was not run, because the thumb already exists.')
|
||||
assert thumb_path.exists() is False, 'Test was not run, because the thumb already exists.'
|
||||
|
||||
# WHEN: Create the thumb.
|
||||
icon = create_thumb(image_path, thumb_path, size=thumb_size)
|
||||
|
||||
# THEN: Check if the thumb was created, retaining its aspect ratio.
|
||||
self.assertTrue(thumb_path.exists(), 'Test was not ran, because the thumb already exists')
|
||||
self.assertIsInstance(icon, QtGui.QIcon, 'The icon should be a QIcon')
|
||||
self.assertFalse(icon.isNull(), 'The icon should not be null')
|
||||
self.assertEqual(
|
||||
expected_size, QtGui.QImageReader(str(thumb_path)).size(), 'The thumb should have the given size')
|
||||
assert thumb_path.exists() is True, 'Test was not ran, because the thumb already exists'
|
||||
assert isinstance(icon, QtGui.QIcon), 'The icon should be a QIcon'
|
||||
assert icon.isNull() is False, 'The icon should not be null'
|
||||
assert expected_size == QtGui.QImageReader(str(thumb_path)).size(), 'The thumb should have the given size'
|
||||
|
||||
# Remove the thumb so that the test actually tests if the thumb will be created.
|
||||
try:
|
||||
|
@ -428,17 +424,16 @@ class TestLib(TestCase):
|
|||
pass
|
||||
|
||||
# Only continue when the thumb does not exist.
|
||||
self.assertFalse(thumb_path.exists(), 'Test was not run, because the thumb already exists.')
|
||||
assert thumb_path.exists() is False, 'Test was not run, because the thumb already exists.'
|
||||
|
||||
# WHEN: Create the thumb.
|
||||
icon = create_thumb(image_path, thumb_path, size=thumb_size)
|
||||
|
||||
# THEN: Check if the thumb was created, retaining its aspect ratio.
|
||||
self.assertTrue(thumb_path.exists(), 'Test was not ran, because the thumb already exists')
|
||||
self.assertIsInstance(icon, QtGui.QIcon, 'The icon should be a QIcon')
|
||||
self.assertFalse(icon.isNull(), 'The icon should not be null')
|
||||
self.assertEqual(
|
||||
expected_size, QtGui.QImageReader(str(thumb_path)).size(), 'The thumb should have the given size')
|
||||
assert isinstance(icon, QtGui.QIcon), 'The icon should be a QIcon'
|
||||
assert icon.isNull() is False, 'The icon should not be null'
|
||||
assert expected_size == QtGui.QImageReader(str(thumb_path)).size(), 'The thumb should have the given size'
|
||||
|
||||
# Remove the thumb so that the test actually tests if the thumb will be created.
|
||||
try:
|
||||
|
@ -465,7 +460,7 @@ class TestLib(TestCase):
|
|||
pass
|
||||
|
||||
# Only continue when the thumb does not exist.
|
||||
self.assertFalse(thumb_path.exists(), 'Test was not run, because the thumb already exists.')
|
||||
assert thumb_path.exists() is False, 'Test was not run, because the thumb already exists.'
|
||||
|
||||
# WHEN: Create the thumb.
|
||||
with patch('openlp.core.lib.QtGui.QImageReader.size') as mocked_size:
|
||||
|
@ -474,10 +469,9 @@ class TestLib(TestCase):
|
|||
|
||||
# THEN: Check if the thumb was created with aspect ratio of 1.
|
||||
self.assertTrue(thumb_path.exists(), 'Test was not ran, because the thumb already exists')
|
||||
self.assertIsInstance(icon, QtGui.QIcon, 'The icon should be a QIcon')
|
||||
self.assertFalse(icon.isNull(), 'The icon should not be null')
|
||||
self.assertEqual(
|
||||
expected_size_1, QtGui.QImageReader(str(thumb_path)).size(), 'The thumb should have the given size')
|
||||
assert isinstance(icon, QtGui.QIcon), 'The icon should be a QIcon'
|
||||
assert icon.isNull() is False, 'The icon should not be null'
|
||||
assert expected_size_1 == QtGui.QImageReader(str(thumb_path)).size(), 'The thumb should have the given size'
|
||||
|
||||
# WHEN: Create the thumb.
|
||||
with patch('openlp.core.lib.QtGui.QImageReader.size') as mocked_size:
|
||||
|
@ -485,10 +479,9 @@ class TestLib(TestCase):
|
|||
icon = create_thumb(image_path, thumb_path, size=thumb_size)
|
||||
|
||||
# THEN: Check if the thumb was created with aspect ratio of 1.
|
||||
self.assertIsInstance(icon, QtGui.QIcon, 'The icon should be a QIcon')
|
||||
self.assertFalse(icon.isNull(), 'The icon should not be null')
|
||||
self.assertEqual(
|
||||
expected_size_2, QtGui.QImageReader(str(thumb_path)).size(), 'The thumb should have the given size')
|
||||
assert isinstance(icon, QtGui.QIcon), 'The icon should be a QIcon'
|
||||
assert icon.isNull() is False, 'The icon should not be null'
|
||||
assert expected_size_2 == QtGui.QImageReader(str(thumb_path)).size(), 'The thumb should have the given size'
|
||||
|
||||
# Remove the thumb so that the test actually tests if the thumb will be created.
|
||||
try:
|
||||
|
@ -511,7 +504,7 @@ class TestLib(TestCase):
|
|||
|
||||
# THEN: The selectedIndexes function should have been called and the result should be true
|
||||
mocked_list_widget.selectedIndexes.assert_called_with()
|
||||
self.assertTrue(result, 'The result should be True')
|
||||
assert result is True, 'The result should be True'
|
||||
|
||||
def test_check_item_selected_false(self):
|
||||
"""
|
||||
|
@ -532,7 +525,7 @@ class TestLib(TestCase):
|
|||
# THEN: The selectedIndexes function should have been called and the result should be true
|
||||
mocked_list_widget.selectedIndexes.assert_called_with()
|
||||
MockedQtWidgets.QMessageBox.information.assert_called_with('parent', 'mocked translate', 'message')
|
||||
self.assertFalse(result, 'The result should be False')
|
||||
assert result is False, 'The result should be False'
|
||||
|
||||
def test_clean_tags(self):
|
||||
"""
|
||||
|
@ -554,7 +547,7 @@ class TestLib(TestCase):
|
|||
result_string = clean_tags(string_to_pass)
|
||||
|
||||
# THEN: The strings should be identical.
|
||||
self.assertEqual(wanted_string, result_string, 'The strings should be identical')
|
||||
assert wanted_string == result_string, 'The strings should be identical'
|
||||
|
||||
def test_expand_tags(self):
|
||||
"""
|
||||
|
@ -593,7 +586,7 @@ class TestLib(TestCase):
|
|||
result_string = expand_tags(string_to_pass)
|
||||
|
||||
# THEN: The strings should be identical.
|
||||
self.assertEqual(wanted_string, result_string, 'The strings should be identical.')
|
||||
assert wanted_string == result_string, 'The strings should be identical.'
|
||||
|
||||
def test_validate_thumb_file_does_not_exist(self):
|
||||
"""
|
||||
|
@ -609,7 +602,7 @@ class TestLib(TestCase):
|
|||
|
||||
# THEN: we should have called a few functions, and the result should be False
|
||||
thumb_path.exists.assert_called_once_with()
|
||||
self.assertFalse(result, 'The result should be False')
|
||||
assert result is False, 'The result should be False'
|
||||
|
||||
def test_validate_thumb_file_exists_and_newer(self):
|
||||
"""
|
||||
|
@ -624,7 +617,7 @@ class TestLib(TestCase):
|
|||
result = validate_thumb(file_path, thumb_path)
|
||||
|
||||
# THEN: `validate_thumb` should return True
|
||||
self.assertTrue(result)
|
||||
assert result is True
|
||||
|
||||
def test_validate_thumb_file_exists_and_older(self):
|
||||
"""
|
||||
|
@ -639,7 +632,7 @@ class TestLib(TestCase):
|
|||
|
||||
# THEN: `validate_thumb` should return False
|
||||
thumb_path.stat.assert_called_once_with()
|
||||
self.assertFalse(result, 'The result should be False')
|
||||
assert result is False, 'The result should be False'
|
||||
|
||||
def test_resize_thumb(self):
|
||||
"""
|
||||
|
@ -658,9 +651,9 @@ class TestLib(TestCase):
|
|||
|
||||
# THEN: Check if the size is correct and the background was set.
|
||||
result_size = image.size()
|
||||
self.assertEqual(wanted_height, result_size.height(), 'The image should have the requested height.')
|
||||
self.assertEqual(wanted_width, result_size.width(), 'The image should have the requested width.')
|
||||
self.assertEqual(image.pixel(0, 0), wanted_background_rgb, 'The background should be white.')
|
||||
assert wanted_height == result_size.height(), 'The image should have the requested height.'
|
||||
assert wanted_width == result_size.width(), 'The image should have the requested width.'
|
||||
assert image.pixel(0, 0) == wanted_background_rgb, 'The background should be white.'
|
||||
|
||||
def test_resize_thumb_ignoring_aspect_ratio(self):
|
||||
"""
|
||||
|
@ -679,9 +672,9 @@ class TestLib(TestCase):
|
|||
|
||||
# THEN: Check if the size is correct and the background was set.
|
||||
result_size = image.size()
|
||||
self.assertEqual(wanted_height, result_size.height(), 'The image should have the requested height.')
|
||||
self.assertEqual(wanted_width, result_size.width(), 'The image should have the requested width.')
|
||||
self.assertEqual(image.pixel(0, 0), wanted_background_rgb, 'The background should be white.')
|
||||
assert wanted_height == result_size.height(), 'The image should have the requested height.'
|
||||
assert wanted_width == result_size.width(), 'The image should have the requested width.'
|
||||
assert image.pixel(0, 0) == wanted_background_rgb, 'The background should be white.'
|
||||
|
||||
@patch('openlp.core.lib.QtCore.QLocale.createSeparatedList')
|
||||
def test_create_separated_list_qlocate(self, mocked_createSeparatedList):
|
||||
|
@ -696,8 +689,8 @@ class TestLib(TestCase):
|
|||
string_result = create_separated_list(string_list)
|
||||
|
||||
# THEN: We should have "Author 1, Author 2, and Author 3"
|
||||
self.assertEqual(string_result, 'Author 1, Author 2 and Author 3', 'The string should be "Author 1, '
|
||||
'Author 2, and Author 3".')
|
||||
assert string_result == 'Author 1, Author 2 and Author 3', \
|
||||
'The string should be "Author 1, Author 2, and Author 3".'
|
||||
|
||||
def test_create_separated_list_empty_list(self):
|
||||
"""
|
||||
|
@ -710,7 +703,7 @@ class TestLib(TestCase):
|
|||
string_result = create_separated_list(string_list)
|
||||
|
||||
# THEN: We shoud have an emptry string.
|
||||
self.assertEqual(string_result, '', 'The string sould be empty.')
|
||||
assert string_result == '', 'The string sould be empty.'
|
||||
|
||||
def test_create_separated_list_with_one_item(self):
|
||||
"""
|
||||
|
@ -723,7 +716,7 @@ class TestLib(TestCase):
|
|||
string_result = create_separated_list(string_list)
|
||||
|
||||
# THEN: We should have "Author 1"
|
||||
self.assertEqual(string_result, 'Author 1', 'The string should be "Author 1".')
|
||||
assert string_result == 'Author 1', 'The string should be "Author 1".'
|
||||
|
||||
def test_create_separated_list_with_two_items(self):
|
||||
"""
|
||||
|
@ -736,7 +729,7 @@ class TestLib(TestCase):
|
|||
string_result = create_separated_list(string_list)
|
||||
|
||||
# THEN: We should have "Author 1 and Author 2"
|
||||
self.assertEqual(string_result, 'Author 1 and Author 2', 'The string should be "Author 1 and Author 2".')
|
||||
assert string_result == 'Author 1 and Author 2', 'The string should be "Author 1 and Author 2".'
|
||||
|
||||
def test_create_separated_list_with_three_items(self):
|
||||
"""
|
||||
|
@ -749,8 +742,8 @@ class TestLib(TestCase):
|
|||
string_result = create_separated_list(string_list)
|
||||
|
||||
# THEN: We should have "Author 1, Author 2 and Author 3"
|
||||
self.assertEqual(string_result, 'Author 1, Author 2 and Author 3', 'The string should be "Author 1, '
|
||||
'Author 2, and Author 3".')
|
||||
assert string_result == 'Author 1, Author 2 and Author 3', \
|
||||
'The string should be "Author 1, Author 2, and Author 3".'
|
||||
|
||||
def test_expand_chords(self):
|
||||
"""
|
||||
|
@ -766,7 +759,7 @@ class TestLib(TestCase):
|
|||
expected_html = '<span class="chordline firstchordline">H<span class="chord"><span><strong>C</strong></span>' \
|
||||
'</span>alleluya.<span class="chord"><span><strong>F</strong></span></span><span class="ws">' \
|
||||
' </span> <span class="chord"><span><strong>G</strong></span></span></span>'
|
||||
self.assertEqual(expected_html, text_with_expanded_chords, 'The expanded chords should look as expected!')
|
||||
assert expected_html == text_with_expanded_chords, 'The expanded chords should look as expected!'
|
||||
|
||||
def test_expand_chords2(self):
|
||||
"""
|
||||
|
@ -782,7 +775,7 @@ class TestLib(TestCase):
|
|||
expected_html = '<span class="chordline firstchordline">I<span class="chord"><span><strong>D</strong></span>' \
|
||||
'</span>'M NOT MOVED BY WHAT I SEE HALLE<span class="chord"><span><strong>F</strong>' \
|
||||
'</span></span>LUJA<span class="chord"><span><strong>C</strong></span></span>H</span>'
|
||||
self.assertEqual(expected_html, text_with_expanded_chords, 'The expanded chords should look as expected!')
|
||||
assert expected_html == text_with_expanded_chords, 'The expanded chords should look as expected!'
|
||||
|
||||
def test_compare_chord_lyric_short_chord(self):
|
||||
"""
|
||||
|
@ -810,7 +803,7 @@ class TestLib(TestCase):
|
|||
ret = compare_chord_lyric(chord, lyrics)
|
||||
|
||||
# THEN: The returned value should 4 because the chord is longer than the lyric
|
||||
self.assertEquals(4, ret, 'The returned value should 4 because the chord is longer than the lyric')
|
||||
assert 4 == ret, 'The returned value should 4 because the chord is longer than the lyric'
|
||||
|
||||
def test_find_formatting_tags(self):
|
||||
"""
|
||||
|
@ -825,7 +818,7 @@ class TestLib(TestCase):
|
|||
active_tags = find_formatting_tags(lyrics, tags)
|
||||
|
||||
# THEN: The list of active tags should contain only 'st'
|
||||
self.assertListEqual(['st'], active_tags, 'The list of active tags should contain only "st"')
|
||||
assert ['st'] == active_tags, 'The list of active tags should contain only "st"'
|
||||
|
||||
def test_expand_chords_for_printing(self):
|
||||
"""
|
||||
|
@ -862,4 +855,4 @@ class TestLib(TestCase):
|
|||
'<table class="segment" cellpadding="0" cellspacing="0" border="0" align="left"><tr ' \
|
||||
'class="chordrow"><td class="chord">F</td></tr><tr><td class="lyrics">{st}{/st} </td>' \
|
||||
'</tr></table></td></tr></table>'
|
||||
self.assertEqual(expected_html, text_with_expanded_chords, 'The expanded chords should look as expected!')
|
||||
assert expected_html == text_with_expanded_chords, 'The expanded chords should look as expected!'
|
||||
|
|
|
@ -69,11 +69,11 @@ class TestMediaManagerItem(TestCase, TestMixin):
|
|||
# WHEN: Object is created
|
||||
mmi.required_icons()
|
||||
# THEN: Default icons should be populated
|
||||
self.assertFalse(mmi.has_import_icon, 'There should be no import icon by default')
|
||||
self.assertTrue(mmi.has_new_icon, 'By default a new icon should be present')
|
||||
self.assertFalse(mmi.has_file_icon, 'There should be no file icon by default')
|
||||
self.assertTrue(mmi.has_delete_icon, 'By default a delete icon should be present')
|
||||
self.assertFalse(mmi.add_to_service_item, 'There should be no add_to_service icon by default')
|
||||
assert mmi.has_import_icon is False, 'There should be no import icon by default'
|
||||
assert mmi.has_new_icon is True, 'By default a new icon should be present'
|
||||
assert mmi.has_file_icon is False, 'There should be no file icon by default'
|
||||
assert mmi.has_delete_icon is True, 'By default a delete icon should be present'
|
||||
assert mmi.add_to_service_item is False, 'There should be no add_to_service icon by default'
|
||||
|
||||
@patch('openlp.core.lib.mediamanageritem.Settings')
|
||||
@patch('openlp.core.lib.mediamanageritem.MediaManagerItem.on_live_click')
|
||||
|
@ -111,5 +111,5 @@ class TestMediaManagerItem(TestCase, TestMixin):
|
|||
mmi.on_double_clicked()
|
||||
|
||||
# THEN: on_live_click() should have been called
|
||||
self.assertEqual(0, mocked_on_live_click.call_count, 'on_live_click() should not have been called')
|
||||
self.assertEqual(0, mocked_on_preview_click.call_count, 'on_preview_click() should not have been called')
|
||||
assert 0 == mocked_on_live_click.call_count, 'on_live_click() should not have been called'
|
||||
assert 0 == mocked_on_preview_click.call_count, 'on_preview_click() should not have been called'
|
||||
|
|
|
@ -64,8 +64,8 @@ class TestPluginManager(TestCase):
|
|||
plugin_manager.hook_media_manager()
|
||||
|
||||
# THEN: The create_media_manager_item() method should have been called
|
||||
self.assertEqual(0, mocked_plugin.create_media_manager_item.call_count,
|
||||
'The create_media_manager_item() method should not have been called.')
|
||||
assert 0 == mocked_plugin.create_media_manager_item.call_count, \
|
||||
'The create_media_manager_item() method should not have been called.'
|
||||
|
||||
def test_hook_media_manager_with_active_plugin(self):
|
||||
"""
|
||||
|
@ -97,8 +97,8 @@ class TestPluginManager(TestCase):
|
|||
plugin_manager.hook_settings_tabs()
|
||||
|
||||
# THEN: The hook_settings_tabs() method should have been called
|
||||
self.assertEqual(0, mocked_plugin.create_media_manager_item.call_count,
|
||||
'The create_media_manager_item() method should not have been called.')
|
||||
assert 0 == mocked_plugin.create_media_manager_item.call_count, \
|
||||
'The create_media_manager_item() method should not have been called.'
|
||||
|
||||
def test_hook_settings_tabs_with_disabled_plugin_and_mocked_form(self):
|
||||
"""
|
||||
|
@ -117,10 +117,10 @@ class TestPluginManager(TestCase):
|
|||
plugin_manager.hook_settings_tabs()
|
||||
|
||||
# THEN: The create_settings_tab() method should not have been called, but the plugins lists should be the same
|
||||
self.assertEqual(0, mocked_plugin.create_settings_tab.call_count,
|
||||
'The create_media_manager_item() method should not have been called.')
|
||||
self.assertEqual(mocked_settings_form.plugin_manager.plugins, plugin_manager.plugins,
|
||||
'The plugins on the settings form should be the same as the plugins in the plugin manager')
|
||||
assert 0 == mocked_plugin.create_settings_tab.call_count, \
|
||||
'The create_media_manager_item() method should not have been called.'
|
||||
assert mocked_settings_form.plugin_manager.plugins == plugin_manager.plugins, \
|
||||
'The plugins on the settings form should be the same as the plugins in the plugin manager'
|
||||
|
||||
def test_hook_settings_tabs_with_active_plugin_and_mocked_form(self):
|
||||
"""
|
||||
|
@ -139,10 +139,10 @@ class TestPluginManager(TestCase):
|
|||
plugin_manager.hook_settings_tabs()
|
||||
|
||||
# THEN: The create_media_manager_item() method should have been called with the mocked settings form
|
||||
self.assertEqual(1, mocked_plugin.create_settings_tab.call_count,
|
||||
'The create_media_manager_item() method should have been called once.')
|
||||
self.assertEqual(plugin_manager.plugins, mocked_settings_form.plugin_manager.plugins,
|
||||
'The plugins on the settings form should be the same as the plugins in the plugin manager')
|
||||
assert 1 == mocked_plugin.create_settings_tab.call_count, \
|
||||
'The create_media_manager_item() method should have been called once.'
|
||||
assert plugin_manager.plugins == mocked_settings_form.plugin_manager.plugins, \
|
||||
'The plugins on the settings form should be the same as the plugins in the plugin manager'
|
||||
|
||||
def test_hook_settings_tabs_with_active_plugin_and_no_form(self):
|
||||
"""
|
||||
|
@ -174,8 +174,8 @@ class TestPluginManager(TestCase):
|
|||
plugin_manager.hook_import_menu()
|
||||
|
||||
# THEN: The create_media_manager_item() method should have been called
|
||||
self.assertEqual(0, mocked_plugin.add_import_menu_item.call_count,
|
||||
'The add_import_menu_item() method should not have been called.')
|
||||
assert 0 == mocked_plugin.add_import_menu_item.call_count, \
|
||||
'The add_import_menu_item() method should not have been called.'
|
||||
|
||||
def test_hook_import_menu_with_active_plugin(self):
|
||||
"""
|
||||
|
@ -207,8 +207,8 @@ class TestPluginManager(TestCase):
|
|||
plugin_manager.hook_export_menu()
|
||||
|
||||
# THEN: The add_export_menu_item() method should not have been called
|
||||
self.assertEqual(0, mocked_plugin.add_export_menu_item.call_count,
|
||||
'The add_export_menu_item() method should not have been called.')
|
||||
assert 0 == mocked_plugin.add_export_menu_item.call_count, \
|
||||
'The add_export_menu_item() method should not have been called.'
|
||||
|
||||
def test_hook_export_menu_with_active_plugin(self):
|
||||
"""
|
||||
|
@ -241,8 +241,8 @@ class TestPluginManager(TestCase):
|
|||
plugin_manager.hook_upgrade_plugin_settings(settings)
|
||||
|
||||
# THEN: The upgrade_settings() method should not have been called
|
||||
self.assertEqual(0, mocked_plugin.upgrade_settings.call_count,
|
||||
'The upgrade_settings() method should not have been called.')
|
||||
assert 0 == mocked_plugin.upgrade_settings.call_count, \
|
||||
'The upgrade_settings() method should not have been called.'
|
||||
|
||||
def test_hook_upgrade_plugin_settings_with_active_plugin(self):
|
||||
"""
|
||||
|
@ -275,8 +275,8 @@ class TestPluginManager(TestCase):
|
|||
plugin_manager.hook_tools_menu()
|
||||
|
||||
# THEN: The add_tools_menu_item() method should have been called
|
||||
self.assertEqual(0, mocked_plugin.add_tools_menu_item.call_count,
|
||||
'The add_tools_menu_item() method should not have been called.')
|
||||
assert 0 == mocked_plugin.add_tools_menu_item.call_count, \
|
||||
'The add_tools_menu_item() method should not have been called.'
|
||||
|
||||
def test_hook_tools_menu_with_active_plugin(self):
|
||||
"""
|
||||
|
@ -310,7 +310,7 @@ class TestPluginManager(TestCase):
|
|||
|
||||
# THEN: The is_active() method should have been called, and initialise() method should NOT have been called
|
||||
mocked_plugin.is_active.assert_called_with()
|
||||
self.assertEqual(0, mocked_plugin.initialise.call_count, 'The initialise() method should not have been called.')
|
||||
assert 0 == mocked_plugin.initialise.call_count, 'The initialise() method should not have been called.'
|
||||
|
||||
def test_initialise_plugins_with_active_plugin(self):
|
||||
"""
|
||||
|
@ -346,7 +346,7 @@ class TestPluginManager(TestCase):
|
|||
|
||||
# THEN: The is_active() method should have been called, and initialise() method should NOT have been called
|
||||
mocked_plugin.is_active.assert_called_with()
|
||||
self.assertEqual(0, mocked_plugin.finalise.call_count, 'The finalise() method should not have been called.')
|
||||
assert 0 == mocked_plugin.finalise.call_count, 'The finalise() method should not have been called.'
|
||||
|
||||
def test_finalise_plugins_with_active_plugin(self):
|
||||
"""
|
||||
|
@ -380,7 +380,7 @@ class TestPluginManager(TestCase):
|
|||
result = plugin_manager.get_plugin_by_name('Missing Plugin')
|
||||
|
||||
# THEN: The is_active() and finalise() methods should have been called
|
||||
self.assertIsNone(result, 'The result for get_plugin_by_name should be None')
|
||||
assert result is None, 'The result for get_plugin_by_name should be None'
|
||||
|
||||
def test_get_plugin_by_name_exists(self):
|
||||
"""
|
||||
|
@ -396,7 +396,7 @@ class TestPluginManager(TestCase):
|
|||
result = plugin_manager.get_plugin_by_name('Mocked Plugin')
|
||||
|
||||
# THEN: The is_active() and finalise() methods should have been called
|
||||
self.assertEqual(result, mocked_plugin, 'The result for get_plugin_by_name should be the mocked plugin')
|
||||
assert result == mocked_plugin, 'The result for get_plugin_by_name should be the mocked plugin'
|
||||
|
||||
def test_new_service_created_with_disabled_plugin(self):
|
||||
"""
|
||||
|
@ -414,8 +414,8 @@ class TestPluginManager(TestCase):
|
|||
|
||||
# THEN: The isActive() method should have been called, and initialise() method should NOT have been called
|
||||
mocked_plugin.is_active.assert_called_with()
|
||||
self.assertEqual(0, mocked_plugin.new_service_created.call_count,
|
||||
'The new_service_created() method should not have been called.')
|
||||
assert 0 == mocked_plugin.new_service_created.call_count, \
|
||||
'The new_service_created() method should not have been called.'
|
||||
|
||||
def test_new_service_created_with_active_plugin(self):
|
||||
"""
|
||||
|
|
|
@ -28,7 +28,9 @@ from unittest.mock import MagicMock, patch
|
|||
|
||||
from openlp.core.common import md5_hash
|
||||
from openlp.core.common.registry import Registry
|
||||
from openlp.core.common.settings import Settings
|
||||
from openlp.core.lib import ItemCapabilities, ServiceItem, ServiceItemType, FormattingTags
|
||||
from tests.helpers.testmixin import TestMixin
|
||||
|
||||
from tests.utils import assert_length, convert_file_service_item
|
||||
|
||||
|
@ -59,19 +61,31 @@ RENDERED_VERSE = 'The Lord said to <span style="-webkit-text-fill-color:red">Noa
|
|||
FOOTER = ['Arky Arky (Unknown)', 'Public Domain', 'CCLI 123456']
|
||||
TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'service'))
|
||||
|
||||
__default_settings__ = {
|
||||
'songs/enable chords': True,
|
||||
}
|
||||
|
||||
class TestServiceItem(TestCase):
|
||||
|
||||
class TestServiceItem(TestCase, TestMixin):
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
Set up the Registry
|
||||
"""
|
||||
self.build_settings()
|
||||
Settings().extend_default_settings(__default_settings__)
|
||||
Registry.create()
|
||||
mocked_renderer = MagicMock()
|
||||
mocked_renderer.format_slide.return_value = [VERSE]
|
||||
Registry().register('renderer', mocked_renderer)
|
||||
Registry().register('image_manager', MagicMock())
|
||||
|
||||
def tearDown(self):
|
||||
"""
|
||||
Clean up
|
||||
"""
|
||||
self.destroy_settings()
|
||||
|
||||
def test_service_item_basic(self):
|
||||
"""
|
||||
Test the Service Item - basic test
|
||||
|
@ -82,8 +96,8 @@ class TestServiceItem(TestCase):
|
|||
service_item = ServiceItem(None)
|
||||
|
||||
# THEN: We should get back a valid service item
|
||||
self.assertTrue(service_item.is_valid, 'The new service item should be valid')
|
||||
self.assertTrue(service_item.missing_frames(), 'There should not be any frames in the service item')
|
||||
assert service_item.is_valid is True, 'The new service item should be valid'
|
||||
assert service_item.missing_frames() is True, 'There should not be any frames in the service item'
|
||||
|
||||
def test_service_item_load_custom_from_service(self):
|
||||
"""
|
||||
|
@ -99,7 +113,7 @@ class TestServiceItem(TestCase):
|
|||
service_item.set_from_service(line)
|
||||
|
||||
# THEN: We should get back a valid service item
|
||||
self.assertTrue(service_item.is_valid, 'The new service item should be valid')
|
||||
assert service_item.is_valid is True, 'The new service item should be valid'
|
||||
assert_length(0, service_item._display_frames, 'The service item should have no display frames')
|
||||
assert_length(5, service_item.capabilities, 'There should be 5 default custom item capabilities')
|
||||
|
||||
|
@ -107,14 +121,14 @@ class TestServiceItem(TestCase):
|
|||
service_item.render(True)
|
||||
|
||||
# THEN: The frames should also be valid
|
||||
self.assertEqual('Test Custom', service_item.get_display_title(), 'The title should be "Test Custom"')
|
||||
self.assertEqual(CLEANED_VERSE[:-1], service_item.get_frames()[0]['text'],
|
||||
'The returned text matches the input, except the last line feed')
|
||||
self.assertEqual(RENDERED_VERSE.split('\n', 1)[0], service_item.get_rendered_frame(1),
|
||||
'The first line has been returned')
|
||||
self.assertEqual('Slide 1', service_item.get_frame_title(0), '"Slide 1" has been returned as the title')
|
||||
self.assertEqual('Slide 2', service_item.get_frame_title(1), '"Slide 2" has been returned as the title')
|
||||
self.assertEqual('', service_item.get_frame_title(2), 'Blank has been returned as the title of slide 3')
|
||||
assert 'Test Custom' == service_item.get_display_title(), 'The title should be "Test Custom"'
|
||||
assert CLEANED_VERSE[:-1] == service_item.get_frames()[0]['text'], \
|
||||
'The returned text matches the input, except the last line feed'
|
||||
assert RENDERED_VERSE.split('\n', 1)[0] == service_item.get_rendered_frame(1), \
|
||||
'The first line has been returned'
|
||||
assert 'Slide 1' == service_item.get_frame_title(0), '"Slide 1" has been returned as the title'
|
||||
assert 'Slide 2' == service_item.get_frame_title(1), '"Slide 2" has been returned as the title'
|
||||
assert '' == service_item.get_frame_title(2), 'Blank has been returned as the title of slide 3'
|
||||
|
||||
def test_service_item_load_image_from_service(self):
|
||||
"""
|
||||
|
@ -138,26 +152,22 @@ class TestServiceItem(TestCase):
|
|||
service_item.set_from_service(line, TEST_PATH)
|
||||
|
||||
# THEN: We should get back a valid service item
|
||||
self.assertTrue(service_item.is_valid, 'The new service item should be valid')
|
||||
self.assertEqual(os.path.normpath(test_file), os.path.normpath(service_item.get_rendered_frame(0)),
|
||||
'The first frame should match the path to the image')
|
||||
self.assertEqual(frame_array, service_item.get_frames()[0],
|
||||
'The return should match frame array1')
|
||||
self.assertEqual(test_file, service_item.get_frame_path(0),
|
||||
'The frame path should match the full path to the image')
|
||||
self.assertEqual(image_name, service_item.get_frame_title(0),
|
||||
'The frame title should match the image name')
|
||||
self.assertEqual(image_name, service_item.get_display_title(),
|
||||
'The display title should match the first image name')
|
||||
self.assertTrue(service_item.is_image(), 'This service item should be of an "image" type')
|
||||
self.assertTrue(service_item.is_capable(ItemCapabilities.CanMaintain),
|
||||
'This service item should be able to be Maintained')
|
||||
self.assertTrue(service_item.is_capable(ItemCapabilities.CanPreview),
|
||||
'This service item should be able to be be Previewed')
|
||||
self.assertTrue(service_item.is_capable(ItemCapabilities.CanLoop),
|
||||
'This service item should be able to be run in a can be made to Loop')
|
||||
self.assertTrue(service_item.is_capable(ItemCapabilities.CanAppend),
|
||||
'This service item should be able to have new items added to it')
|
||||
assert service_item.is_valid is True, 'The new service item should be valid'
|
||||
assert os.path.normpath(test_file) == os.path.normpath(service_item.get_rendered_frame(0)), \
|
||||
'The first frame should match the path to the image'
|
||||
assert frame_array == service_item.get_frames()[0], 'The return should match frame array1'
|
||||
assert test_file == service_item.get_frame_path(0), 'The frame path should match the full path to the image'
|
||||
assert image_name == service_item.get_frame_title(0), 'The frame title should match the image name'
|
||||
assert image_name == service_item.get_display_title(), 'The display title should match the first image name'
|
||||
assert service_item.is_image() is True, 'This service item should be of an "image" type'
|
||||
assert service_item.is_capable(ItemCapabilities.CanMaintain) is True, \
|
||||
'This service item should be able to be Maintained'
|
||||
assert service_item.is_capable(ItemCapabilities.CanPreview) is True, \
|
||||
'This service item should be able to be be Previewed'
|
||||
assert service_item.is_capable(ItemCapabilities.CanLoop) is True, \
|
||||
'This service item should be able to be run in a can be made to Loop'
|
||||
assert service_item.is_capable(ItemCapabilities.CanAppend) is True, \
|
||||
'This service item should be able to have new items added to it'
|
||||
|
||||
def test_service_item_load_image_from_local_service(self):
|
||||
"""
|
||||
|
@ -193,35 +203,33 @@ class TestServiceItem(TestCase):
|
|||
|
||||
# This test is copied from service_item.py, but is changed since to conform to
|
||||
# new layout of service item. The layout use in serviceitem_image_2.osd is actually invalid now.
|
||||
self.assertTrue(service_item.is_valid, 'The first service item should be valid')
|
||||
self.assertTrue(service_item2.is_valid, 'The second service item should be valid')
|
||||
assert service_item.is_valid is True, 'The first service item should be valid'
|
||||
assert service_item2.is_valid is True, 'The second service item should be valid'
|
||||
# These test will fail on windows due to the difference in folder seperators
|
||||
if os.name != 'nt':
|
||||
self.assertEqual(test_file1, service_item.get_rendered_frame(0),
|
||||
'The first frame should match the path to the image')
|
||||
self.assertEqual(test_file2, service_item2.get_rendered_frame(0),
|
||||
'The Second frame should match the path to the image')
|
||||
self.assertEqual(frame_array1, service_item.get_frames()[0], 'The return should match the frame array1')
|
||||
self.assertEqual(frame_array2, service_item2.get_frames()[0], 'The return should match the frame array2')
|
||||
self.assertEqual(test_file1, service_item.get_frame_path(0),
|
||||
'The frame path should match the full path to the image')
|
||||
self.assertEqual(test_file2, service_item2.get_frame_path(0),
|
||||
'The frame path should match the full path to the image')
|
||||
self.assertEqual(image_name1, service_item.get_frame_title(0),
|
||||
'The 1st frame title should match the image name')
|
||||
self.assertEqual(image_name2, service_item2.get_frame_title(0),
|
||||
'The 2nd frame title should match the image name')
|
||||
self.assertEqual(service_item.name, service_item.title.lower(),
|
||||
'The plugin name should match the display title, as there are > 1 Images')
|
||||
self.assertTrue(service_item.is_image(), 'This service item should be of an "image" type')
|
||||
self.assertTrue(service_item.is_capable(ItemCapabilities.CanMaintain),
|
||||
'This service item should be able to be Maintained')
|
||||
self.assertTrue(service_item.is_capable(ItemCapabilities.CanPreview),
|
||||
'This service item should be able to be be Previewed')
|
||||
self.assertTrue(service_item.is_capable(ItemCapabilities.CanLoop),
|
||||
'This service item should be able to be run in a can be made to Loop')
|
||||
self.assertTrue(service_item.is_capable(ItemCapabilities.CanAppend),
|
||||
'This service item should be able to have new items added to it')
|
||||
assert test_file1 == service_item.get_rendered_frame(0), \
|
||||
'The first frame should match the path to the image'
|
||||
assert test_file2 == service_item2.get_rendered_frame(0), \
|
||||
'The Second frame should match the path to the image'
|
||||
assert frame_array1 == service_item.get_frames()[0], 'The return should match the frame array1'
|
||||
assert frame_array2 == service_item2.get_frames()[0], 'The return should match the frame array2'
|
||||
assert test_file1 == service_item.get_frame_path(0), \
|
||||
'The frame path should match the full path to the image'
|
||||
assert test_file2 == service_item2.get_frame_path(0), \
|
||||
'The frame path should match the full path to the image'
|
||||
assert image_name1 == service_item.get_frame_title(0), 'The 1st frame title should match the image name'
|
||||
assert image_name2 == service_item2.get_frame_title(0), 'The 2nd frame title should match the image name'
|
||||
assert service_item.name == service_item.title.lower(), \
|
||||
'The plugin name should match the display title, as there are > 1 Images'
|
||||
assert service_item.is_image() is True, 'This service item should be of an "image" type'
|
||||
assert service_item.is_capable(ItemCapabilities.CanMaintain) is True, \
|
||||
'This service item should be able to be Maintained'
|
||||
assert service_item.is_capable(ItemCapabilities.CanPreview) is True, \
|
||||
'This service item should be able to be be Previewed'
|
||||
assert service_item.is_capable(ItemCapabilities.CanLoop) is True, \
|
||||
'This service item should be able to be run in a can be made to Loop'
|
||||
assert service_item.is_capable(ItemCapabilities.CanAppend) is True, \
|
||||
'This service item should be able to have new items added to it'
|
||||
|
||||
def test_add_from_command_for_a_presentation(self):
|
||||
"""
|
||||
|
@ -240,8 +248,8 @@ class TestServiceItem(TestCase):
|
|||
service_item.add_from_command(TEST_PATH, presentation_name, image, display_title, notes)
|
||||
|
||||
# THEN: verify that it is setup as a Command and that the frame data matches
|
||||
self.assertEqual(service_item.service_item_type, ServiceItemType.Command, 'It should be a Command')
|
||||
self.assertEqual(service_item.get_frames()[0], frame, 'Frames should match')
|
||||
assert service_item.service_item_type == ServiceItemType.Command, 'It should be a Command'
|
||||
assert service_item.get_frames()[0] == frame, 'Frames should match'
|
||||
|
||||
def test_add_from_comamnd_without_display_title_and_notes(self):
|
||||
"""
|
||||
|
@ -258,8 +266,8 @@ class TestServiceItem(TestCase):
|
|||
service_item.add_from_command(TEST_PATH, image_name, image)
|
||||
|
||||
# THEN: verify that it is setup as a Command and that the frame data matches
|
||||
self.assertEqual(service_item.service_item_type, ServiceItemType.Command, 'It should be a Command')
|
||||
self.assertEqual(service_item.get_frames()[0], frame, 'Frames should match')
|
||||
assert service_item.service_item_type == ServiceItemType.Command, 'It should be a Command'
|
||||
assert service_item.get_frames()[0] == frame, 'Frames should match'
|
||||
|
||||
@patch(u'openlp.core.lib.serviceitem.ServiceItem.image_manager')
|
||||
@patch('openlp.core.lib.serviceitem.AppLocation.get_section_data_path')
|
||||
|
@ -287,9 +295,9 @@ class TestServiceItem(TestCase):
|
|||
service_item.add_from_command(TEST_PATH, presentation_name, thumb, display_title, notes)
|
||||
|
||||
# THEN: verify that it is setup as a Command and that the frame data matches
|
||||
self.assertEqual(service_item.service_item_type, ServiceItemType.Command, 'It should be a Command')
|
||||
self.assertEqual(service_item.get_frames()[0], frame, 'Frames should match')
|
||||
self.assertEqual(1, mocked_image_manager.add_image.call_count, 'image_manager should be used')
|
||||
assert service_item.service_item_type == ServiceItemType.Command, 'It should be a Command'
|
||||
assert service_item.get_frames()[0] == frame, 'Frames should match'
|
||||
assert 1 == mocked_image_manager.add_image.call_count, 'image_manager should be used'
|
||||
|
||||
def test_service_item_load_optical_media_from_service(self):
|
||||
"""
|
||||
|
@ -306,11 +314,11 @@ class TestServiceItem(TestCase):
|
|||
service_item.set_from_service(line)
|
||||
|
||||
# THEN: We should get back a valid service item with optical media info
|
||||
self.assertTrue(service_item.is_valid, 'The service item should be valid')
|
||||
self.assertTrue(service_item.is_capable(ItemCapabilities.IsOptical), 'The item should be Optical')
|
||||
self.assertEqual(service_item.start_time, 654.375, 'Start time should be 654.375')
|
||||
self.assertEqual(service_item.end_time, 672.069, 'End time should be 672.069')
|
||||
self.assertEqual(service_item.media_length, 17.694, 'Media length should be 17.694')
|
||||
assert service_item.is_valid is True, 'The service item should be valid'
|
||||
assert service_item.is_capable(ItemCapabilities.IsOptical) is True, 'The item should be Optical'
|
||||
assert service_item.start_time == 654.375, 'Start time should be 654.375'
|
||||
assert service_item.end_time == 672.069, 'End time should be 672.069'
|
||||
assert service_item.media_length == 17.694, 'Media length should be 17.694'
|
||||
|
||||
def test_service_item_load_song_and_audio_from_service(self):
|
||||
"""
|
||||
|
@ -326,22 +334,22 @@ class TestServiceItem(TestCase):
|
|||
service_item.set_from_service(line, '/test/')
|
||||
|
||||
# THEN: We should get back a valid service item
|
||||
self.assertTrue(service_item.is_valid, 'The new service item should be valid')
|
||||
assert_length(0, service_item._display_frames, 'The service item should have no display frames')
|
||||
assert_length(7, service_item.capabilities, 'There should be 7 default custom item capabilities')
|
||||
assert service_item.is_valid is True, 'The new service item should be valid'
|
||||
assert 0 == len(service_item._display_frames), 'The service item should have no display frames'
|
||||
assert 7 == len(service_item.capabilities), 'There should be 7 default custom item capabilities'
|
||||
|
||||
# WHEN: We render the frames of the service item
|
||||
service_item.render(True)
|
||||
|
||||
# THEN: The frames should also be valid
|
||||
self.assertEqual('Amazing Grace', service_item.get_display_title(), 'The title should be "Amazing Grace"')
|
||||
self.assertEqual(CLEANED_VERSE[:-1], service_item.get_frames()[0]['text'],
|
||||
'The returned text matches the input, except the last line feed')
|
||||
self.assertEqual(RENDERED_VERSE.split('\n', 1)[0], service_item.get_rendered_frame(1),
|
||||
'The first line has been returned')
|
||||
self.assertEqual('Amazing Grace! how sweet the s', service_item.get_frame_title(0),
|
||||
'"Amazing Grace! how sweet the s" has been returned as the title')
|
||||
self.assertEqual('’Twas grace that taught my hea', service_item.get_frame_title(1),
|
||||
'"’Twas grace that taught my hea" has been returned as the title')
|
||||
self.assertEqual('/test/amazing_grace.mp3', service_item.background_audio[0],
|
||||
'"/test/amazing_grace.mp3" should be in the background_audio list')
|
||||
assert 'Amazing Grace' == service_item.get_display_title(), 'The title should be "Amazing Grace"'
|
||||
assert CLEANED_VERSE[:-1] == service_item.get_frames()[0]['text'], \
|
||||
'The returned text matches the input, except the last line feed'
|
||||
assert RENDERED_VERSE.split('\n', 1)[0] == service_item.get_rendered_frame(1), \
|
||||
'The first line has been returned'
|
||||
assert 'Amazing Grace! how sweet the s' == service_item.get_frame_title(0), \
|
||||
'"Amazing Grace! how sweet the s" has been returned as the title'
|
||||
assert '’Twas grace that taught my hea' == service_item.get_frame_title(1), \
|
||||
'"’Twas grace that taught my hea" has been returned as the title'
|
||||
assert '/test/amazing_grace.mp3' == service_item.background_audio[0], \
|
||||
'"/test/amazing_grace.mp3" should be in the background_audio list'
|
||||
|
|
|
@ -90,8 +90,8 @@ class TestTheme(TestCase):
|
|||
|
||||
# THEN: The filename of the background should be correct
|
||||
expected_filename = path / 'MyBeautifulTheme' / 'video.mp4'
|
||||
self.assertEqual(expected_filename, theme.background_filename)
|
||||
self.assertEqual('MyBeautifulTheme', theme.theme_name)
|
||||
assert expected_filename == theme.background_filename
|
||||
assert 'MyBeautifulTheme' == theme.theme_name
|
||||
|
||||
def test_save_retrieve(self):
|
||||
"""
|
||||
|
@ -107,9 +107,9 @@ class TestTheme(TestCase):
|
|||
self.check_theme(lt)
|
||||
|
||||
def check_theme(self, theme):
|
||||
self.assertEqual('#000000', theme.background_border_color, 'background_border_color should be "#000000"')
|
||||
self.assertEqual('solid', theme.background_type, 'background_type should be "solid"')
|
||||
self.assertEqual(0, theme.display_vertical_align, 'display_vertical_align should be 0')
|
||||
self.assertFalse(theme.font_footer_bold, 'font_footer_bold should be False')
|
||||
self.assertEqual('Arial', theme.font_main_name, 'font_main_name should be "Arial"')
|
||||
self.assertEqual(47, len(theme.__dict__), 'The theme should have 47 attributes')
|
||||
assert '#000000' == theme.background_border_color, 'background_border_color should be "#000000"'
|
||||
assert 'solid' == theme.background_type, 'background_type should be "solid"'
|
||||
assert 0 == theme.display_vertical_align, 'display_vertical_align should be 0'
|
||||
assert theme.font_footer_bold is False, 'font_footer_bold should be False'
|
||||
assert 'Arial' == theme.font_main_name, 'font_main_name should be "Arial"'
|
||||
assert 47 == len(theme.__dict__), 'The theme should have 47 attributes'
|
||||
|
|
|
@ -49,8 +49,8 @@ class TestUi(TestCase):
|
|||
add_welcome_page(wizard, ':/wizards/wizard_firsttime.bmp')
|
||||
|
||||
# THEN: The wizard should have one page with a pixmap.
|
||||
self.assertEqual(1, len(wizard.pageIds()), 'The wizard should have one page.')
|
||||
self.assertIsInstance(wizard.page(0).pixmap(QtWidgets.QWizard.WatermarkPixmap), QtGui.QPixmap)
|
||||
assert 1 == len(wizard.pageIds()), 'The wizard should have one page.'
|
||||
assert isinstance(wizard.page(0).pixmap(QtWidgets.QWizard.WatermarkPixmap), QtGui.QPixmap)
|
||||
|
||||
def test_create_button_box(self):
|
||||
"""
|
||||
|
@ -63,22 +63,22 @@ class TestUi(TestCase):
|
|||
btnbox = create_button_box(dialog, 'my_btns', ['ok', 'save', 'cancel', 'close', 'defaults'])
|
||||
|
||||
# THEN: We should get a QDialogButtonBox with five buttons
|
||||
self.assertIsInstance(btnbox, QtWidgets.QDialogButtonBox)
|
||||
self.assertEqual(5, len(btnbox.buttons()))
|
||||
assert isinstance(btnbox, QtWidgets.QDialogButtonBox)
|
||||
assert 5 == len(btnbox.buttons())
|
||||
|
||||
# WHEN: We create the button box with a custom button
|
||||
btnbox = create_button_box(dialog, 'my_btns', None, [QtWidgets.QPushButton('Custom')])
|
||||
# THEN: We should get a QDialogButtonBox with one button
|
||||
self.assertIsInstance(btnbox, QtWidgets.QDialogButtonBox)
|
||||
self.assertEqual(1, len(btnbox.buttons()))
|
||||
assert isinstance(btnbox, QtWidgets.QDialogButtonBox)
|
||||
assert 1 == len(btnbox.buttons())
|
||||
|
||||
# WHEN: We create the button box with a custom button and a custom role
|
||||
btnbox = create_button_box(dialog, 'my_btns', None,
|
||||
[(QtWidgets.QPushButton('Help'), QtWidgets.QDialogButtonBox.HelpRole)])
|
||||
# THEN: We should get a QDialogButtonBox with one button with a certain role
|
||||
self.assertIsInstance(btnbox, QtWidgets.QDialogButtonBox)
|
||||
self.assertEqual(1, len(btnbox.buttons()))
|
||||
self.assertEqual(QtWidgets.QDialogButtonBox.HelpRole, btnbox.buttonRole(btnbox.buttons()[0]))
|
||||
assert isinstance(btnbox, QtWidgets.QDialogButtonBox)
|
||||
assert 1 == len(btnbox.buttons())
|
||||
assert QtWidgets.QDialogButtonBox.HelpRole, btnbox.buttonRole(btnbox.buttons()[0])
|
||||
|
||||
def test_create_horizontal_adjusting_combo_box(self):
|
||||
"""
|
||||
|
@ -91,9 +91,9 @@ class TestUi(TestCase):
|
|||
combo = create_horizontal_adjusting_combo_box(dialog, 'combo1')
|
||||
|
||||
# THEN: We should get a ComboBox
|
||||
self.assertIsInstance(combo, QtWidgets.QComboBox)
|
||||
self.assertEqual('combo1', combo.objectName())
|
||||
self.assertEqual(QtWidgets.QComboBox.AdjustToMinimumContentsLength, combo.sizeAdjustPolicy())
|
||||
assert isinstance(combo, QtWidgets.QComboBox)
|
||||
assert 'combo1' == combo.objectName()
|
||||
assert QtWidgets.QComboBox.AdjustToMinimumContentsLength == combo.sizeAdjustPolicy()
|
||||
|
||||
def test_create_button(self):
|
||||
"""
|
||||
|
@ -106,26 +106,26 @@ class TestUi(TestCase):
|
|||
btn = create_button(dialog, 'my_btn')
|
||||
|
||||
# THEN: We should get a button with a name
|
||||
self.assertIsInstance(btn, QtWidgets.QPushButton)
|
||||
self.assertEqual('my_btn', btn.objectName())
|
||||
self.assertTrue(btn.isEnabled())
|
||||
assert isinstance(btn, QtWidgets.QPushButton)
|
||||
assert 'my_btn' == btn.objectName()
|
||||
assert btn.isEnabled() is True
|
||||
|
||||
# WHEN: We create a button with some attributes
|
||||
btn = create_button(dialog, 'my_btn', text='Hello', tooltip='How are you?', enabled=False)
|
||||
|
||||
# THEN: We should get a button with those attributes
|
||||
self.assertIsInstance(btn, QtWidgets.QPushButton)
|
||||
self.assertEqual('Hello', btn.text())
|
||||
self.assertEqual('How are you?', btn.toolTip())
|
||||
self.assertFalse(btn.isEnabled())
|
||||
assert isinstance(btn, QtWidgets.QPushButton)
|
||||
assert 'Hello' == btn.text()
|
||||
assert 'How are you?' == btn.toolTip()
|
||||
assert btn.isEnabled() is False
|
||||
|
||||
# WHEN: We create a toolbutton
|
||||
btn = create_button(dialog, 'my_btn', btn_class='toolbutton')
|
||||
|
||||
# THEN: We should get a toolbutton
|
||||
self.assertIsInstance(btn, QtWidgets.QToolButton)
|
||||
self.assertEqual('my_btn', btn.objectName())
|
||||
self.assertTrue(btn.isEnabled())
|
||||
assert isinstance(btn, QtWidgets.QToolButton)
|
||||
assert 'my_btn' == btn.objectName()
|
||||
assert btn.isEnabled() is True
|
||||
|
||||
def test_create_action(self):
|
||||
"""
|
||||
|
@ -138,19 +138,19 @@ class TestUi(TestCase):
|
|||
action = create_action(dialog, 'my_action')
|
||||
|
||||
# THEN: We should get a QAction
|
||||
self.assertIsInstance(action, QtWidgets.QAction)
|
||||
self.assertEqual('my_action', action.objectName())
|
||||
assert isinstance(action, QtWidgets.QAction)
|
||||
assert 'my_action' == action.objectName()
|
||||
|
||||
# WHEN: We create an action with some properties
|
||||
action = create_action(dialog, 'my_action', text='my text', icon=':/wizards/wizard_firsttime.bmp',
|
||||
tooltip='my tooltip', statustip='my statustip')
|
||||
|
||||
# THEN: These properties should be set
|
||||
self.assertIsInstance(action, QtWidgets.QAction)
|
||||
self.assertEqual('my text', action.text())
|
||||
self.assertIsInstance(action.icon(), QtGui.QIcon)
|
||||
self.assertEqual('my tooltip', action.toolTip())
|
||||
self.assertEqual('my statustip', action.statusTip())
|
||||
assert isinstance(action, QtWidgets.QAction)
|
||||
assert 'my text' == action.text()
|
||||
assert isinstance(action.icon(), QtGui.QIcon)
|
||||
assert 'my tooltip' == action.toolTip()
|
||||
assert 'my statustip' == action.statusTip()
|
||||
|
||||
def test_create_action_on_mac_osx(self):
|
||||
"""
|
||||
|
@ -186,8 +186,8 @@ class TestUi(TestCase):
|
|||
create_action(dialog, 'my_action')
|
||||
|
||||
# THEN: setIconVisibleInMenu should not be called
|
||||
self.assertEqual(0, mocked_action.setIconVisibleInMenu.call_count,
|
||||
'setIconVisibleInMenu should not have been called')
|
||||
assert 0 == mocked_action.setIconVisibleInMenu.call_count, \
|
||||
'setIconVisibleInMenu should not have been called'
|
||||
|
||||
def test_create_checked_disabled_invisible_action(self):
|
||||
"""
|
||||
|
@ -200,9 +200,9 @@ class TestUi(TestCase):
|
|||
action = create_action(dialog, 'my_action', checked=True, enabled=False, visible=False)
|
||||
|
||||
# THEN: These properties should be set
|
||||
self.assertTrue(action.isChecked(), 'The action should be checked')
|
||||
self.assertFalse(action.isEnabled(), 'The action should be disabled')
|
||||
self.assertFalse(action.isVisible(), 'The action should be invisble')
|
||||
assert action.isChecked() is True, 'The action should be checked'
|
||||
assert action.isEnabled() is False, 'The action should be disabled'
|
||||
assert action.isVisible() is False, 'The action should be invisble'
|
||||
|
||||
def test_create_action_separator(self):
|
||||
"""
|
||||
|
@ -215,7 +215,7 @@ class TestUi(TestCase):
|
|||
action = create_action(dialog, 'my_action', separator=True)
|
||||
|
||||
# THEN: The action should be a separator
|
||||
self.assertTrue(action.isSeparator(), 'The action should be a separator')
|
||||
assert action.isSeparator() is True, 'The action should be a separator'
|
||||
|
||||
def test_create_valign_selection_widgets(self):
|
||||
"""
|
||||
|
@ -228,11 +228,11 @@ class TestUi(TestCase):
|
|||
label, combo = create_valign_selection_widgets(dialog)
|
||||
|
||||
# THEN: We should get a label and a combobox.
|
||||
self.assertEqual(translate('OpenLP.Ui', '&Vertical Align:'), label.text())
|
||||
self.assertIsInstance(combo, QtWidgets.QComboBox)
|
||||
self.assertEqual(combo, label.buddy())
|
||||
assert translate('OpenLP.Ui', '&Vertical Align:') == label.text()
|
||||
assert isinstance(combo, QtWidgets.QComboBox)
|
||||
assert combo == label.buddy()
|
||||
for text in [UiStrings().Top, UiStrings().Middle, UiStrings().Bottom]:
|
||||
self.assertTrue(combo.findText(text) >= 0)
|
||||
assert combo.findText(text) >= 0
|
||||
|
||||
def test_find_and_set_in_combo_box(self):
|
||||
"""
|
||||
|
@ -247,19 +247,19 @@ class TestUi(TestCase):
|
|||
find_and_set_in_combo_box(combo, 'Four', set_missing=False)
|
||||
|
||||
# THEN: The index should not have changed
|
||||
self.assertEqual(1, combo.currentIndex())
|
||||
assert 1 == combo.currentIndex()
|
||||
|
||||
# WHEN: We call the method with a non-existing value
|
||||
find_and_set_in_combo_box(combo, 'Four')
|
||||
|
||||
# THEN: The index should have been reset
|
||||
self.assertEqual(0, combo.currentIndex())
|
||||
assert 0 == combo.currentIndex()
|
||||
|
||||
# WHEN: We call the method with the default behavior
|
||||
find_and_set_in_combo_box(combo, 'Three')
|
||||
|
||||
# THEN: The index should have changed
|
||||
self.assertEqual(2, combo.currentIndex())
|
||||
assert 2 == combo.currentIndex()
|
||||
|
||||
def test_create_widget_action(self):
|
||||
"""
|
||||
|
@ -272,8 +272,8 @@ class TestUi(TestCase):
|
|||
action = create_widget_action(button, 'some action')
|
||||
|
||||
# THEN: The action should be returned
|
||||
self.assertIsInstance(action, QtWidgets.QAction)
|
||||
self.assertEqual(action.objectName(), 'some action')
|
||||
assert isinstance(action, QtWidgets.QAction)
|
||||
assert action.objectName() == 'some action'
|
||||
|
||||
def test_set_case_insensitive_completer(self):
|
||||
"""
|
||||
|
@ -288,5 +288,5 @@ class TestUi(TestCase):
|
|||
|
||||
# THEN: The Combobox should have a completer which is case insensitive
|
||||
completer = line_edit.completer()
|
||||
self.assertIsInstance(completer, QtWidgets.QCompleter)
|
||||
self.assertEqual(completer.caseSensitivity(), QtCore.Qt.CaseInsensitive)
|
||||
assert isinstance(completer, QtWidgets.QCompleter)
|
||||
assert completer.caseSensitivity() == QtCore.Qt.CaseInsensitive
|
||||
|
|
|
@ -289,9 +289,9 @@ class TestOpenLP(TestCase):
|
|||
result = self.openlp.event(event)
|
||||
|
||||
# THEN: The path should be inserted.
|
||||
self.assertTrue(result, "The method should have returned True.")
|
||||
assert result is True, "The method should have returned True."
|
||||
mocked_file_method.assert_called_once_with()
|
||||
self.assertEqual(self.openlp.args[0], file_path, "The path should be in args.")
|
||||
assert self.openlp.args[0] == file_path, "The path should be in args."
|
||||
|
||||
@patch('openlp.core.app.is_macosx')
|
||||
def test_application_activate_event(self, mocked_is_macosx):
|
||||
|
@ -309,7 +309,7 @@ class TestOpenLP(TestCase):
|
|||
result = self.openlp.event(event)
|
||||
|
||||
# THEN:
|
||||
self.assertTrue(result, "The method should have returned True.")
|
||||
assert result is True, "The method should have returned True."
|
||||
# self.assertFalse(self.openlp.main_window.isMinimized())
|
||||
|
||||
@patch('openlp.core.app.get_version')
|
||||
|
@ -321,11 +321,11 @@ class TestOpenLP(TestCase):
|
|||
# GIVEN: Mocked data version and OpenLP version which are the same
|
||||
old_install = False
|
||||
MOCKED_VERSION = {
|
||||
'full': '2.2.0-bzr000',
|
||||
'version': '2.2.0',
|
||||
'full': '2.4.0-bzr000',
|
||||
'version': '2.4.0',
|
||||
'build': 'bzr000'
|
||||
}
|
||||
Settings().setValue('core/application version', '2.2.0')
|
||||
Settings().setValue('core/application version', '2.4.0')
|
||||
mocked_get_version.return_value = MOCKED_VERSION
|
||||
mocked_question.return_value = QtWidgets.QMessageBox.No
|
||||
|
||||
|
@ -333,8 +333,8 @@ class TestOpenLP(TestCase):
|
|||
self.openlp.backup_on_upgrade(old_install, False)
|
||||
|
||||
# THEN: It should not ask if we want to create a backup
|
||||
self.assertEqual(Settings().value('core/application version'), '2.2.0', 'Version should be the same!')
|
||||
self.assertEqual(mocked_question.call_count, 0, 'No question should have been asked!')
|
||||
assert Settings().value('core/application version') == '2.4.0', 'Version should be the same!'
|
||||
assert mocked_question.call_count == 0, 'No question should have been asked!'
|
||||
|
||||
@patch('openlp.core.app.get_version')
|
||||
@patch('openlp.core.app.QtWidgets.QMessageBox.question')
|
||||
|
@ -345,8 +345,8 @@ class TestOpenLP(TestCase):
|
|||
# GIVEN: Mocked data version and OpenLP version which are different
|
||||
old_install = True
|
||||
MOCKED_VERSION = {
|
||||
'full': '2.2.0-bzr000',
|
||||
'version': '2.2.0',
|
||||
'full': '2.4.0-bzr000',
|
||||
'version': '2.4.0',
|
||||
'build': 'bzr000'
|
||||
}
|
||||
Settings().setValue('core/application version', '2.0.5')
|
||||
|
@ -359,7 +359,7 @@ class TestOpenLP(TestCase):
|
|||
self.openlp.backup_on_upgrade(old_install, True)
|
||||
|
||||
# THEN: It should ask if we want to create a backup
|
||||
self.assertEqual(Settings().value('core/application version'), '2.2.0', 'Version should be upgraded!')
|
||||
self.assertEqual(mocked_question.call_count, 1, 'A question should have been asked!')
|
||||
assert Settings().value('core/application version') == '2.4.0', 'Version should be upgraded!'
|
||||
assert mocked_question.call_count == 1, 'A question should have been asked!'
|
||||
self.openlp.splash.hide.assert_called_once_with()
|
||||
self.openlp.splash.show.assert_called_once_with()
|
||||
|
|
|
@ -54,10 +54,10 @@ class TestMediaController(TestCase, TestMixin):
|
|||
media_controller._generate_extensions_lists()
|
||||
|
||||
# THEN: extensions list should have been copied from the player to the mediacontroller
|
||||
self.assertListEqual(media_player.video_extensions_list, media_controller.video_extensions_list,
|
||||
'Video extensions should be the same')
|
||||
self.assertListEqual(media_player.audio_extensions_list, media_controller.audio_extensions_list,
|
||||
'Audio extensions should be the same')
|
||||
assert media_player.video_extensions_list == media_controller.video_extensions_list, \
|
||||
'Video extensions should be the same'
|
||||
assert media_player.audio_extensions_list == media_controller.audio_extensions_list, \
|
||||
'Audio extensions should be the same'
|
||||
|
||||
def test_resize(self):
|
||||
"""
|
||||
|
@ -96,7 +96,7 @@ class TestMediaController(TestCase, TestMixin):
|
|||
ret = media_controller._check_file_type(mocked_controller, mocked_display, mocked_service_item)
|
||||
|
||||
# THEN: it should return False
|
||||
self.assertFalse(ret, '_check_file_type should return False when no mediaplayers are available.')
|
||||
assert ret is False, '_check_file_type should return False when no mediaplayers are available.'
|
||||
|
||||
@patch('openlp.core.ui.media.mediacontroller.MediaController._get_used_players')
|
||||
@patch('openlp.core.ui.media.mediacontroller.UiStrings')
|
||||
|
@ -119,7 +119,7 @@ class TestMediaController(TestCase, TestMixin):
|
|||
ret = media_controller._check_file_type(mocked_controller, mocked_display, mocked_service_item)
|
||||
|
||||
# THEN: it should return False
|
||||
self.assertFalse(ret, '_check_file_type should return False when the processor for service_item is None.')
|
||||
assert ret is False, '_check_file_type should return False when the processor for service_item is None.'
|
||||
|
||||
@patch('openlp.core.ui.media.mediacontroller.MediaController._get_used_players')
|
||||
@patch('openlp.core.ui.media.mediacontroller.UiStrings')
|
||||
|
@ -148,8 +148,8 @@ class TestMediaController(TestCase, TestMixin):
|
|||
ret = media_controller._check_file_type(mocked_controller, mocked_display, mocked_service_item)
|
||||
|
||||
# THEN: it should return True
|
||||
self.assertTrue(ret, '_check_file_type should return True when mediaplayers are available and '
|
||||
'the service item has an automatic processor.')
|
||||
assert ret is True, '_check_file_type should return True when mediaplayers are available and ' \
|
||||
'the service item has an automatic processor.'
|
||||
|
||||
@patch('openlp.core.ui.media.mediacontroller.MediaController._get_used_players')
|
||||
@patch('openlp.core.ui.media.mediacontroller.UiStrings')
|
||||
|
@ -178,8 +178,8 @@ class TestMediaController(TestCase, TestMixin):
|
|||
ret = media_controller._check_file_type(mocked_controller, mocked_display, mocked_service_item)
|
||||
|
||||
# THEN: it should return True
|
||||
self.assertTrue(ret, '_check_file_type should return True when the players available are different'
|
||||
'from the processor from the service item.')
|
||||
assert ret is True, '_check_file_type should return True when the players available are different' \
|
||||
'from the processor from the service item.'
|
||||
|
||||
def test_media_play_msg(self):
|
||||
"""
|
||||
|
|
|
@ -1,533 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2017 OpenLP Developers #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# This program is free software; you can redistribute it and/or modify it #
|
||||
# under the terms of the GNU General Public License as published by the Free #
|
||||
# Software Foundation; version 2 of the License. #
|
||||
# #
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
||||
# more details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU General Public License along #
|
||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
"""
|
||||
Package to test the openlp.core.ui.media.systemplayer package.
|
||||
"""
|
||||
from unittest import TestCase
|
||||
from unittest.mock import MagicMock, call, patch
|
||||
|
||||
from PyQt5 import QtCore, QtMultimedia
|
||||
|
||||
from openlp.core.common.registry import Registry
|
||||
from openlp.core.ui.media import MediaState
|
||||
from openlp.core.ui.media.systemplayer import SystemPlayer, CheckMediaWorker, ADDITIONAL_EXT
|
||||
|
||||
|
||||
class TestSystemPlayer(TestCase):
|
||||
"""
|
||||
Test the system media player
|
||||
"""
|
||||
@patch('openlp.core.ui.media.systemplayer.mimetypes')
|
||||
@patch('openlp.core.ui.media.systemplayer.QtMultimedia.QMediaPlayer')
|
||||
def test_constructor(self, MockQMediaPlayer, mocked_mimetypes):
|
||||
"""
|
||||
Test the SystemPlayer constructor
|
||||
"""
|
||||
# GIVEN: The SystemPlayer class and a mockedQMediaPlayer
|
||||
mocked_media_player = MagicMock()
|
||||
mocked_media_player.supportedMimeTypes.return_value = [
|
||||
'application/postscript',
|
||||
'audio/aiff',
|
||||
'audio/x-aiff',
|
||||
'text/html',
|
||||
'video/animaflex',
|
||||
'video/x-ms-asf'
|
||||
]
|
||||
mocked_mimetypes.guess_all_extensions.side_effect = [
|
||||
['.aiff'],
|
||||
['.aiff'],
|
||||
['.afl'],
|
||||
['.asf']
|
||||
]
|
||||
MockQMediaPlayer.return_value = mocked_media_player
|
||||
|
||||
# WHEN: An object is created from it
|
||||
player = SystemPlayer(self)
|
||||
|
||||
# THEN: The correct initial values should be set up
|
||||
self.assertEqual('system', player.name)
|
||||
self.assertEqual('System', player.original_name)
|
||||
self.assertEqual('&System', player.display_name)
|
||||
self.assertEqual(self, player.parent)
|
||||
self.assertEqual(ADDITIONAL_EXT, player.additional_extensions)
|
||||
MockQMediaPlayer.assert_called_once_with(None, QtMultimedia.QMediaPlayer.VideoSurface)
|
||||
mocked_mimetypes.init.assert_called_once_with()
|
||||
mocked_media_player.service.assert_called_once_with()
|
||||
mocked_media_player.supportedMimeTypes.assert_called_once_with()
|
||||
self.assertEqual(['*.aiff'], player.audio_extensions_list)
|
||||
self.assertEqual(['*.afl', '*.asf'], player.video_extensions_list)
|
||||
|
||||
@patch('openlp.core.ui.media.systemplayer.QtMultimediaWidgets.QVideoWidget')
|
||||
@patch('openlp.core.ui.media.systemplayer.QtMultimedia.QMediaPlayer')
|
||||
def test_setup(self, MockQMediaPlayer, MockQVideoWidget):
|
||||
"""
|
||||
Test the setup() method of SystemPlayer
|
||||
"""
|
||||
# GIVEN: A SystemPlayer instance and a mock display
|
||||
player = SystemPlayer(self)
|
||||
mocked_display = MagicMock()
|
||||
mocked_display.size.return_value = [1, 2, 3, 4]
|
||||
mocked_video_widget = MagicMock()
|
||||
mocked_media_player = MagicMock()
|
||||
MockQVideoWidget.return_value = mocked_video_widget
|
||||
MockQMediaPlayer.return_value = mocked_media_player
|
||||
|
||||
# WHEN: setup() is run
|
||||
player.setup(mocked_display)
|
||||
|
||||
# THEN: The player should have a display widget
|
||||
MockQVideoWidget.assert_called_once_with(mocked_display)
|
||||
self.assertEqual(mocked_video_widget, mocked_display.video_widget)
|
||||
mocked_display.size.assert_called_once_with()
|
||||
mocked_video_widget.resize.assert_called_once_with([1, 2, 3, 4])
|
||||
MockQMediaPlayer.assert_called_with(mocked_display)
|
||||
self.assertEqual(mocked_media_player, mocked_display.media_player)
|
||||
mocked_media_player.setVideoOutput.assert_called_once_with(mocked_video_widget)
|
||||
mocked_video_widget.raise_.assert_called_once_with()
|
||||
mocked_video_widget.hide.assert_called_once_with()
|
||||
self.assertTrue(player.has_own_widget)
|
||||
|
||||
def test_disconnect_slots(self):
|
||||
"""
|
||||
Test that we the disconnect slots method catches the TypeError
|
||||
"""
|
||||
# GIVEN: A SystemPlayer class and a signal that throws a TypeError
|
||||
player = SystemPlayer(self)
|
||||
mocked_signal = MagicMock()
|
||||
mocked_signal.disconnect.side_effect = \
|
||||
TypeError('disconnect() failed between \'durationChanged\' and all its connections')
|
||||
|
||||
# WHEN: disconnect_slots() is called
|
||||
player.disconnect_slots(mocked_signal)
|
||||
|
||||
# THEN: disconnect should have been called and the exception should have been ignored
|
||||
mocked_signal.disconnect.assert_called_once_with()
|
||||
|
||||
def test_check_available(self):
|
||||
"""
|
||||
Test the check_available() method on SystemPlayer
|
||||
"""
|
||||
# GIVEN: A SystemPlayer instance
|
||||
player = SystemPlayer(self)
|
||||
|
||||
# WHEN: check_available is run
|
||||
result = player.check_available()
|
||||
|
||||
# THEN: it should be available
|
||||
self.assertTrue(result)
|
||||
|
||||
def test_load_valid_media(self):
|
||||
"""
|
||||
Test the load() method of SystemPlayer with a valid media file
|
||||
"""
|
||||
# GIVEN: A SystemPlayer instance and a mocked display
|
||||
player = SystemPlayer(self)
|
||||
mocked_display = MagicMock()
|
||||
mocked_display.controller.media_info.volume = 1
|
||||
mocked_display.controller.media_info.file_info.absoluteFilePath.return_value = '/path/to/file'
|
||||
|
||||
# WHEN: The load() method is run
|
||||
with patch.object(player, 'check_media') as mocked_check_media, \
|
||||
patch.object(player, 'volume') as mocked_volume:
|
||||
mocked_check_media.return_value = True
|
||||
result = player.load(mocked_display)
|
||||
|
||||
# THEN: the file is sent to the video widget
|
||||
mocked_display.controller.media_info.file_info.absoluteFilePath.assert_called_once_with()
|
||||
mocked_check_media.assert_called_once_with('/path/to/file')
|
||||
mocked_display.media_player.setMedia.assert_called_once_with(
|
||||
QtMultimedia.QMediaContent(QtCore.QUrl.fromLocalFile('/path/to/file')))
|
||||
mocked_volume.assert_called_once_with(mocked_display, 1)
|
||||
self.assertTrue(result)
|
||||
|
||||
def test_load_invalid_media(self):
|
||||
"""
|
||||
Test the load() method of SystemPlayer with an invalid media file
|
||||
"""
|
||||
# GIVEN: A SystemPlayer instance and a mocked display
|
||||
player = SystemPlayer(self)
|
||||
mocked_display = MagicMock()
|
||||
mocked_display.controller.media_info.volume = 1
|
||||
mocked_display.controller.media_info.file_info.absoluteFilePath.return_value = '/path/to/file'
|
||||
|
||||
# WHEN: The load() method is run
|
||||
with patch.object(player, 'check_media') as mocked_check_media, \
|
||||
patch.object(player, 'volume') as mocked_volume:
|
||||
mocked_check_media.return_value = False
|
||||
result = player.load(mocked_display)
|
||||
|
||||
# THEN: stuff
|
||||
mocked_display.controller.media_info.file_info.absoluteFilePath.assert_called_once_with()
|
||||
mocked_check_media.assert_called_once_with('/path/to/file')
|
||||
self.assertFalse(result)
|
||||
|
||||
def test_resize(self):
|
||||
"""
|
||||
Test the resize() method of the SystemPlayer
|
||||
"""
|
||||
# GIVEN: A SystemPlayer instance and a mocked display
|
||||
player = SystemPlayer(self)
|
||||
mocked_display = MagicMock()
|
||||
mocked_display.size.return_value = [1, 2, 3, 4]
|
||||
|
||||
# WHEN: The resize() method is called
|
||||
player.resize(mocked_display)
|
||||
|
||||
# THEN: The player is resized
|
||||
mocked_display.size.assert_called_once_with()
|
||||
mocked_display.video_widget.resize.assert_called_once_with([1, 2, 3, 4])
|
||||
|
||||
@patch('openlp.core.ui.media.systemplayer.functools')
|
||||
def test_play_is_live(self, mocked_functools):
|
||||
"""
|
||||
Test the play() method of the SystemPlayer on the live display
|
||||
"""
|
||||
# GIVEN: A SystemPlayer instance and a mocked display
|
||||
mocked_functools.partial.return_value = 'function'
|
||||
player = SystemPlayer(self)
|
||||
mocked_display = MagicMock()
|
||||
mocked_display.controller.is_live = True
|
||||
mocked_display.controller.media_info.start_time = 1
|
||||
mocked_display.controller.media_info.volume = 1
|
||||
|
||||
# WHEN: play() is called
|
||||
with patch.object(player, 'get_live_state') as mocked_get_live_state, \
|
||||
patch.object(player, 'seek') as mocked_seek, \
|
||||
patch.object(player, 'volume') as mocked_volume, \
|
||||
patch.object(player, 'set_state') as mocked_set_state, \
|
||||
patch.object(player, 'disconnect_slots') as mocked_disconnect_slots:
|
||||
mocked_get_live_state.return_value = QtMultimedia.QMediaPlayer.PlayingState
|
||||
result = player.play(mocked_display)
|
||||
|
||||
# THEN: the media file is played
|
||||
mocked_get_live_state.assert_called_once_with()
|
||||
mocked_display.media_player.play.assert_called_once_with()
|
||||
mocked_seek.assert_called_once_with(mocked_display, 1000)
|
||||
mocked_volume.assert_called_once_with(mocked_display, 1)
|
||||
mocked_disconnect_slots.assert_called_once_with(mocked_display.media_player.durationChanged)
|
||||
mocked_display.media_player.durationChanged.connect.assert_called_once_with('function')
|
||||
mocked_set_state.assert_called_once_with(MediaState.Playing, mocked_display)
|
||||
mocked_display.video_widget.raise_.assert_called_once_with()
|
||||
self.assertTrue(result)
|
||||
|
||||
@patch('openlp.core.ui.media.systemplayer.functools')
|
||||
def test_play_is_preview(self, mocked_functools):
|
||||
"""
|
||||
Test the play() method of the SystemPlayer on the preview display
|
||||
"""
|
||||
# GIVEN: A SystemPlayer instance and a mocked display
|
||||
mocked_functools.partial.return_value = 'function'
|
||||
player = SystemPlayer(self)
|
||||
mocked_display = MagicMock()
|
||||
mocked_display.controller.is_live = False
|
||||
mocked_display.controller.media_info.start_time = 1
|
||||
mocked_display.controller.media_info.volume = 1
|
||||
|
||||
# WHEN: play() is called
|
||||
with patch.object(player, 'get_preview_state') as mocked_get_preview_state, \
|
||||
patch.object(player, 'seek') as mocked_seek, \
|
||||
patch.object(player, 'volume') as mocked_volume, \
|
||||
patch.object(player, 'set_state') as mocked_set_state:
|
||||
mocked_get_preview_state.return_value = QtMultimedia.QMediaPlayer.PlayingState
|
||||
result = player.play(mocked_display)
|
||||
|
||||
# THEN: the media file is played
|
||||
mocked_get_preview_state.assert_called_once_with()
|
||||
mocked_display.media_player.play.assert_called_once_with()
|
||||
mocked_seek.assert_called_once_with(mocked_display, 1000)
|
||||
mocked_volume.assert_called_once_with(mocked_display, 1)
|
||||
mocked_display.media_player.durationChanged.connect.assert_called_once_with('function')
|
||||
mocked_set_state.assert_called_once_with(MediaState.Playing, mocked_display)
|
||||
mocked_display.video_widget.raise_.assert_called_once_with()
|
||||
self.assertTrue(result)
|
||||
|
||||
def test_pause_is_live(self):
|
||||
"""
|
||||
Test the pause() method of the SystemPlayer on the live display
|
||||
"""
|
||||
# GIVEN: A SystemPlayer instance
|
||||
player = SystemPlayer(self)
|
||||
mocked_display = MagicMock()
|
||||
mocked_display.controller.is_live = True
|
||||
|
||||
# WHEN: The pause method is called
|
||||
with patch.object(player, 'get_live_state') as mocked_get_live_state, \
|
||||
patch.object(player, 'set_state') as mocked_set_state:
|
||||
mocked_get_live_state.return_value = QtMultimedia.QMediaPlayer.PausedState
|
||||
player.pause(mocked_display)
|
||||
|
||||
# THEN: The video is paused
|
||||
mocked_display.media_player.pause.assert_called_once_with()
|
||||
mocked_get_live_state.assert_called_once_with()
|
||||
mocked_set_state.assert_called_once_with(MediaState.Paused, mocked_display)
|
||||
|
||||
def test_pause_is_preview(self):
|
||||
"""
|
||||
Test the pause() method of the SystemPlayer on the preview display
|
||||
"""
|
||||
# GIVEN: A SystemPlayer instance
|
||||
player = SystemPlayer(self)
|
||||
mocked_display = MagicMock()
|
||||
mocked_display.controller.is_live = False
|
||||
|
||||
# WHEN: The pause method is called
|
||||
with patch.object(player, 'get_preview_state') as mocked_get_preview_state, \
|
||||
patch.object(player, 'set_state') as mocked_set_state:
|
||||
mocked_get_preview_state.return_value = QtMultimedia.QMediaPlayer.PausedState
|
||||
player.pause(mocked_display)
|
||||
|
||||
# THEN: The video is paused
|
||||
mocked_display.media_player.pause.assert_called_once_with()
|
||||
mocked_get_preview_state.assert_called_once_with()
|
||||
mocked_set_state.assert_called_once_with(MediaState.Paused, mocked_display)
|
||||
|
||||
def test_stop(self):
|
||||
"""
|
||||
Test the stop() method of the SystemPlayer
|
||||
"""
|
||||
# GIVEN: A SystemPlayer instance
|
||||
player = SystemPlayer(self)
|
||||
mocked_display = MagicMock()
|
||||
|
||||
# WHEN: The stop method is called
|
||||
with patch.object(player, 'set_visible') as mocked_set_visible, \
|
||||
patch.object(player, 'set_state') as mocked_set_state:
|
||||
player.stop(mocked_display)
|
||||
|
||||
# THEN: The video is stopped
|
||||
mocked_display.media_player.stop.assert_called_once_with()
|
||||
mocked_set_visible.assert_called_once_with(mocked_display, False)
|
||||
mocked_set_state.assert_called_once_with(MediaState.Stopped, mocked_display)
|
||||
|
||||
def test_volume(self):
|
||||
"""
|
||||
Test the volume() method of the SystemPlayer
|
||||
"""
|
||||
# GIVEN: A SystemPlayer instance
|
||||
player = SystemPlayer(self)
|
||||
mocked_display = MagicMock()
|
||||
mocked_display.has_audio = True
|
||||
|
||||
# WHEN: The stop method is called
|
||||
player.volume(mocked_display, 2)
|
||||
|
||||
# THEN: The video is stopped
|
||||
mocked_display.media_player.setVolume.assert_called_once_with(2)
|
||||
|
||||
def test_seek(self):
|
||||
"""
|
||||
Test the seek() method of the SystemPlayer
|
||||
"""
|
||||
# GIVEN: A SystemPlayer instance
|
||||
player = SystemPlayer(self)
|
||||
mocked_display = MagicMock()
|
||||
|
||||
# WHEN: The stop method is called
|
||||
player.seek(mocked_display, 2)
|
||||
|
||||
# THEN: The video is stopped
|
||||
mocked_display.media_player.setPosition.assert_called_once_with(2)
|
||||
|
||||
def test_reset(self):
|
||||
"""
|
||||
Test the reset() method of the SystemPlayer
|
||||
"""
|
||||
# GIVEN: A SystemPlayer instance
|
||||
player = SystemPlayer(self)
|
||||
mocked_display = MagicMock()
|
||||
|
||||
# WHEN: reset() is called
|
||||
with patch.object(player, 'set_state') as mocked_set_state, \
|
||||
patch.object(player, 'set_visible') as mocked_set_visible:
|
||||
player.reset(mocked_display)
|
||||
|
||||
# THEN: The media player is reset
|
||||
mocked_display.media_player.stop()
|
||||
mocked_display.media_player.setMedia.assert_called_once_with(QtMultimedia.QMediaContent())
|
||||
mocked_set_visible.assert_called_once_with(mocked_display, False)
|
||||
mocked_display.video_widget.setVisible.assert_called_once_with(False)
|
||||
mocked_set_state.assert_called_once_with(MediaState.Off, mocked_display)
|
||||
|
||||
def test_set_visible(self):
|
||||
"""
|
||||
Test the set_visible() method on the SystemPlayer
|
||||
"""
|
||||
# GIVEN: A SystemPlayer instance and a mocked display
|
||||
player = SystemPlayer(self)
|
||||
player.has_own_widget = True
|
||||
mocked_display = MagicMock()
|
||||
|
||||
# WHEN: set_visible() is called
|
||||
player.set_visible(mocked_display, True)
|
||||
|
||||
# THEN: The widget should be visible
|
||||
mocked_display.video_widget.setVisible.assert_called_once_with(True)
|
||||
|
||||
def test_set_duration(self):
|
||||
"""
|
||||
Test the set_duration() method of the SystemPlayer
|
||||
"""
|
||||
# GIVEN: a mocked controller
|
||||
mocked_controller = MagicMock()
|
||||
mocked_controller.media_info.length = 5
|
||||
|
||||
# WHEN: The set_duration() is called. NB: the 10 here is ignored by the code
|
||||
SystemPlayer.set_duration(mocked_controller, 10)
|
||||
|
||||
# THEN: The maximum length of the slider should be set
|
||||
mocked_controller.seek_slider.setMaximum.assert_called_once_with(5)
|
||||
|
||||
def test_update_ui(self):
|
||||
"""
|
||||
Test the update_ui() method on the SystemPlayer
|
||||
"""
|
||||
# GIVEN: A SystemPlayer instance
|
||||
player = SystemPlayer(self)
|
||||
player.state = [MediaState.Playing, MediaState.Playing]
|
||||
mocked_display = MagicMock()
|
||||
mocked_display.media_player.state.return_value = QtMultimedia.QMediaPlayer.PausedState
|
||||
mocked_display.controller.media_info.end_time = 1
|
||||
mocked_display.media_player.position.return_value = 2
|
||||
mocked_display.controller.seek_slider.isSliderDown.return_value = False
|
||||
|
||||
# WHEN: update_ui() is called
|
||||
with patch.object(player, 'stop') as mocked_stop, \
|
||||
patch.object(player, 'set_visible') as mocked_set_visible:
|
||||
player.update_ui(mocked_display)
|
||||
|
||||
# THEN: The UI is updated
|
||||
expected_stop_calls = [call(mocked_display)]
|
||||
expected_position_calls = [call(), call()]
|
||||
expected_block_signals_calls = [call(True), call(False)]
|
||||
mocked_display.media_player.state.assert_called_once_with()
|
||||
self.assertEqual(1, mocked_stop.call_count)
|
||||
self.assertEqual(expected_stop_calls, mocked_stop.call_args_list)
|
||||
self.assertEqual(2, mocked_display.media_player.position.call_count)
|
||||
self.assertEqual(expected_position_calls, mocked_display.media_player.position.call_args_list)
|
||||
mocked_set_visible.assert_called_once_with(mocked_display, False)
|
||||
mocked_display.controller.seek_slider.isSliderDown.assert_called_once_with()
|
||||
self.assertEqual(expected_block_signals_calls,
|
||||
mocked_display.controller.seek_slider.blockSignals.call_args_list)
|
||||
mocked_display.controller.seek_slider.setSliderPosition.assert_called_once_with(2)
|
||||
|
||||
def test_get_media_display_css(self):
|
||||
"""
|
||||
Test the get_media_display_css() method of the SystemPlayer
|
||||
"""
|
||||
# GIVEN: A SystemPlayer instance
|
||||
player = SystemPlayer(self)
|
||||
|
||||
# WHEN: get_media_display_css() is called
|
||||
result = player.get_media_display_css()
|
||||
|
||||
# THEN: The css should be empty
|
||||
self.assertEqual('', result)
|
||||
|
||||
@patch('openlp.core.ui.media.systemplayer.QtMultimedia.QMediaPlayer')
|
||||
def test_get_info(self, MockQMediaPlayer):
|
||||
"""
|
||||
Test the get_info() method of the SystemPlayer
|
||||
"""
|
||||
# GIVEN: A SystemPlayer instance
|
||||
mocked_media_player = MagicMock()
|
||||
mocked_media_player.supportedMimeTypes.return_value = []
|
||||
MockQMediaPlayer.return_value = mocked_media_player
|
||||
player = SystemPlayer(self)
|
||||
|
||||
# WHEN: get_info() is called
|
||||
result = player.get_info()
|
||||
|
||||
# THEN: The info should be correct
|
||||
expected_info = 'This media player uses your operating system to provide media capabilities.<br/> ' \
|
||||
'<strong>Audio</strong><br/>[]<br/><strong>Video</strong><br/>[]<br/>'
|
||||
self.assertEqual(expected_info, result)
|
||||
|
||||
@patch('openlp.core.ui.media.systemplayer.CheckMediaWorker')
|
||||
@patch('openlp.core.ui.media.systemplayer.run_thread')
|
||||
def test_check_media(self, mocked_run_thread, MockCheckMediaWorker):
|
||||
"""
|
||||
Test the check_media() method of the SystemPlayer
|
||||
"""
|
||||
# GIVEN: A SystemPlayer instance and a mocked thread
|
||||
valid_file = '/path/to/video.ogv'
|
||||
mocked_application = MagicMock()
|
||||
Registry().create()
|
||||
Registry().register('application', mocked_application)
|
||||
player = SystemPlayer(self)
|
||||
|
||||
# WHEN: check_media() is called with a valid media file
|
||||
player.check_media(valid_file)
|
||||
|
||||
# THEN: It should return True
|
||||
assert False, 'Fix this test'
|
||||
|
||||
|
||||
class TestCheckMediaWorker(TestCase):
|
||||
"""
|
||||
Test the CheckMediaWorker class
|
||||
"""
|
||||
def test_constructor(self):
|
||||
"""
|
||||
Test the constructor of the CheckMediaWorker class
|
||||
"""
|
||||
# GIVEN: A file path
|
||||
path = 'file.ogv'
|
||||
|
||||
# WHEN: The CheckMediaWorker object is instantiated
|
||||
worker = CheckMediaWorker(path)
|
||||
|
||||
# THEN: The correct values should be set up
|
||||
self.assertIsNotNone(worker)
|
||||
|
||||
def test_signals_media(self):
|
||||
"""
|
||||
Test the signals() signal of the CheckMediaWorker class with a "media" origin
|
||||
"""
|
||||
# GIVEN: A CheckMediaWorker instance
|
||||
worker = CheckMediaWorker('file.ogv')
|
||||
|
||||
# WHEN: signals() is called with media and BufferedMedia
|
||||
with patch.object(worker, 'stop') as mocked_stop, \
|
||||
patch.object(worker, 'quit') as mocked_quit:
|
||||
worker.signals('media', worker.BufferedMedia)
|
||||
|
||||
# THEN: The worker should exit and the result should be True
|
||||
mocked_stop.assert_called_once_with()
|
||||
mocked_quit.emit.assert_called_once_with()
|
||||
self.assertTrue(worker.result)
|
||||
|
||||
def test_signals_error(self):
|
||||
"""
|
||||
Test the signals() signal of the CheckMediaWorker class with a "error" origin
|
||||
"""
|
||||
# GIVEN: A CheckMediaWorker instance
|
||||
worker = CheckMediaWorker('file.ogv')
|
||||
|
||||
# WHEN: signals() is called with error and BufferedMedia
|
||||
with patch.object(worker, 'stop') as mocked_stop, \
|
||||
patch.object(worker, 'quit') as mocked_quit:
|
||||
worker.signals('error', None)
|
||||
|
||||
# THEN: The worker should exit and the result should be True
|
||||
mocked_stop.assert_called_once_with()
|
||||
mocked_quit.emit.assert_called_once_with()
|
||||
self.assertFalse(worker.result)
|
|
@ -24,7 +24,7 @@ Package to test the openlp.core.ui.media.vlcplayer package.
|
|||
"""
|
||||
import os
|
||||
import sys
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import timedelta
|
||||
from unittest import TestCase, skip
|
||||
from unittest.mock import MagicMock, patch, call
|
||||
|
||||
|
@ -64,7 +64,7 @@ class TestVLCPlayer(TestCase, TestMixin):
|
|||
get_vlc()
|
||||
|
||||
# THEN: The extra environment variable should be there
|
||||
self.assertNotIn('openlp.core.ui.media.vendor.vlc', sys.modules)
|
||||
assert 'openlp.core.ui.media.vendor.vlc' not in sys.modules
|
||||
|
||||
@patch('openlp.core.ui.media.vlcplayer.is_macosx')
|
||||
def test_fix_vlc_22_plugin_path(self, mocked_is_macosx):
|
||||
|
@ -78,9 +78,8 @@ class TestVLCPlayer(TestCase, TestMixin):
|
|||
get_vlc()
|
||||
|
||||
# THEN: The extra environment variable should be there
|
||||
self.assertIn('VLC_PLUGIN_PATH', os.environ,
|
||||
'The plugin path should be in the environment variables')
|
||||
self.assertEqual('/Applications/VLC.app/Contents/MacOS/plugins', os.environ['VLC_PLUGIN_PATH'])
|
||||
assert 'VLC_PLUGIN_PATH' in os.environ, 'The plugin path should be in the environment variables'
|
||||
assert '/Applications/VLC.app/Contents/MacOS/plugins' == os.environ['VLC_PLUGIN_PATH']
|
||||
|
||||
@patch.dict(os.environ)
|
||||
@patch('openlp.core.ui.media.vlcplayer.is_macosx')
|
||||
|
@ -95,8 +94,7 @@ class TestVLCPlayer(TestCase, TestMixin):
|
|||
get_vlc()
|
||||
|
||||
# THEN: The extra environment variable should NOT be there
|
||||
self.assertNotIn('VLC_PLUGIN_PATH', os.environ,
|
||||
'The plugin path should NOT be in the environment variables')
|
||||
assert 'VLC_PLUGIN_PATH' not in os.environ, 'The plugin path should NOT be in the environment variables'
|
||||
|
||||
def test_init(self):
|
||||
"""
|
||||
|
@ -109,12 +107,12 @@ class TestVLCPlayer(TestCase, TestMixin):
|
|||
vlc_player = VlcPlayer(None)
|
||||
|
||||
# THEN: The correct variables are set
|
||||
self.assertEqual('VLC', vlc_player.original_name)
|
||||
self.assertEqual('&VLC', vlc_player.display_name)
|
||||
self.assertIsNone(vlc_player.parent)
|
||||
self.assertTrue(vlc_player.can_folder)
|
||||
self.assertListEqual(AUDIO_EXT, vlc_player.audio_extensions_list)
|
||||
self.assertListEqual(VIDEO_EXT, vlc_player.video_extensions_list)
|
||||
assert 'VLC' == vlc_player.original_name
|
||||
assert '&VLC' == vlc_player.display_name
|
||||
assert vlc_player.parent is None
|
||||
assert vlc_player.can_folder is True
|
||||
assert AUDIO_EXT == vlc_player.audio_extensions_list
|
||||
assert VIDEO_EXT == vlc_player.video_extensions_list
|
||||
|
||||
@patch('openlp.core.ui.media.vlcplayer.is_win')
|
||||
@patch('openlp.core.ui.media.vlcplayer.is_macosx')
|
||||
|
@ -151,20 +149,20 @@ class TestVLCPlayer(TestCase, TestMixin):
|
|||
vlc_player.setup(mocked_display)
|
||||
|
||||
# THEN: The VLC widget should be set up correctly
|
||||
self.assertEqual(mocked_display.vlc_widget, mocked_qframe)
|
||||
assert mocked_display.vlc_widget == mocked_qframe
|
||||
mocked_qframe.setFrameStyle.assert_called_with(1)
|
||||
mocked_settings.value.assert_called_with('advanced/hide mouse')
|
||||
mocked_vlc.Instance.assert_called_with('--no-video-title-show --no-audio --no-video-title-show '
|
||||
'--mouse-hide-timeout=0')
|
||||
self.assertEqual(mocked_display.vlc_instance, mocked_instance)
|
||||
assert mocked_display.vlc_instance == mocked_instance
|
||||
mocked_instance.media_player_new.assert_called_with()
|
||||
self.assertEqual(mocked_display.vlc_media_player, mocked_media_player_new)
|
||||
assert mocked_display.vlc_media_player == mocked_media_player_new
|
||||
mocked_display.size.assert_called_with()
|
||||
mocked_qframe.resize.assert_called_with((10, 10))
|
||||
mocked_qframe.raise_.assert_called_with()
|
||||
mocked_qframe.hide.assert_called_with()
|
||||
mocked_media_player_new.set_xwindow.assert_called_with(2)
|
||||
self.assertTrue(vlc_player.has_own_widget)
|
||||
assert vlc_player.has_own_widget is True
|
||||
|
||||
@patch('openlp.core.ui.media.vlcplayer.is_win')
|
||||
@patch('openlp.core.ui.media.vlcplayer.is_macosx')
|
||||
|
@ -328,7 +326,7 @@ class TestVLCPlayer(TestCase, TestMixin):
|
|||
is_available = vlc_player.check_available()
|
||||
|
||||
# THEN: VLC should be available
|
||||
self.assertTrue(is_available)
|
||||
assert is_available is True
|
||||
|
||||
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
|
||||
def test_check_not_available(self, mocked_get_vlc):
|
||||
|
@ -343,7 +341,7 @@ class TestVLCPlayer(TestCase, TestMixin):
|
|||
is_available = vlc_player.check_available()
|
||||
|
||||
# THEN: VLC should NOT be available
|
||||
self.assertFalse(is_available)
|
||||
assert is_available is False
|
||||
|
||||
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
|
||||
@patch('openlp.core.ui.media.vlcplayer.os.path.normcase')
|
||||
|
@ -376,11 +374,11 @@ class TestVLCPlayer(TestCase, TestMixin):
|
|||
# THEN: The video should be loaded
|
||||
mocked_normcase.assert_called_with(media_path)
|
||||
mocked_display.vlc_instance.media_new_path.assert_called_with(media_path)
|
||||
self.assertEqual(mocked_vlc_media, mocked_display.vlc_media)
|
||||
assert mocked_vlc_media == mocked_display.vlc_media
|
||||
mocked_display.vlc_media_player.set_media.assert_called_with(mocked_vlc_media)
|
||||
mocked_vlc_media.parse.assert_called_with()
|
||||
mocked_volume.assert_called_with(mocked_display, 100)
|
||||
self.assertTrue(result)
|
||||
assert result is True
|
||||
|
||||
@patch('openlp.core.ui.media.vlcplayer.is_win')
|
||||
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
|
||||
|
@ -421,11 +419,11 @@ class TestVLCPlayer(TestCase, TestMixin):
|
|||
# THEN: The video should be loaded
|
||||
mocked_normcase.assert_called_with(media_path)
|
||||
mocked_display.vlc_instance.media_new_location.assert_called_with('cdda://' + media_path)
|
||||
self.assertEqual(mocked_vlc_media, mocked_display.vlc_media)
|
||||
assert mocked_vlc_media == mocked_display.vlc_media
|
||||
mocked_display.vlc_media_player.set_media.assert_called_with(mocked_vlc_media)
|
||||
mocked_vlc_media.parse.assert_called_with()
|
||||
mocked_volume.assert_called_with(mocked_display, 100)
|
||||
self.assertTrue(result)
|
||||
assert result is True
|
||||
|
||||
@patch('openlp.core.ui.media.vlcplayer.is_win')
|
||||
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
|
||||
|
@ -466,11 +464,11 @@ class TestVLCPlayer(TestCase, TestMixin):
|
|||
# THEN: The video should be loaded
|
||||
mocked_normcase.assert_called_with(media_path)
|
||||
mocked_display.vlc_instance.media_new_location.assert_called_with('cdda:///' + media_path)
|
||||
self.assertEqual(mocked_vlc_media, mocked_display.vlc_media)
|
||||
assert mocked_vlc_media == mocked_display.vlc_media
|
||||
mocked_display.vlc_media_player.set_media.assert_called_with(mocked_vlc_media)
|
||||
mocked_vlc_media.parse.assert_called_with()
|
||||
mocked_volume.assert_called_with(mocked_display, 100)
|
||||
self.assertTrue(result)
|
||||
assert result is True
|
||||
|
||||
@patch('openlp.core.ui.media.vlcplayer.is_win')
|
||||
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
|
||||
|
@ -511,11 +509,11 @@ class TestVLCPlayer(TestCase, TestMixin):
|
|||
# THEN: The video should be loaded
|
||||
mocked_normcase.assert_called_with(media_path)
|
||||
mocked_display.vlc_instance.media_new_location.assert_called_with('cdda://' + media_path)
|
||||
self.assertEqual(mocked_vlc_media, mocked_display.vlc_media)
|
||||
self.assertEqual(0, mocked_subitems.item_at_index.call_count)
|
||||
assert mocked_vlc_media == mocked_display.vlc_media
|
||||
assert 0 == mocked_subitems.item_at_index.call_count
|
||||
mocked_display.vlc_media_player.set_media.assert_called_with(mocked_vlc_media)
|
||||
self.assertEqual(0, mocked_vlc_media.parse.call_count)
|
||||
self.assertFalse(result)
|
||||
assert 0 == mocked_vlc_media.parse.call_count
|
||||
assert result is False
|
||||
|
||||
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
|
||||
@patch('openlp.core.ui.media.vlcplayer.datetime', MockDateTime)
|
||||
|
@ -538,7 +536,7 @@ class TestVLCPlayer(TestCase, TestMixin):
|
|||
result = vlc_player.media_state_wait(mocked_display, 2)
|
||||
|
||||
# THEN: The results should be True
|
||||
self.assertTrue(result)
|
||||
assert result is True
|
||||
|
||||
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
|
||||
@patch('openlp.core.ui.media.vlcplayer.datetime', MockDateTime)
|
||||
|
@ -561,7 +559,7 @@ class TestVLCPlayer(TestCase, TestMixin):
|
|||
result = vlc_player.media_state_wait(mocked_display, 2)
|
||||
|
||||
# THEN: The results should be True
|
||||
self.assertFalse(result)
|
||||
assert result is False
|
||||
|
||||
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
|
||||
@patch('openlp.core.ui.media.vlcplayer.datetime', MockDateTime)
|
||||
|
@ -586,7 +584,7 @@ class TestVLCPlayer(TestCase, TestMixin):
|
|||
result = vlc_player.media_state_wait(mocked_display, 3)
|
||||
|
||||
# THEN: The results should be True
|
||||
self.assertFalse(result)
|
||||
assert result is False
|
||||
|
||||
def test_resize(self):
|
||||
"""
|
||||
|
@ -636,9 +634,9 @@ class TestVLCPlayer(TestCase, TestMixin):
|
|||
# THEN: A bunch of things should happen to play the media
|
||||
mocked_thread.start.assert_called_with()
|
||||
mocked_volume.assert_called_with(mocked_display, 100)
|
||||
self.assertEqual(MediaState.Playing, vlc_player.get_live_state())
|
||||
assert MediaState.Playing == vlc_player.get_live_state()
|
||||
mocked_display.vlc_widget.raise_.assert_called_with()
|
||||
self.assertTrue(result, 'The value returned from play() should be True')
|
||||
assert result is True, 'The value returned from play() should be True'
|
||||
|
||||
@patch('openlp.core.ui.media.vlcplayer.threading')
|
||||
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
|
||||
|
@ -666,7 +664,7 @@ class TestVLCPlayer(TestCase, TestMixin):
|
|||
|
||||
# THEN: A thread should be started, but the method should return False
|
||||
mocked_thread.start.assert_called_with()
|
||||
self.assertFalse(result)
|
||||
assert result is False
|
||||
|
||||
@patch('openlp.core.ui.media.vlcplayer.threading')
|
||||
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
|
||||
|
@ -705,9 +703,9 @@ class TestVLCPlayer(TestCase, TestMixin):
|
|||
mocked_display.vlc_media_player.audio_set_track.assert_called_with(1)
|
||||
mocked_display.vlc_media_player.video_set_spu.assert_called_with(1)
|
||||
mocked_volume.assert_called_with(mocked_display, 100)
|
||||
self.assertEqual(MediaState.Playing, vlc_player.get_live_state())
|
||||
assert MediaState.Playing == vlc_player.get_live_state()
|
||||
mocked_display.vlc_widget.raise_.assert_called_with()
|
||||
self.assertTrue(result, 'The value returned from play() should be True')
|
||||
assert result is True, 'The value returned from play() should be True'
|
||||
|
||||
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
|
||||
def test_pause(self, mocked_get_vlc):
|
||||
|
@ -732,7 +730,7 @@ class TestVLCPlayer(TestCase, TestMixin):
|
|||
mocked_display.vlc_media.get_state.assert_called_with()
|
||||
mocked_display.vlc_media_player.pause.assert_called_with()
|
||||
mocked_media_state_wait.assert_called_with(mocked_display, 2)
|
||||
self.assertEqual(MediaState.Paused, vlc_player.get_live_state())
|
||||
assert MediaState.Paused == vlc_player.get_live_state()
|
||||
|
||||
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
|
||||
def test_pause_not_playing(self, mocked_get_vlc):
|
||||
|
@ -752,7 +750,7 @@ class TestVLCPlayer(TestCase, TestMixin):
|
|||
|
||||
# THEN: The pause method should exit early
|
||||
mocked_display.vlc_media.get_state.assert_called_with()
|
||||
self.assertEqual(0, mocked_display.vlc_media_player.pause.call_count)
|
||||
assert 0 == mocked_display.vlc_media_player.pause.call_count
|
||||
|
||||
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
|
||||
def test_pause_fail(self, mocked_get_vlc):
|
||||
|
@ -777,7 +775,7 @@ class TestVLCPlayer(TestCase, TestMixin):
|
|||
mocked_display.vlc_media.get_state.assert_called_with()
|
||||
mocked_display.vlc_media_player.pause.assert_called_with()
|
||||
mocked_media_state_wait.assert_called_with(mocked_display, 2)
|
||||
self.assertNotEqual(MediaState.Paused, vlc_player.state)
|
||||
assert MediaState.Paused is not vlc_player.state
|
||||
|
||||
@patch('openlp.core.ui.media.vlcplayer.threading')
|
||||
def test_stop(self, mocked_threading):
|
||||
|
@ -798,7 +796,7 @@ class TestVLCPlayer(TestCase, TestMixin):
|
|||
# THEN: A thread should have been started to stop VLC
|
||||
mocked_threading.Thread.assert_called_with(target=mocked_stop)
|
||||
mocked_thread.start.assert_called_with()
|
||||
self.assertEqual(MediaState.Stopped, vlc_player.get_live_state())
|
||||
assert MediaState.Stopped == vlc_player.get_live_state()
|
||||
|
||||
def test_volume(self):
|
||||
"""
|
||||
|
@ -828,7 +826,7 @@ class TestVLCPlayer(TestCase, TestMixin):
|
|||
vlc_player.volume(mocked_display, 10)
|
||||
|
||||
# THEN: The volume should NOT have been set
|
||||
self.assertEqual(0, mocked_display.vlc_media_player.audio_set_volume.call_count)
|
||||
assert 0 == mocked_display.vlc_media_player.audio_set_volume.call_count
|
||||
|
||||
def test_seek_unseekable_media(self):
|
||||
"""
|
||||
|
@ -845,7 +843,7 @@ class TestVLCPlayer(TestCase, TestMixin):
|
|||
|
||||
# THEN: nothing should happen
|
||||
mocked_display.vlc_media_player.is_seekable.assert_called_with()
|
||||
self.assertEqual(0, mocked_display.vlc_media_player.set_time.call_count)
|
||||
assert 0 == mocked_display.vlc_media_player.set_time.call_count
|
||||
|
||||
def test_seek_seekable_media(self):
|
||||
"""
|
||||
|
@ -896,7 +894,7 @@ class TestVLCPlayer(TestCase, TestMixin):
|
|||
# THEN: The media should be stopped and invisible
|
||||
mocked_display.vlc_media_player.stop.assert_called_with()
|
||||
mocked_display.vlc_widget.setVisible.assert_called_with(False)
|
||||
self.assertEqual(MediaState.Off, vlc_player.get_live_state())
|
||||
assert MediaState.Off == vlc_player.get_live_state()
|
||||
|
||||
def test_set_visible_has_own_widget(self):
|
||||
"""
|
||||
|
@ -926,7 +924,7 @@ class TestVLCPlayer(TestCase, TestMixin):
|
|||
vlc_player.set_visible(mocked_display, True)
|
||||
|
||||
# THEN: The media should be stopped and invsibile
|
||||
self.assertEqual(0, mocked_display.vlc_widget.setVisible.call_count)
|
||||
assert 0 == mocked_display.vlc_widget.setVisible.call_count
|
||||
|
||||
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
|
||||
def test_update_ui(self, mocked_get_vlc):
|
||||
|
@ -953,12 +951,12 @@ class TestVLCPlayer(TestCase, TestMixin):
|
|||
|
||||
# THEN: Certain methods should be called
|
||||
mocked_stop.assert_called_with(mocked_display)
|
||||
self.assertEqual(2, mocked_stop.call_count)
|
||||
assert 2 == mocked_stop.call_count
|
||||
mocked_display.vlc_media_player.get_time.assert_called_with()
|
||||
mocked_set_visible.assert_called_with(mocked_display, False)
|
||||
mocked_controller.seek_slider.setSliderPosition.assert_called_with(400000)
|
||||
expected_calls = [call(True), call(False)]
|
||||
self.assertEqual(expected_calls, mocked_controller.seek_slider.blockSignals.call_args_list)
|
||||
assert expected_calls == mocked_controller.seek_slider.blockSignals.call_args_list
|
||||
|
||||
@patch('openlp.core.ui.media.vlcplayer.get_vlc')
|
||||
def test_update_ui_dvd(self, mocked_get_vlc):
|
||||
|
@ -987,12 +985,12 @@ class TestVLCPlayer(TestCase, TestMixin):
|
|||
|
||||
# THEN: Certain methods should be called
|
||||
mocked_stop.assert_called_with(mocked_display)
|
||||
self.assertEqual(2, mocked_stop.call_count)
|
||||
assert 2 == mocked_stop.call_count
|
||||
mocked_display.vlc_media_player.get_time.assert_called_with()
|
||||
mocked_set_visible.assert_called_with(mocked_display, False)
|
||||
mocked_controller.seek_slider.setSliderPosition.assert_called_with(300)
|
||||
expected_calls = [call(True), call(False)]
|
||||
self.assertEqual(expected_calls, mocked_controller.seek_slider.blockSignals.call_args_list)
|
||||
assert expected_calls == mocked_controller.seek_slider.blockSignals.call_args_list
|
||||
|
||||
@patch('openlp.core.ui.media.vlcplayer.translate')
|
||||
def test_get_info(self, mocked_translate):
|
||||
|
@ -1007,6 +1005,6 @@ class TestVLCPlayer(TestCase, TestMixin):
|
|||
info = vlc_player.get_info()
|
||||
|
||||
# THEN: The information should be correct
|
||||
self.assertEqual('VLC is an external player which supports a number of different formats.<br/> '
|
||||
'<strong>Audio</strong><br/>' + str(AUDIO_EXT) + '<br/><strong>Video</strong><br/>' +
|
||||
str(VIDEO_EXT) + '<br/>', info)
|
||||
assert 'VLC is an external player which supports a number of different formats.<br/> ' \
|
||||
'<strong>Audio</strong><br/>' + str(AUDIO_EXT) + '<br/><strong>Video</strong><br/>' + \
|
||||
str(VIDEO_EXT) + '<br/>' == info
|
||||
|
|
|
@ -47,8 +47,7 @@ class TestWebkitPlayer(TestCase):
|
|||
available = webkit_player.check_available()
|
||||
|
||||
# THEN: The player should not be available when '[object HTMLUnknownElement]' is returned
|
||||
self.assertEqual(False, available,
|
||||
'The WebkitPlayer should not be available when video feature detection fails')
|
||||
assert available is False, 'The WebkitPlayer should not be available when video feature detection fails'
|
||||
|
||||
def test_check_available_video_enabled(self):
|
||||
"""
|
||||
|
@ -64,5 +63,4 @@ class TestWebkitPlayer(TestCase):
|
|||
available = webkit_player.check_available()
|
||||
|
||||
# THEN: The player should be available when '[object HTMLVideoElement]' is returned
|
||||
self.assertEqual(True, available,
|
||||
'The WebkitPlayer should be available when video feature detection passes')
|
||||
assert available is True, 'The WebkitPlayer should be available when video feature detection passes'
|
||||
|
|
|
@ -59,8 +59,8 @@ class TestFirstTimeForm(TestCase, TestMixin):
|
|||
about_form = AboutForm(None)
|
||||
|
||||
# THEN: The build number should be in the text
|
||||
self.assertTrue('OpenLP 3.1.5 build 3000' in about_form.about_text_edit.toPlainText(),
|
||||
"The build number should be set correctly")
|
||||
assert 'OpenLP 3.1.5 build 3000' in about_form.about_text_edit.toPlainText(), \
|
||||
"The build number should be set correctly"
|
||||
|
||||
def test_about_form_date(self):
|
||||
"""
|
||||
|
@ -74,5 +74,4 @@ class TestFirstTimeForm(TestCase, TestMixin):
|
|||
license_text = about_form.license_text_edit.toPlainText()
|
||||
|
||||
# THEN: The date should be in the text twice.
|
||||
self.assertTrue(license_text.count(date_string, 0) == 2,
|
||||
"The text string should be added twice to the license string")
|
||||
assert license_text.count(date_string, 0) == 2, "The text string should be added twice to the license string"
|
||||
|
|
|
@ -50,7 +50,7 @@ class TestAdvancedTab(TestCase, TestMixin):
|
|||
advanced_tab = AdvancedTab(settings_form)
|
||||
|
||||
# THEN:
|
||||
self.assertEqual("Advanced", advanced_tab.tab_title, 'The tab title should be Advanced')
|
||||
assert "Advanced" == advanced_tab.tab_title, 'The tab title should be Advanced'
|
||||
|
||||
def test_change_search_as_type(self):
|
||||
"""
|
||||
|
@ -64,6 +64,6 @@ class TestAdvancedTab(TestCase, TestMixin):
|
|||
advanced_tab.on_search_as_type_check_box_changed(True)
|
||||
|
||||
# THEN: we should have two post save processed to run
|
||||
self.assertEqual(2, len(settings_form.processes), 'Two post save processes should be created')
|
||||
self.assertTrue("songs_config_updated" in settings_form.processes, 'The songs plugin should be called')
|
||||
self.assertTrue("custom_config_updated" in settings_form.processes, 'The custom plugin should be called')
|
||||
assert 2 == len(settings_form.processes), 'Two post save processes should be created'
|
||||
assert "songs_config_updated" in settings_form.processes, 'The songs plugin should be called'
|
||||
assert "custom_config_updated" in settings_form.processes, 'The custom plugin should be called'
|
||||
|
|
|
@ -90,12 +90,12 @@ class TestFirstTimeForm(TestCase, TestMixin):
|
|||
frw.initialize(expected_screens)
|
||||
|
||||
# THEN: The screens should be set up, and the default values initialised
|
||||
self.assertEqual(expected_screens, frw.screens, 'The screens should be correct')
|
||||
self.assertTrue(frw.web_access, 'The default value of self.web_access should be True')
|
||||
self.assertFalse(frw.was_cancelled, 'The default value of self.was_cancelled should be False')
|
||||
self.assertListEqual([], frw.theme_screenshot_threads, 'The list of threads should be empty')
|
||||
self.assertListEqual([], frw.theme_screenshot_workers, 'The list of workers should be empty')
|
||||
self.assertFalse(frw.has_run_wizard, 'has_run_wizard should be False')
|
||||
assert expected_screens == frw.screens, 'The screens should be correct'
|
||||
assert frw.web_access is True, 'The default value of self.web_access should be True'
|
||||
assert frw.was_cancelled is False, 'The default value of self.was_cancelled should be False'
|
||||
assert [] == frw.theme_screenshot_threads, 'The list of threads should be empty'
|
||||
assert [] == frw.theme_screenshot_workers, 'The list of workers should be empty'
|
||||
assert frw.has_run_wizard is False, 'has_run_wizard should be False'
|
||||
|
||||
def test_set_defaults(self):
|
||||
"""
|
||||
|
@ -124,7 +124,7 @@ class TestFirstTimeForm(TestCase, TestMixin):
|
|||
|
||||
# THEN: The default values should have been set
|
||||
mocked_restart.assert_called_with()
|
||||
self.assertEqual('http://openlp.org/files/frw/', frw.web, 'The default URL should be set')
|
||||
assert 'http://openlp.org/files/frw/' == frw.web, 'The default URL should be set'
|
||||
mocked_cancel_button.clicked.connect.assert_called_with(frw.on_cancel_button_clicked)
|
||||
mocked_no_internet_finish_btn.clicked.connect.assert_called_with(frw.on_no_internet_finish_button_clicked)
|
||||
mocked_currentIdChanged.connect.assert_called_with(frw.on_current_id_changed)
|
||||
|
@ -176,12 +176,12 @@ class TestFirstTimeForm(TestCase, TestMixin):
|
|||
frw.on_cancel_button_clicked()
|
||||
|
||||
# THEN: The right things should be called in the right order
|
||||
self.assertTrue(frw.was_cancelled, 'The was_cancelled property should have been set to True')
|
||||
assert frw.was_cancelled is True, 'The was_cancelled property should have been set to True'
|
||||
mocked_worker.set_download_canceled.assert_called_with(True)
|
||||
mocked_thread.isRunning.assert_called_with()
|
||||
self.assertEqual(2, mocked_thread.isRunning.call_count, 'isRunning() should have been called twice')
|
||||
assert 2 == mocked_thread.isRunning.call_count, 'isRunning() should have been called twice'
|
||||
mocked_time.sleep.assert_called_with(0.1)
|
||||
self.assertEqual(1, mocked_time.sleep.call_count, 'sleep() should have only been called once')
|
||||
assert 1 == mocked_time.sleep.call_count, 'sleep() should have only been called once'
|
||||
mocked_set_normal_cursor.assert_called_with()
|
||||
|
||||
def test_broken_config(self):
|
||||
|
@ -198,7 +198,7 @@ class TestFirstTimeForm(TestCase, TestMixin):
|
|||
first_time_form._download_index()
|
||||
|
||||
# THEN: The First Time Form should not have web access
|
||||
self.assertFalse(first_time_form.web_access, 'There should not be web access with a broken config file')
|
||||
assert first_time_form.web_access is False, 'There should not be web access with a broken config file'
|
||||
|
||||
def test_invalid_config(self):
|
||||
"""
|
||||
|
@ -214,7 +214,7 @@ class TestFirstTimeForm(TestCase, TestMixin):
|
|||
first_time_form._download_index()
|
||||
|
||||
# THEN: The First Time Form should not have web access
|
||||
self.assertFalse(first_time_form.web_access, 'There should not be web access with an invalid config file')
|
||||
assert first_time_form.web_access is False, 'There should not be web access with an invalid config file'
|
||||
|
||||
@patch('openlp.core.ui.firsttimeform.get_web_page')
|
||||
@patch('openlp.core.ui.firsttimeform.QtWidgets.QMessageBox')
|
||||
|
|
|
@ -43,7 +43,7 @@ class TestFormattingTagController(TestCase):
|
|||
result = self.services._strip(tag)
|
||||
|
||||
# THEN: The tag should be returned with the wrappers removed.
|
||||
self.assertEqual(result, 'tag', 'FormattingTagForm._strip should return u\'tag\' when called with u\'{tag}\'')
|
||||
assert result == 'tag', 'FormattingTagForm._strip should return u\'tag\' when called with u\'{tag}\''
|
||||
|
||||
def test_end_tag_changed_processes_correctly(self):
|
||||
"""
|
||||
|
@ -64,11 +64,9 @@ class TestFormattingTagController(TestCase):
|
|||
error, result = self.services.end_tag_changed(test['start'], test['end'])
|
||||
|
||||
# THEN: The result should match the predetermined value.
|
||||
self.assertTrue(result == test['gen'],
|
||||
'Function should handle end tag correctly : %s and %s for %s ' %
|
||||
(test['gen'], result, test['start']))
|
||||
self.assertTrue(error == test['valid'], 'Function should not generate unexpected error messages : %s ' %
|
||||
error)
|
||||
assert result == test['gen'], \
|
||||
'Function should handle end tag correctly : %s and %s for %s ' % (test['gen'], result, test['start'])
|
||||
assert error == test['valid'], 'Function should not generate unexpected error messages : %s ' % error
|
||||
|
||||
def test_start_tag_changed_processes_correctly(self):
|
||||
"""
|
||||
|
@ -88,10 +86,9 @@ class TestFormattingTagController(TestCase):
|
|||
error, result = self.services.start_tag_changed(test['start'], test['end'])
|
||||
|
||||
# THEN: The result should match the predetermined value.
|
||||
self.assertTrue(result == test['gen'], 'Function should handle end tag correctly : %s and %s ' %
|
||||
(test['gen'], result))
|
||||
self.assertTrue(error == test['valid'], 'Function should not generate unexpected error messages : %s ' %
|
||||
error)
|
||||
assert result == test['gen'], \
|
||||
'Function should handle end tag correctly : %s and %s ' % (test['gen'], result)
|
||||
assert error == test['valid'], 'Function should not generate unexpected error messages : %s ' % error
|
||||
|
||||
def test_start_html_to_end_html(self):
|
||||
"""
|
||||
|
@ -106,5 +103,4 @@ class TestFormattingTagController(TestCase):
|
|||
result = self.services.start_html_to_end_html(test1)
|
||||
|
||||
# THEN: The result should match the predetermined value.
|
||||
self.assertTrue(result == test2, 'Calculated end tag should be valid: %s and %s = %s' %
|
||||
(test1, test2, result))
|
||||
assert result == test2, 'Calculated end tag should be valid: %s and %s = %s' % (test1, test2, result)
|
||||
|
|
|
@ -83,8 +83,8 @@ class TestFormattingTagForm(TestCase):
|
|||
call(row_count, 2, mocked_table_widget),
|
||||
call(row_count, 3, mocked_table_widget)
|
||||
]
|
||||
self.assertEqual(expected_set_item_calls, form.tag_table_widget.setItem.call_args_list,
|
||||
'setItem should have been called correctly')
|
||||
assert expected_set_item_calls == form.tag_table_widget.setItem.call_args_list, \
|
||||
'setItem should have been called correctly'
|
||||
form.tag_table_widget.resizeRowsToContents.assert_called_with()
|
||||
form.tag_table_widget.scrollToBottom.assert_called_with()
|
||||
form.tag_table_widget.selectRow.assert_called_with(row_count)
|
||||
|
|
|
@ -83,7 +83,7 @@ class TestMainDisplay(TestCase, TestMixin):
|
|||
main_display = MainDisplay(display)
|
||||
|
||||
# THEN: The controller should be a live controller.
|
||||
self.assertEqual(main_display.is_live, True, 'The main display should be a live controller')
|
||||
assert main_display.is_live is True, 'The main display should be a live controller'
|
||||
|
||||
def test_set_transparency_enabled(self):
|
||||
"""
|
||||
|
@ -97,12 +97,12 @@ class TestMainDisplay(TestCase, TestMixin):
|
|||
main_display.set_transparency(True)
|
||||
|
||||
# THEN: The transparent stylesheet should be used
|
||||
self.assertEqual(TRANSPARENT_STYLESHEET, main_display.styleSheet(),
|
||||
'The MainDisplay should use the transparent stylesheet')
|
||||
self.assertFalse(main_display.autoFillBackground(),
|
||||
'The MainDisplay should not have autoFillBackground set')
|
||||
self.assertTrue(main_display.testAttribute(QtCore.Qt.WA_TranslucentBackground),
|
||||
'The MainDisplay should have a translucent background')
|
||||
assert TRANSPARENT_STYLESHEET == main_display.styleSheet(), \
|
||||
'The MainDisplay should use the transparent stylesheet'
|
||||
assert main_display.autoFillBackground() is False, \
|
||||
'The MainDisplay should not have autoFillBackground set'
|
||||
assert main_display.testAttribute(QtCore.Qt.WA_TranslucentBackground) is True, \
|
||||
'The MainDisplay should have a translucent background'
|
||||
|
||||
def test_set_transparency_disabled(self):
|
||||
"""
|
||||
|
@ -116,10 +116,10 @@ class TestMainDisplay(TestCase, TestMixin):
|
|||
main_display.set_transparency(False)
|
||||
|
||||
# THEN: The opaque stylesheet should be used
|
||||
self.assertEqual(OPAQUE_STYLESHEET, main_display.styleSheet(),
|
||||
'The MainDisplay should use the opaque stylesheet')
|
||||
self.assertFalse(main_display.testAttribute(QtCore.Qt.WA_TranslucentBackground),
|
||||
'The MainDisplay should not have a translucent background')
|
||||
assert OPAQUE_STYLESHEET == main_display.styleSheet(), \
|
||||
'The MainDisplay should use the opaque stylesheet'
|
||||
assert main_display.testAttribute(QtCore.Qt.WA_TranslucentBackground) is False, \
|
||||
'The MainDisplay should not have a translucent background'
|
||||
|
||||
def test_css_changed(self):
|
||||
"""
|
||||
|
@ -156,9 +156,9 @@ class TestMainDisplay(TestCase, TestMixin):
|
|||
main_display = MainDisplay(display)
|
||||
|
||||
# THEN: The window flags should be the same as those needed on Mac OS X.
|
||||
self.assertEqual(QtCore.Qt.Window | QtCore.Qt.FramelessWindowHint | QtCore.Qt.NoDropShadowWindowHint,
|
||||
main_display.windowFlags(),
|
||||
'The window flags should be Qt.Window, Qt.FramelessWindowHint, and Qt.NoDropShadowWindowHint.')
|
||||
assert QtCore.Qt.Window | QtCore.Qt.FramelessWindowHint | QtCore.Qt.NoDropShadowWindowHint == \
|
||||
main_display.windowFlags(), \
|
||||
'The window flags should be Qt.Window, Qt.FramelessWindowHint, and Qt.NoDropShadowWindowHint.'
|
||||
|
||||
@skipUnless(is_macosx(), 'Can only run test on Mac OS X due to pyobjc dependency.')
|
||||
def test_macosx_display(self):
|
||||
|
@ -181,10 +181,10 @@ class TestMainDisplay(TestCase, TestMixin):
|
|||
pyobjc_nsview = objc_object(cobject=nsview_pointer)
|
||||
|
||||
# THEN: The window level and collection behavior should be the same as those needed for Mac OS X.
|
||||
self.assertEqual(pyobjc_nsview.window().level(), NSMainMenuWindowLevel + 2,
|
||||
'Window level should be NSMainMenuWindowLevel + 2')
|
||||
self.assertEqual(pyobjc_nsview.window().collectionBehavior(), NSWindowCollectionBehaviorManaged,
|
||||
'Window collection behavior should be NSWindowCollectionBehaviorManaged')
|
||||
assert pyobjc_nsview.window().level() == NSMainMenuWindowLevel + 2, \
|
||||
'Window level should be NSMainMenuWindowLevel + 2'
|
||||
assert pyobjc_nsview.window().collectionBehavior() == NSWindowCollectionBehaviorManaged, \
|
||||
'Window collection behavior should be NSWindowCollectionBehaviorManaged'
|
||||
|
||||
@patch('openlp.core.ui.maindisplay.Settings')
|
||||
def test_show_display_startup_logo(self, MockedSettings):
|
||||
|
@ -250,9 +250,9 @@ class TestMainDisplay(TestCase, TestMixin):
|
|||
main_display.build_html(service_item)
|
||||
|
||||
# THEN: the following should had not been called
|
||||
self.assertEquals(main_display.web_view.setHtml.call_count, 1, 'setHTML should be called once')
|
||||
self.assertEquals(main_display.media_controller.video.call_count, 0,
|
||||
'Media Controller video should not have been called')
|
||||
assert main_display.web_view.setHtml.call_count == 1, 'setHTML should be called once'
|
||||
assert main_display.media_controller.video.call_count == 0, \
|
||||
'Media Controller video should not have been called'
|
||||
|
||||
@patch('openlp.core.ui.maindisplay.Settings')
|
||||
@patch('openlp.core.ui.maindisplay.build_html')
|
||||
|
@ -282,9 +282,9 @@ class TestMainDisplay(TestCase, TestMixin):
|
|||
main_display.build_html(service_item)
|
||||
|
||||
# THEN: the following should had not been called
|
||||
self.assertEquals(main_display.web_view.setHtml.call_count, 1, 'setHTML should be called once')
|
||||
self.assertEquals(main_display.media_controller.video.call_count, 1,
|
||||
'Media Controller video should have been called once')
|
||||
assert main_display.web_view.setHtml.call_count == 1, 'setHTML should be called once'
|
||||
assert main_display.media_controller.video.call_count == 1, \
|
||||
'Media Controller video should have been called once'
|
||||
|
||||
|
||||
def test_calling_next_item_in_playlist():
|
||||
|
|
|
@ -106,7 +106,7 @@ class TestMainWindow(TestCase, TestMixin):
|
|||
self.main_window.open_cmd_line_files("")
|
||||
|
||||
# THEN the file should not be opened
|
||||
assert not mocked_load_file.called, 'load_file should not have been called'
|
||||
assert mocked_load_file.called is False, 'load_file should not have been called'
|
||||
|
||||
def test_main_window_title(self):
|
||||
"""
|
||||
|
@ -130,8 +130,8 @@ class TestMainWindow(TestCase, TestMixin):
|
|||
self.main_window.set_service_modified(True, 'test.osz')
|
||||
|
||||
# THEN the main window's title should be set to the
|
||||
self.assertEqual(self.main_window.windowTitle(), '%s - %s*' % (UiStrings().OpenLP, 'test.osz'),
|
||||
'The main window\'s title should be set to "<the contents of UiStrings().OpenLP> - test.osz*"')
|
||||
assert self.main_window.windowTitle(), '%s - %s*' % (UiStrings().OpenLP, 'test.osz') == \
|
||||
'The main window\'s title should be set to "<the contents of UiStrings().OpenLP> - test.osz*"'
|
||||
|
||||
def test_set_service_unmodified(self):
|
||||
"""
|
||||
|
@ -143,8 +143,8 @@ class TestMainWindow(TestCase, TestMixin):
|
|||
self.main_window.set_service_modified(False, 'test.osz')
|
||||
|
||||
# THEN the main window's title should be set to the
|
||||
self.assertEqual(self.main_window.windowTitle(), '%s - %s' % (UiStrings().OpenLP, 'test.osz'),
|
||||
'The main window\'s title should be set to "<the contents of UiStrings().OpenLP> - test.osz"')
|
||||
assert self.main_window.windowTitle(), '%s - %s' % (UiStrings().OpenLP, 'test.osz') == \
|
||||
'The main window\'s title should be set to "<the contents of UiStrings().OpenLP> - test.osz"'
|
||||
|
||||
def test_mainwindow_configuration(self):
|
||||
"""
|
||||
|
|
|
@ -52,8 +52,8 @@ class TestMedia(TestCase, TestMixin):
|
|||
used_players, overridden_player = get_media_players()
|
||||
|
||||
# THEN: the used_players should be an empty list, and the overridden player should be an empty string
|
||||
self.assertEqual([], used_players, 'Used players should be an empty list')
|
||||
self.assertEqual('', overridden_player, 'Overridden player should be an empty string')
|
||||
assert [] == used_players, 'Used players should be an empty list'
|
||||
assert '' == overridden_player, 'Overridden player should be an empty string'
|
||||
|
||||
def test_get_media_players_no_players(self):
|
||||
"""
|
||||
|
@ -73,8 +73,8 @@ class TestMedia(TestCase, TestMixin):
|
|||
used_players, overridden_player = get_media_players()
|
||||
|
||||
# THEN: the used_players should be an empty list, and the overridden player should be an empty string
|
||||
self.assertEqual([], used_players, 'Used players should be an empty list')
|
||||
self.assertEqual('auto', overridden_player, 'Overridden player should be "auto"')
|
||||
assert [] == used_players, 'Used players should be an empty list'
|
||||
assert 'auto' == overridden_player, 'Overridden player should be "auto"'
|
||||
|
||||
def test_get_media_players_with_valid_list(self):
|
||||
"""
|
||||
|
@ -94,8 +94,8 @@ class TestMedia(TestCase, TestMixin):
|
|||
used_players, overridden_player = get_media_players()
|
||||
|
||||
# THEN: the used_players should be an empty list, and the overridden player should be an empty string
|
||||
self.assertEqual(['vlc', 'webkit', 'system'], used_players, 'Used players should be correct')
|
||||
self.assertEqual('', overridden_player, 'Overridden player should be an empty string')
|
||||
assert ['vlc', 'webkit', 'system'] == used_players, 'Used players should be correct'
|
||||
assert '' == overridden_player, 'Overridden player should be an empty string'
|
||||
|
||||
def test_get_media_players_with_overridden_player(self):
|
||||
"""
|
||||
|
@ -115,8 +115,8 @@ class TestMedia(TestCase, TestMixin):
|
|||
used_players, overridden_player = get_media_players()
|
||||
|
||||
# THEN: the used_players should be an empty list, and the overridden player should be an empty string
|
||||
self.assertEqual(['vlc', 'webkit', 'system'], used_players, 'Used players should be correct')
|
||||
self.assertEqual('vlc,webkit,system', overridden_player, 'Overridden player should be a string of players')
|
||||
assert ['vlc', 'webkit', 'system'] == used_players, 'Used players should be correct'
|
||||
assert 'vlc,webkit,system' == overridden_player, 'Overridden player should be a string of players'
|
||||
|
||||
def test_parse_optical_path_linux(self):
|
||||
"""
|
||||
|
@ -138,13 +138,13 @@ class TestMedia(TestCase, TestMixin):
|
|||
(device_path, title_track, audio_track, subtitle_track, start, end, name) = parse_optical_path(path)
|
||||
|
||||
# THEN: The return values should match the original values
|
||||
self.assertEqual(org_title_track, title_track, 'Returned title_track should match the original')
|
||||
self.assertEqual(org_audio_track, audio_track, 'Returned audio_track should match the original')
|
||||
self.assertEqual(org_subtitle_track, subtitle_track, 'Returned subtitle_track should match the original')
|
||||
self.assertEqual(org_start, start, 'Returned start should match the original')
|
||||
self.assertEqual(org_end, end, 'Returned end should match the original')
|
||||
self.assertEqual(org_name, name, 'Returned end should match the original')
|
||||
self.assertEqual(org_device_path, device_path, 'Returned device_path should match the original')
|
||||
assert org_title_track == title_track, 'Returned title_track should match the original'
|
||||
assert org_audio_track == audio_track, 'Returned audio_track should match the original'
|
||||
assert org_subtitle_track == subtitle_track, 'Returned subtitle_track should match the original'
|
||||
assert org_start == start, 'Returned start should match the original'
|
||||
assert org_end == end, 'Returned end should match the original'
|
||||
assert org_name == name, 'Returned end should match the original'
|
||||
assert org_device_path == device_path, 'Returned device_path should match the original'
|
||||
|
||||
def test_parse_optical_path_win(self):
|
||||
"""
|
||||
|
@ -166,10 +166,10 @@ class TestMedia(TestCase, TestMixin):
|
|||
(device_path, title_track, audio_track, subtitle_track, start, end, name) = parse_optical_path(path)
|
||||
|
||||
# THEN: The return values should match the original values
|
||||
self.assertEqual(org_title_track, title_track, 'Returned title_track should match the original')
|
||||
self.assertEqual(org_audio_track, audio_track, 'Returned audio_track should match the original')
|
||||
self.assertEqual(org_subtitle_track, subtitle_track, 'Returned subtitle_track should match the original')
|
||||
self.assertEqual(org_start, start, 'Returned start should match the original')
|
||||
self.assertEqual(org_end, end, 'Returned end should match the original')
|
||||
self.assertEqual(org_name, name, 'Returned end should match the original')
|
||||
self.assertEqual(org_device_path, device_path, 'Returned device_path should match the original')
|
||||
assert org_title_track == title_track, 'Returned title_track should match the original'
|
||||
assert org_audio_track == audio_track, 'Returned audio_track should match the original'
|
||||
assert org_subtitle_track == subtitle_track, 'Returned subtitle_track should match the original'
|
||||
assert org_start == start, 'Returned start should match the original'
|
||||
assert org_end == end, 'Returned end should match the original'
|
||||
assert org_name == name, 'Returned end should match the original'
|
||||
assert org_device_path == device_path, 'Returned device_path should match the original'
|
||||
|
|
|
@ -54,7 +54,7 @@ class TestServiceManager(TestCase):
|
|||
ServiceManager(None)
|
||||
# WHEN: the default service manager is built.
|
||||
# THEN: The the controller should be registered in the registry.
|
||||
self.assertNotEqual(Registry().get('service_manager'), None, 'The base service manager should be registered')
|
||||
assert Registry().get('service_manager') is not None, 'The base service manager should be registered'
|
||||
|
||||
def test_create_basic_service(self):
|
||||
"""
|
||||
|
@ -67,9 +67,9 @@ class TestServiceManager(TestCase):
|
|||
service_manager.service_theme = 'test_theme'
|
||||
service = service_manager.create_basic_service()[0]
|
||||
# THEN: The controller should be registered in the registry.
|
||||
self.assertNotEqual(service, None, 'The base service should be created')
|
||||
self.assertEqual(service['openlp_core']['service-theme'], 'test_theme', 'The test theme should be saved')
|
||||
self.assertEqual(service['openlp_core']['lite-service'], False, 'The lite service should be saved')
|
||||
assert service is not None, 'The base service should be created'
|
||||
assert service['openlp_core']['service-theme'] == 'test_theme', 'The test theme should be saved'
|
||||
assert service['openlp_core']['lite-service'] is False, 'The lite service should be saved'
|
||||
|
||||
def test_supported_suffixes(self):
|
||||
"""
|
||||
|
@ -81,9 +81,9 @@ class TestServiceManager(TestCase):
|
|||
service_manager.supported_suffixes('txt')
|
||||
service_manager.supported_suffixes(['pptx', 'ppt'])
|
||||
# THEN: The suffixes should be available to test.
|
||||
self.assertEqual('txt' in service_manager.suffixes, True, 'The suffix txt should be in the list')
|
||||
self.assertEqual('ppt' in service_manager.suffixes, True, 'The suffix ppt should be in the list')
|
||||
self.assertEqual('pptx' in service_manager.suffixes, True, 'The suffix pptx should be in the list')
|
||||
assert 'txt' in service_manager.suffixes, 'The suffix txt should be in the list'
|
||||
assert 'ppt' in service_manager.suffixes, 'The suffix ppt should be in the list'
|
||||
assert 'pptx' in service_manager.suffixes, 'The suffix pptx should be in the list'
|
||||
|
||||
def test_build_context_menu(self):
|
||||
"""
|
||||
|
@ -114,20 +114,20 @@ class TestServiceManager(TestCase):
|
|||
# WHEN I define a context menu
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following calls should have occurred.
|
||||
self.assertEqual(service_manager.edit_action.setVisible.call_count, 1, 'Should have been called once')
|
||||
self.assertEqual(service_manager.rename_action.setVisible.call_count, 1, 'Should have been called once')
|
||||
self.assertEqual(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have been called once')
|
||||
self.assertEqual(service_manager.maintain_action.setVisible.call_count, 1, 'Should have been called once')
|
||||
self.assertEqual(service_manager.notes_action.setVisible.call_count, 1, 'Should have been called once')
|
||||
self.assertEqual(service_manager.time_action.setVisible.call_count, 1, 'Should have been called once')
|
||||
self.assertEqual(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have been called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have been called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.theme_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have been called once')
|
||||
assert service_manager.edit_action.setVisible.call_count == 1, 'Should have been called once'
|
||||
assert service_manager.rename_action.setVisible.call_count == 1, 'Should have been called once'
|
||||
assert service_manager.create_custom_action.setVisible.call_count == 1, 'Should have been called once'
|
||||
assert service_manager.maintain_action.setVisible.call_count == 1, 'Should have been called once'
|
||||
assert service_manager.notes_action.setVisible.call_count == 1, 'Should have been called once'
|
||||
assert service_manager.time_action.setVisible.call_count == 1, 'Should have been called once'
|
||||
assert service_manager.auto_start_action.setVisible.call_count == 1, 'Should have been called once'
|
||||
assert service_manager.auto_play_slides_menu.menuAction().setVisible.call_count == 1, \
|
||||
'Should have been called once'
|
||||
assert service_manager.auto_play_slides_once.setChecked.call_count == 0, 'Should not be called'
|
||||
assert service_manager.auto_play_slides_loop.setChecked.call_count == 0, 'Should not be called'
|
||||
assert service_manager.timed_slide_interval.setChecked.call_count == 0, 'Should not be called'
|
||||
assert service_manager.theme_menu.menuAction().setVisible.call_count == 1, \
|
||||
'Should have been called once'
|
||||
|
||||
def test_build_song_context_menu(self):
|
||||
"""
|
||||
|
@ -169,29 +169,29 @@ class TestServiceManager(TestCase):
|
|||
# WHEN I define a context menu
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following calls should have occurred.
|
||||
self.assertEqual(service_manager.edit_action.setVisible.call_count, 2, 'Should have be called twice')
|
||||
self.assertEqual(service_manager.rename_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.maintain_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.theme_menu.menuAction().setVisible.call_count, 2,
|
||||
'Should have be called twice')
|
||||
assert service_manager.edit_action.setVisible.call_count == 2, 'Should have be called twice'
|
||||
assert service_manager.rename_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.create_custom_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.maintain_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.notes_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.time_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.auto_start_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.auto_play_slides_menu.menuAction().setVisible.call_count == 1, \
|
||||
'Should have be called once'
|
||||
assert service_manager.auto_play_slides_once.setChecked.call_count == 0, 'Should not be called'
|
||||
assert service_manager.auto_play_slides_loop.setChecked.call_count == 0, 'Should not be called'
|
||||
assert service_manager.timed_slide_interval.setChecked.call_count == 0, 'Should not be called'
|
||||
assert service_manager.theme_menu.menuAction().setVisible.call_count == 2, \
|
||||
'Should have be called twice'
|
||||
# THEN we add a 2nd display frame
|
||||
service_item._display_frames.append(MagicMock())
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following additional calls should have occurred.
|
||||
self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 2,
|
||||
'Should have be called twice')
|
||||
self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 1, 'Should have be called once')
|
||||
assert service_manager.auto_play_slides_menu.menuAction().setVisible.call_count == 2, \
|
||||
'Should have be called twice'
|
||||
assert service_manager.auto_play_slides_once.setChecked.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.auto_play_slides_loop.setChecked.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.timed_slide_interval.setChecked.call_count == 1, 'Should have be called once'
|
||||
|
||||
def test_build_bible_context_menu(self):
|
||||
"""
|
||||
|
@ -233,29 +233,29 @@ class TestServiceManager(TestCase):
|
|||
# WHEN I define a context menu
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following calls should have occurred.
|
||||
self.assertEqual(service_manager.edit_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.rename_action.setVisible.call_count, 2, 'Should have be called twice')
|
||||
self.assertEqual(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.maintain_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.theme_menu.menuAction().setVisible.call_count, 2,
|
||||
'Should have be called twice')
|
||||
assert service_manager.edit_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.rename_action.setVisible.call_count == 2, 'Should have be called twice'
|
||||
assert service_manager.create_custom_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.maintain_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.notes_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.time_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.auto_start_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.auto_play_slides_menu.menuAction().setVisible.call_count == 1, \
|
||||
'Should have be called once'
|
||||
assert service_manager.auto_play_slides_once.setChecked.call_count == 0, 'Should not be called'
|
||||
assert service_manager.auto_play_slides_loop.setChecked.call_count == 0, 'Should not be called'
|
||||
assert service_manager.timed_slide_interval.setChecked.call_count == 0, 'Should not be called'
|
||||
assert service_manager.theme_menu.menuAction().setVisible.call_count == 2, \
|
||||
'Should have be called twice'
|
||||
# THEN we add a 2nd display frame
|
||||
service_item._display_frames.append(MagicMock())
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following additional calls should have occurred.
|
||||
self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 2,
|
||||
'Should have be called twice')
|
||||
self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 1, 'Should have be called once')
|
||||
assert service_manager.auto_play_slides_menu.menuAction().setVisible.call_count == 2, \
|
||||
'Should have be called twice'
|
||||
assert service_manager.auto_play_slides_once.setChecked.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.auto_play_slides_loop.setChecked.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.timed_slide_interval.setChecked.call_count == 1, 'Should have be called once'
|
||||
|
||||
def test_build_custom_context_menu(self):
|
||||
"""
|
||||
|
@ -298,29 +298,29 @@ class TestServiceManager(TestCase):
|
|||
# WHEN I define a context menu
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following calls should have occurred.
|
||||
self.assertEqual(service_manager.edit_action.setVisible.call_count, 2, 'Should have be called twice')
|
||||
self.assertEqual(service_manager.rename_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.maintain_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.theme_menu.menuAction().setVisible.call_count, 2,
|
||||
'Should have be called twice')
|
||||
assert service_manager.edit_action.setVisible.call_count == 2, 'Should have be called twice'
|
||||
assert service_manager.rename_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.create_custom_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.maintain_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.notes_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.time_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.auto_start_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.auto_play_slides_menu.menuAction().setVisible.call_count == 1, \
|
||||
'Should have be called once'
|
||||
assert service_manager.auto_play_slides_once.setChecked.call_count == 0, 'Should not be called'
|
||||
assert service_manager.auto_play_slides_loop.setChecked.call_count == 0, 'Should not be called'
|
||||
assert service_manager.timed_slide_interval.setChecked.call_count == 0, 'Should not be called'
|
||||
assert service_manager.theme_menu.menuAction().setVisible.call_count == 2, \
|
||||
'Should have be called twice'
|
||||
# THEN we add a 2nd display frame
|
||||
service_item._display_frames.append(MagicMock())
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following additional calls should have occurred.
|
||||
self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 2,
|
||||
'Should have be called twice')
|
||||
self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 1, 'Should have be called once')
|
||||
assert service_manager.auto_play_slides_menu.menuAction().setVisible.call_count == 2, \
|
||||
'Should have be called twice'
|
||||
assert service_manager.auto_play_slides_once.setChecked.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.auto_play_slides_loop.setChecked.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.timed_slide_interval.setChecked.call_count == 1, 'Should have be called once'
|
||||
|
||||
def test_build_image_context_menu(self):
|
||||
"""
|
||||
|
@ -361,29 +361,29 @@ class TestServiceManager(TestCase):
|
|||
# WHEN I define a context menu
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following calls should have occurred.
|
||||
self.assertEqual(service_manager.edit_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.rename_action.setVisible.call_count, 2, 'Should have be called twice')
|
||||
self.assertEqual(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.maintain_action.setVisible.call_count, 2, 'Should have be called twice')
|
||||
self.assertEqual(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.theme_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
assert service_manager.edit_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.rename_action.setVisible.call_count == 2, 'Should have be called twice'
|
||||
assert service_manager.create_custom_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.maintain_action.setVisible.call_count == 2, 'Should have be called twice'
|
||||
assert service_manager.notes_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.time_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.auto_start_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.auto_play_slides_menu.menuAction().setVisible.call_count == 1, \
|
||||
'Should have be called once'
|
||||
assert service_manager.auto_play_slides_once.setChecked.call_count == 0, 'Should not be called'
|
||||
assert service_manager.auto_play_slides_loop.setChecked.call_count == 0, 'Should not be called'
|
||||
assert service_manager.timed_slide_interval.setChecked.call_count == 0, 'Should not be called'
|
||||
assert service_manager.theme_menu.menuAction().setVisible.call_count == 1, \
|
||||
'Should have be called once'
|
||||
# THEN we add a 2nd display frame and regenerate the menu.
|
||||
service_item._raw_frames.append(MagicMock())
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following additional calls should have occurred.
|
||||
self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 2,
|
||||
'Should have be called twice')
|
||||
self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 1, 'Should have be called once')
|
||||
assert service_manager.auto_play_slides_menu.menuAction().setVisible.call_count == 2, \
|
||||
'Should have be called twice'
|
||||
assert service_manager.auto_play_slides_once.setChecked.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.auto_play_slides_loop.setChecked.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.timed_slide_interval.setChecked.call_count == 1, 'Should have be called once'
|
||||
|
||||
def test_build_media_context_menu(self):
|
||||
"""
|
||||
|
@ -422,25 +422,25 @@ class TestServiceManager(TestCase):
|
|||
# WHEN I define a context menu
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following calls should have occurred.
|
||||
self.assertEqual(service_manager.edit_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.rename_action.setVisible.call_count, 2, 'Should have be called twice')
|
||||
self.assertEqual(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.maintain_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_start_action.setVisible.call_count, 2, 'Should have be called twice')
|
||||
self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.theme_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
assert service_manager.edit_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.rename_action.setVisible.call_count == 2, 'Should have be called twice'
|
||||
assert service_manager.create_custom_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.maintain_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.notes_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.time_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.auto_start_action.setVisible.call_count == 2, 'Should have be called twice'
|
||||
assert service_manager.auto_play_slides_menu.menuAction().setVisible.call_count == 1, \
|
||||
'Should have be called once'
|
||||
assert service_manager.auto_play_slides_once.setChecked.call_count == 0, 'Should not be called'
|
||||
assert service_manager.auto_play_slides_loop.setChecked.call_count == 0, 'Should not be called'
|
||||
assert service_manager.timed_slide_interval.setChecked.call_count == 0, 'Should not be called'
|
||||
assert service_manager.theme_menu.menuAction().setVisible.call_count == 1, \
|
||||
'Should have be called once'
|
||||
# THEN I change the length of the media and regenerate the menu.
|
||||
service_item.set_media_length(5)
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following additional calls should have occurred.
|
||||
self.assertEqual(service_manager.time_action.setVisible.call_count, 3, 'Should have be called three times')
|
||||
assert service_manager.time_action.setVisible.call_count == 3, 'Should have be called three times'
|
||||
|
||||
def test_build_presentation_pdf_context_menu(self):
|
||||
"""
|
||||
|
@ -480,20 +480,20 @@ class TestServiceManager(TestCase):
|
|||
# WHEN I define a context menu
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following calls should have occurred.
|
||||
self.assertEqual(service_manager.edit_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.rename_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.maintain_action.setVisible.call_count, 2, 'Should have be called twice')
|
||||
self.assertEqual(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.theme_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
assert service_manager.edit_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.rename_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.create_custom_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.maintain_action.setVisible.call_count == 2, 'Should have be called twice'
|
||||
assert service_manager.notes_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.time_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.auto_start_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.auto_play_slides_menu.menuAction().setVisible.call_count == 1, \
|
||||
'Should have be called once'
|
||||
assert service_manager.auto_play_slides_once.setChecked.call_count == 0, 'Should not be called'
|
||||
assert service_manager.auto_play_slides_loop.setChecked.call_count == 0, 'Should not be called'
|
||||
assert service_manager.timed_slide_interval.setChecked.call_count == 0, 'Should not be called'
|
||||
assert service_manager.theme_menu.menuAction().setVisible.call_count == 1, \
|
||||
'Should have be called once'
|
||||
|
||||
def test_build_presentation_non_pdf_context_menu(self):
|
||||
"""
|
||||
|
@ -530,20 +530,20 @@ class TestServiceManager(TestCase):
|
|||
# WHEN I define a context menu
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following calls should have occurred.
|
||||
self.assertEqual(service_manager.edit_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.rename_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.maintain_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.theme_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
assert service_manager.edit_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.rename_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.create_custom_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.maintain_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.notes_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.time_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.auto_start_action.setVisible.call_count == 1, 'Should have be called once'
|
||||
assert service_manager.auto_play_slides_menu.menuAction().setVisible.call_count == 1, \
|
||||
'Should have be called once'
|
||||
assert service_manager.auto_play_slides_once.setChecked.call_count == 0, 'Should not be called'
|
||||
assert service_manager.auto_play_slides_loop.setChecked.call_count == 0, 'Should not be called'
|
||||
assert service_manager.timed_slide_interval.setChecked.call_count == 0, 'Should not be called'
|
||||
assert service_manager.theme_menu.menuAction().setVisible.call_count == 1, \
|
||||
'Should have be called once'
|
||||
|
||||
@patch('openlp.core.ui.servicemanager.Settings')
|
||||
@patch('PyQt5.QtCore.QTimer.singleShot')
|
||||
|
@ -576,7 +576,7 @@ class TestServiceManager(TestCase):
|
|||
# WHEN: on_single_click_preview() is called
|
||||
service_manager.on_single_click_preview()
|
||||
# THEN: timer should not be started
|
||||
self.assertEqual(mocked_singleShot.call_count, 0, 'Should not be called')
|
||||
assert mocked_singleShot.call_count == 0, 'Should not be called'
|
||||
|
||||
@patch('openlp.core.ui.servicemanager.Settings')
|
||||
@patch('PyQt5.QtCore.QTimer.singleShot')
|
||||
|
@ -595,7 +595,7 @@ class TestServiceManager(TestCase):
|
|||
service_manager.on_single_click_preview()
|
||||
# THEN: timer should not be started
|
||||
mocked_make_live.assert_called_with()
|
||||
self.assertEqual(mocked_singleShot.call_count, 0, 'Should not be called')
|
||||
assert mocked_singleShot.call_count == 0, 'Should not be called'
|
||||
|
||||
@patch('openlp.core.ui.servicemanager.ServiceManager.make_preview')
|
||||
def test_single_click_timeout_single(self, mocked_make_preview):
|
||||
|
@ -607,8 +607,7 @@ class TestServiceManager(TestCase):
|
|||
# WHEN: on_single_click_preview() is called
|
||||
service_manager.on_single_click_preview_timeout()
|
||||
# THEN: make_preview() should have been called
|
||||
self.assertEqual(mocked_make_preview.call_count, 1,
|
||||
'ServiceManager.make_preview() should have been called once')
|
||||
assert mocked_make_preview.call_count == 1, 'ServiceManager.make_preview() should have been called once'
|
||||
|
||||
@patch('openlp.core.ui.servicemanager.ServiceManager.make_preview')
|
||||
@patch('openlp.core.ui.servicemanager.ServiceManager.make_live')
|
||||
|
@ -622,7 +621,7 @@ class TestServiceManager(TestCase):
|
|||
service_manager.on_double_click_live()
|
||||
service_manager.on_single_click_preview_timeout()
|
||||
# THEN: make_preview() should not have been called
|
||||
self.assertEqual(mocked_make_preview.call_count, 0, 'ServiceManager.make_preview() should not be called')
|
||||
assert mocked_make_preview.call_count == 0, 'ServiceManager.make_preview() should not be called'
|
||||
|
||||
@patch('openlp.core.ui.servicemanager.shutil.copy')
|
||||
@patch('openlp.core.ui.servicemanager.zipfile')
|
||||
|
@ -650,7 +649,7 @@ class TestServiceManager(TestCase):
|
|||
result = service_manager.save_file()
|
||||
|
||||
# THEN: The "save_as" method is called to save the service
|
||||
self.assertTrue(result)
|
||||
assert result is True
|
||||
mocked_save_file_as.assert_called_with()
|
||||
|
||||
@patch('openlp.core.ui.servicemanager.shutil.copy')
|
||||
|
@ -678,7 +677,7 @@ class TestServiceManager(TestCase):
|
|||
result = service_manager.save_local_file()
|
||||
|
||||
# THEN: The "save_as" method is called to save the service
|
||||
self.assertTrue(result)
|
||||
assert result is True
|
||||
mocked_save_file_as.assert_called_with()
|
||||
|
||||
@patch('openlp.core.ui.servicemanager.ServiceManager.regenerate_service_items')
|
||||
|
@ -699,8 +698,8 @@ class TestServiceManager(TestCase):
|
|||
service_manager.theme_change()
|
||||
|
||||
# THEN: The the theme toolbar should not be visible
|
||||
self.assertFalse(service_manager.toolbar.actions['theme_combo_box'].isVisible(),
|
||||
'The visibility should be False')
|
||||
assert service_manager.toolbar.actions['theme_combo_box'].isVisible() is False, \
|
||||
'The visibility should be False'
|
||||
|
||||
@patch('openlp.core.ui.servicemanager.ServiceManager.regenerate_service_items')
|
||||
def test_theme_change_service(self, mocked_regenerate_service_items):
|
||||
|
@ -720,8 +719,8 @@ class TestServiceManager(TestCase):
|
|||
service_manager.theme_change()
|
||||
|
||||
# THEN: The the theme toolbar should be visible
|
||||
self.assertTrue(service_manager.toolbar.actions['theme_combo_box'].isVisible(),
|
||||
'The visibility should be True')
|
||||
assert service_manager.toolbar.actions['theme_combo_box'].isVisible() is True, \
|
||||
'The visibility should be True'
|
||||
|
||||
@patch('openlp.core.ui.servicemanager.ServiceManager.regenerate_service_items')
|
||||
def test_theme_change_song(self, mocked_regenerate_service_items):
|
||||
|
@ -741,5 +740,5 @@ class TestServiceManager(TestCase):
|
|||
service_manager.theme_change()
|
||||
|
||||
# THEN: The the theme toolbar should be visible
|
||||
self.assertTrue(service_manager.toolbar.actions['theme_combo_box'].isVisible(),
|
||||
'The visibility should be True')
|
||||
assert service_manager.toolbar.actions['theme_combo_box'].isVisible() is True, \
|
||||
'The visibility should be True'
|
||||
|
|
|
@ -57,7 +57,7 @@ class TestSettingsForm(TestCase):
|
|||
|
||||
# THEN: The general tab should have been inserted into the stacked layout and an item inserted into the list
|
||||
mocked_add_widget.assert_called_with(general_tab)
|
||||
self.assertEqual(1, mocked_add_item.call_count, 'addItem should have been called')
|
||||
assert 1 == mocked_add_item.call_count, 'addItem should have been called'
|
||||
|
||||
def test_insert_tab_not_visible(self):
|
||||
"""
|
||||
|
@ -75,7 +75,7 @@ class TestSettingsForm(TestCase):
|
|||
|
||||
# THEN: The general tab should have been inserted, but no list item should have been inserted into the list
|
||||
mocked_add_widget.assert_called_with(general_tab)
|
||||
self.assertEqual(0, mocked_add_item.call_count, 'addItem should not have been called')
|
||||
assert 0 == mocked_add_item.call_count, 'addItem should not have been called'
|
||||
|
||||
def test_accept_with_inactive_plugins(self):
|
||||
"""
|
||||
|
@ -107,7 +107,7 @@ class TestSettingsForm(TestCase):
|
|||
|
||||
# THEN: The general tab's save() method should have been called, but not the themes tab
|
||||
mocked_general_save.assert_called_with()
|
||||
self.assertEqual(0, mocked_theme_save.call_count, 'The Themes tab\'s save() should not have been called')
|
||||
assert 0 == mocked_theme_save.call_count, 'The Themes tab\'s save() should not have been called'
|
||||
|
||||
def test_list_item_changed_invalid_item(self):
|
||||
"""
|
||||
|
@ -128,7 +128,7 @@ class TestSettingsForm(TestCase):
|
|||
settings_form.list_item_changed(100)
|
||||
|
||||
# THEN: The rest of the method should not have been called
|
||||
self.assertEqual(0, mocked_count.call_count, 'The count method of the stacked layout should not be called')
|
||||
assert 0 == mocked_count.call_count, 'The count method of the stacked layout should not be called'
|
||||
|
||||
def test_reject_with_inactive_items(self):
|
||||
"""
|
||||
|
@ -158,7 +158,7 @@ class TestSettingsForm(TestCase):
|
|||
|
||||
# THEN: The general tab's cancel() method should have been called, but not the themes tab
|
||||
mocked_general_cancel.assert_called_with()
|
||||
self.assertEqual(0, mocked_theme_cancel.call_count, 'The Themes tab\'s cancel() should not have been called')
|
||||
assert 0 == mocked_theme_cancel.call_count, 'The Themes tab\'s cancel() should not have been called'
|
||||
|
||||
def test_register_post_process(self):
|
||||
"""
|
||||
|
|
|
@ -29,12 +29,18 @@ from PyQt5 import QtCore, QtGui
|
|||
|
||||
from openlp.core.common.registry import Registry
|
||||
from openlp.core.lib import ServiceItemAction
|
||||
from openlp.core.ui import SlideController, LiveController, PreviewController
|
||||
from openlp.core.ui.slidecontroller import InfoLabel, WIDE_MENU, NON_TEXT_MENU
|
||||
from openlp.core.ui.slidecontroller import InfoLabel, SlideController, LiveController, PreviewController, \
|
||||
NON_TEXT_MENU, WIDE_MENU
|
||||
|
||||
|
||||
class TestSlideController(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
Set up the components need for all tests.
|
||||
"""
|
||||
Registry.create()
|
||||
|
||||
def test_initial_slide_controller(self):
|
||||
"""
|
||||
Test the initial slide controller state .
|
||||
|
@ -44,7 +50,7 @@ class TestSlideController(TestCase):
|
|||
|
||||
# WHEN: the default controller is built.
|
||||
# THEN: The controller should not be a live controller.
|
||||
self.assertEqual(slide_controller.is_live, False, 'The base slide controller should not be a live controller')
|
||||
assert slide_controller.is_live is False, 'The base slide controller should not be a live controller'
|
||||
|
||||
def test_text_service_item_blank(self):
|
||||
"""
|
||||
|
@ -121,8 +127,8 @@ class TestSlideController(TestCase):
|
|||
|
||||
# THEN: Only on_blank_display() should have been called with an argument of True
|
||||
mocked_on_blank_display.assert_called_once_with(True)
|
||||
self.assertEqual(0, mocked_on_theme_display.call_count, 'on_theme_display should not have been called')
|
||||
self.assertEqual(0, mocked_on_hide_display.call_count, 'on_hide_display should not have been called')
|
||||
assert 0 == mocked_on_theme_display.call_count, 'on_theme_display should not have been called'
|
||||
assert 0 == mocked_on_hide_display.call_count, 'on_hide_display should not have been called'
|
||||
|
||||
def test_toggle_display_hide(self):
|
||||
"""
|
||||
|
@ -142,8 +148,8 @@ class TestSlideController(TestCase):
|
|||
|
||||
# THEN: Only on_blank_display() should have been called with an argument of True
|
||||
mocked_on_blank_display.assert_called_once_with(True)
|
||||
self.assertEqual(0, mocked_on_theme_display.call_count, 'on_theme_display should not have been called')
|
||||
self.assertEqual(0, mocked_on_hide_display.call_count, 'on_hide_display should not have been called')
|
||||
assert 0 == mocked_on_theme_display.call_count, 'on_theme_display should not have been called'
|
||||
assert 0 == mocked_on_hide_display.call_count, 'on_hide_display should not have been called'
|
||||
|
||||
def test_toggle_display_theme(self):
|
||||
"""
|
||||
|
@ -163,8 +169,8 @@ class TestSlideController(TestCase):
|
|||
|
||||
# THEN: Only on_theme_display() should have been called with an argument of True
|
||||
mocked_on_theme_display.assert_called_once_with(True)
|
||||
self.assertEqual(0, mocked_on_blank_display.call_count, 'on_blank_display should not have been called')
|
||||
self.assertEqual(0, mocked_on_hide_display.call_count, 'on_hide_display should not have been called')
|
||||
assert 0 == mocked_on_blank_display.call_count, 'on_blank_display should not have been called'
|
||||
assert 0 == mocked_on_hide_display.call_count, 'on_hide_display should not have been called'
|
||||
|
||||
def test_toggle_display_desktop(self):
|
||||
"""
|
||||
|
@ -184,8 +190,8 @@ class TestSlideController(TestCase):
|
|||
|
||||
# THEN: Only on_hide_display() should have been called with an argument of True
|
||||
mocked_on_hide_display.assert_called_once_with(True)
|
||||
self.assertEqual(0, mocked_on_blank_display.call_count, 'on_blank_display should not have been called')
|
||||
self.assertEqual(0, mocked_on_theme_display.call_count, 'on_theme_display should not have been called')
|
||||
assert 0 == mocked_on_blank_display.call_count, 'on_blank_display should not have been called'
|
||||
assert 0 == mocked_on_theme_display.call_count, 'on_theme_display should not have been called'
|
||||
|
||||
def test_toggle_display_show(self):
|
||||
"""
|
||||
|
@ -348,7 +354,7 @@ class TestSlideController(TestCase):
|
|||
|
||||
# THEN: The value of slide_limits should be 10
|
||||
mocked_value.assert_called_once_with('advanced/slide limits')
|
||||
self.assertEqual(10, slide_controller.slide_limits, 'Slide limits should have been updated to 10')
|
||||
assert 10 == slide_controller.slide_limits, 'Slide limits should have been updated to 10'
|
||||
|
||||
def test_enable_tool_bar_live(self):
|
||||
"""
|
||||
|
@ -368,7 +374,7 @@ class TestSlideController(TestCase):
|
|||
|
||||
# THEN: The enable_live_tool_bar() method is called, not enable_preview_tool_bar()
|
||||
mocked_enable_live_tool_bar.assert_called_once_with(mocked_service_item)
|
||||
self.assertEqual(0, mocked_enable_preview_tool_bar.call_count, 'The preview method should not have been called')
|
||||
assert 0 == mocked_enable_preview_tool_bar.call_count, 'The preview method should not have been called'
|
||||
|
||||
def test_enable_tool_bar_preview(self):
|
||||
"""
|
||||
|
@ -388,7 +394,7 @@ class TestSlideController(TestCase):
|
|||
|
||||
# THEN: The enable_preview_tool_bar() method is called, not enable_live_tool_bar()
|
||||
mocked_enable_preview_tool_bar.assert_called_once_with(mocked_service_item)
|
||||
self.assertEqual(0, mocked_enable_live_tool_bar.call_count, 'The live method should not have been called')
|
||||
assert 0 == mocked_enable_live_tool_bar.call_count, 'The live method should not have been called'
|
||||
|
||||
def test_refresh_service_item_text(self):
|
||||
"""
|
||||
|
@ -409,7 +415,7 @@ class TestSlideController(TestCase):
|
|||
|
||||
# THEN: The item should be re-processed
|
||||
mocked_service_item.is_text.assert_called_once_with()
|
||||
self.assertEqual(0, mocked_service_item.is_image.call_count, 'is_image should not have been called')
|
||||
assert 0 == mocked_service_item.is_image.call_count, 'is_image should not have been called'
|
||||
mocked_service_item.render.assert_called_once_with()
|
||||
mocked_process_item.assert_called_once_with(mocked_service_item, 5)
|
||||
|
||||
|
@ -456,9 +462,8 @@ class TestSlideController(TestCase):
|
|||
# THEN: The item should be re-processed
|
||||
mocked_service_item.is_text.assert_called_once_with()
|
||||
mocked_service_item.is_image.assert_called_once_with()
|
||||
self.assertEqual(0, mocked_service_item.render.call_count, 'The render() method should not have been called')
|
||||
self.assertEqual(0, mocked_process_item.call_count,
|
||||
'The mocked_process_item() method should not have been called')
|
||||
assert 0 == mocked_service_item.render.call_count, 'The render() method should not have been called'
|
||||
assert 0 == mocked_process_item.call_count, 'The mocked_process_item() method should not have been called'
|
||||
|
||||
def test_add_service_item_with_song_edit(self):
|
||||
"""
|
||||
|
@ -477,7 +482,7 @@ class TestSlideController(TestCase):
|
|||
|
||||
# THEN: The item is processed, the slide number is correct, and the song is not editable (or something)
|
||||
mocked_item.render.assert_called_once_with()
|
||||
self.assertFalse(slide_controller.song_edit, 'song_edit should be False')
|
||||
assert slide_controller.song_edit is False, 'song_edit should be False'
|
||||
mocked_process_item.assert_called_once_with(mocked_item, 2)
|
||||
|
||||
def test_add_service_item_without_song_edit(self):
|
||||
|
@ -497,7 +502,7 @@ class TestSlideController(TestCase):
|
|||
|
||||
# THEN: The item is processed, the slide number is correct, and the song is not editable (or something)
|
||||
mocked_item.render.assert_called_once_with()
|
||||
self.assertFalse(slide_controller.song_edit, 'song_edit should be False')
|
||||
assert slide_controller.song_edit is False, 'song_edit should be False'
|
||||
mocked_process_item.assert_called_once_with(mocked_item, 0)
|
||||
|
||||
def test_replace_service_manager_item_different_items(self):
|
||||
|
@ -517,9 +522,9 @@ class TestSlideController(TestCase):
|
|||
slide_controller.replace_service_manager_item(mocked_item)
|
||||
|
||||
# THEN: The service item should not be processed
|
||||
self.assertEqual(0, mocked_process_item.call_count, 'The _process_item() method should not have been called')
|
||||
self.assertEqual(0, mocked_preview_widget.current_slide_number.call_count,
|
||||
'The preview_widgetcurrent_slide_number.() method should not have been called')
|
||||
assert 0 == mocked_process_item.call_count, 'The _process_item() method should not have been called'
|
||||
assert 0 == mocked_preview_widget.current_slide_number.call_count, \
|
||||
'The preview_widget current_slide_number.() method should not have been called'
|
||||
|
||||
def test_replace_service_manager_item_same_item(self):
|
||||
"""
|
||||
|
@ -583,7 +588,7 @@ class TestSlideController(TestCase):
|
|||
slide_controller.on_slide_selected_index([10])
|
||||
|
||||
# THEN: It should have exited early
|
||||
self.assertEqual(0, mocked_item.is_command.call_count, 'The service item should have not been called')
|
||||
assert 0 == mocked_item.is_command.call_count, 'The service item should have not been called'
|
||||
|
||||
@patch.object(Registry, 'execute')
|
||||
def test_on_slide_selected_index_service_item_command(self, mocked_execute):
|
||||
|
@ -612,8 +617,8 @@ class TestSlideController(TestCase):
|
|||
mocked_item.is_command.assert_called_once_with()
|
||||
mocked_execute.assert_called_once_with('mocked item_slide', [mocked_item, True, 9])
|
||||
mocked_update_preview.assert_called_once_with()
|
||||
self.assertEqual(0, mocked_preview_widget.change_slide.call_count, 'Change slide should not have been called')
|
||||
self.assertEqual(0, mocked_slide_selected.call_count, 'slide_selected should not have been called')
|
||||
assert 0 == mocked_preview_widget.change_slide.call_count, 'Change slide should not have been called'
|
||||
assert 0 == mocked_slide_selected.call_count, 'slide_selected should not have been called'
|
||||
|
||||
@patch.object(Registry, 'execute')
|
||||
def test_on_slide_selected_index_service_item_not_command(self, mocked_execute):
|
||||
|
@ -639,8 +644,8 @@ class TestSlideController(TestCase):
|
|||
|
||||
# THEN: It should have sent a notification
|
||||
mocked_item.is_command.assert_called_once_with()
|
||||
self.assertEqual(0, mocked_execute.call_count, 'Execute should not have been called')
|
||||
self.assertEqual(0, mocked_update_preview.call_count, 'Update preview should not have been called')
|
||||
assert 0 == mocked_execute.call_count, 'Execute should not have been called'
|
||||
assert 0 == mocked_update_preview.call_count, 'Update preview should not have been called'
|
||||
mocked_preview_widget.change_slide.assert_called_once_with(7)
|
||||
mocked_slide_selected.assert_called_once_with()
|
||||
|
||||
|
@ -685,9 +690,9 @@ class TestSlideController(TestCase):
|
|||
slide_controller._process_item(mocked_media_item, 0)
|
||||
|
||||
# THEN: Registry.execute should have been called to stop the presentation
|
||||
self.assertEqual(2, mocked_execute.call_count, 'Execute should have been called 2 times')
|
||||
self.assertEqual('mocked_presentation_item_stop', mocked_execute.call_args_list[1][0][0],
|
||||
'The presentation should have been stopped.')
|
||||
assert 2 == mocked_execute.call_count, 'Execute should have been called 2 times'
|
||||
assert 'mocked_presentation_item_stop' == mocked_execute.call_args_list[1][0][0], \
|
||||
'The presentation should have been stopped.'
|
||||
|
||||
def test_live_stolen_focus_shortcuts(self):
|
||||
"""
|
||||
|
@ -737,8 +742,8 @@ class TestSlideController(TestCase):
|
|||
slide_controller.on_preview_double_click()
|
||||
|
||||
# THEN: The call to addActions should be correct
|
||||
self.assertEqual(1, slide_controller.on_go_live.call_count, 'on_go_live should have been called once.')
|
||||
self.assertEqual(0, slide_controller.on_preview_add_to_service.call_count, 'Should have not been called.')
|
||||
assert 1 == slide_controller.on_go_live.call_count, 'on_go_live should have been called once.'
|
||||
assert 0 == slide_controller.on_preview_add_to_service.call_count, 'Should have not been called.'
|
||||
|
||||
@patch('openlp.core.ui.slidecontroller.Settings')
|
||||
def test_on_preview_double_click_add_to_service(self, MockedSettings):
|
||||
|
@ -760,8 +765,8 @@ class TestSlideController(TestCase):
|
|||
slide_controller.on_preview_double_click()
|
||||
|
||||
# THEN: The call to addActions should be correct
|
||||
self.assertEqual(0, slide_controller.on_go_live.call_count, 'on_go_live Should have not been called.')
|
||||
self.assertEqual(1, slide_controller.on_preview_add_to_service.call_count, 'Should have been called once.')
|
||||
assert 0 == slide_controller.on_go_live.call_count, 'on_go_live Should have not been called.'
|
||||
assert 1 == slide_controller.on_preview_add_to_service.call_count, 'Should have been called once.'
|
||||
|
||||
@patch(u'openlp.core.ui.slidecontroller.SlideController.image_manager')
|
||||
@patch(u'PyQt5.QtCore.QTimer.singleShot')
|
||||
|
@ -800,11 +805,10 @@ class TestSlideController(TestCase):
|
|||
slide_controller.update_preview()
|
||||
|
||||
# THEN: A screen_grab should have been called
|
||||
self.assertEqual(0, slide_controller.slide_preview.setPixmap.call_count, 'setPixmap should not be called')
|
||||
self.assertEqual(0, slide_controller.display.preview.call_count, 'display.preview() should not be called')
|
||||
self.assertEqual(2, mocked_singleShot.call_count,
|
||||
'Timer to grab_maindisplay should have been called 2 times')
|
||||
self.assertEqual(0, mocked_image_manager.get_image.call_count, 'image_manager not be called')
|
||||
assert 0 == slide_controller.slide_preview.setPixmap.call_count, 'setPixmap should not be called'
|
||||
assert 0 == slide_controller.display.preview.call_count, 'display.preview() should not be called'
|
||||
assert 2 == mocked_singleShot.call_count, 'Timer to grab_maindisplay should have been called 2 times'
|
||||
assert 0 == mocked_image_manager.get_image.call_count, 'image_manager not be called'
|
||||
|
||||
@patch(u'openlp.core.ui.slidecontroller.SlideController.image_manager')
|
||||
@patch(u'PyQt5.QtCore.QTimer.singleShot')
|
||||
|
@ -843,10 +847,10 @@ class TestSlideController(TestCase):
|
|||
slide_controller.update_preview()
|
||||
|
||||
# THEN: setPixmap and the image_manager should have been called
|
||||
self.assertEqual(1, slide_controller.slide_preview.setPixmap.call_count, 'setPixmap should be called')
|
||||
self.assertEqual(0, slide_controller.display.preview.call_count, 'display.preview() should not be called')
|
||||
self.assertEqual(0, mocked_singleShot.call_count, 'Timer to grab_maindisplay should not be called')
|
||||
self.assertEqual(1, mocked_image_manager.get_image.call_count, 'image_manager should be called')
|
||||
assert 1 == slide_controller.slide_preview.setPixmap.call_count, 'setPixmap should be called'
|
||||
assert 0 == slide_controller.display.preview.call_count, 'display.preview() should not be called'
|
||||
assert 0 == mocked_singleShot.call_count, 'Timer to grab_maindisplay should not be called'
|
||||
assert 1 == mocked_image_manager.get_image.call_count, 'image_manager should be called'
|
||||
|
||||
@patch(u'openlp.core.ui.slidecontroller.SlideController.image_manager')
|
||||
@patch(u'PyQt5.QtCore.QTimer.singleShot')
|
||||
|
@ -885,10 +889,10 @@ class TestSlideController(TestCase):
|
|||
slide_controller.update_preview()
|
||||
|
||||
# THEN: setPixmap should have been called
|
||||
self.assertEqual(1, slide_controller.slide_preview.setPixmap.call_count, 'setPixmap should be called')
|
||||
self.assertEqual(0, slide_controller.display.preview.call_count, 'display.preview() should not be called')
|
||||
self.assertEqual(0, mocked_singleShot.call_count, 'Timer to grab_maindisplay should not be called')
|
||||
self.assertEqual(0, mocked_image_manager.get_image.call_count, 'image_manager should not be called')
|
||||
assert 1 == slide_controller.slide_preview.setPixmap.call_count, 'setPixmap should be called'
|
||||
assert 0 == slide_controller.display.preview.call_count, 'display.preview() should not be called'
|
||||
assert 0 == mocked_singleShot.call_count, 'Timer to grab_maindisplay should not be called'
|
||||
assert 0 == mocked_image_manager.get_image.call_count, 'image_manager should not be called'
|
||||
|
||||
@patch(u'openlp.core.ui.slidecontroller.SlideController.image_manager')
|
||||
@patch(u'PyQt5.QtCore.QTimer.singleShot')
|
||||
|
@ -927,10 +931,10 @@ class TestSlideController(TestCase):
|
|||
slide_controller.update_preview()
|
||||
|
||||
# THEN: setPixmap and display.preview should have been called
|
||||
self.assertEqual(1, slide_controller.slide_preview.setPixmap.call_count, 'setPixmap should be called')
|
||||
self.assertEqual(1, slide_controller.display.preview.call_count, 'display.preview() should be called')
|
||||
self.assertEqual(0, mocked_singleShot.call_count, 'Timer to grab_maindisplay should not be called')
|
||||
self.assertEqual(0, mocked_image_manager.get_image.call_count, 'image_manager should not be called')
|
||||
assert 1 == slide_controller.slide_preview.setPixmap.call_count, 'setPixmap should be called'
|
||||
assert 1 == slide_controller.display.preview.call_count, 'display.preview() should be called'
|
||||
assert 0 == mocked_singleShot.call_count, 'Timer to grab_maindisplay should not be called'
|
||||
assert 0 == mocked_image_manager.get_image.call_count, 'image_manager should not be called'
|
||||
|
||||
|
||||
class TestInfoLabel(TestCase):
|
||||
|
@ -1023,7 +1027,7 @@ class TestLiveController(TestCase):
|
|||
|
||||
# WHEN: the default controller is built.
|
||||
# THEN: The controller should not be a live controller.
|
||||
self.assertEqual(live_controller.is_live, True, 'The slide controller should be a live controller')
|
||||
assert live_controller.is_live is True, 'The slide controller should be a live controller'
|
||||
|
||||
|
||||
class TestPreviewLiveController(TestCase):
|
||||
|
@ -1038,4 +1042,4 @@ class TestPreviewLiveController(TestCase):
|
|||
|
||||
# WHEN: the default controller is built.
|
||||
# THEN: The controller should not be a live controller.
|
||||
self.assertEqual(preview_controller.is_live, False, 'The slide controller should be a Preview controller')
|
||||
assert preview_controller.is_live is False, 'The slide controller should be a Preview controller'
|
||||
|
|
|
@ -49,5 +49,5 @@ class TestThemeManager(TestCase):
|
|||
self.instance.on_image_path_edit_path_changed(Path('/', 'new', 'pat.h'))
|
||||
|
||||
# THEN: The theme background file should be set and `set_background_page_values` should have been called
|
||||
self.assertEqual(self.instance.theme.background_filename, Path('/', 'new', 'pat.h'))
|
||||
assert self.instance.theme.background_filename == Path('/', 'new', 'pat.h')
|
||||
mocked_set_background_page_values.assert_called_once_with()
|
||||
|
|
|
@ -80,7 +80,7 @@ class TestThemeManager(TestCase):
|
|||
|
||||
# WHEN: the default theme manager is built.
|
||||
# THEN: The the controller should be registered in the registry.
|
||||
self.assertIsNotNone(Registry().get('theme_manager'), 'The base theme manager should be registered')
|
||||
assert Registry().get('theme_manager') is not None, 'The base theme manager should be registered'
|
||||
|
||||
@patch('openlp.core.ui.thememanager.copyfile')
|
||||
@patch('openlp.core.ui.thememanager.create_paths')
|
||||
|
@ -147,8 +147,8 @@ class TestThemeManager(TestCase):
|
|||
theme_manager._write_theme(mocked_theme, None, None)
|
||||
|
||||
# THEN: It should have been created
|
||||
self.assertTrue(os.path.exists(os.path.join(self.temp_folder, 'theme 愛 name', 'theme 愛 name.json')),
|
||||
'Theme with special characters should have been created!')
|
||||
assert os.path.exists(os.path.join(self.temp_folder, 'theme 愛 name', 'theme 愛 name.json')) is True, \
|
||||
'Theme with special characters should have been created!'
|
||||
|
||||
@patch('openlp.core.ui.thememanager.QtWidgets.QMessageBox.question', return_value=QtWidgets.QMessageBox.Yes)
|
||||
@patch('openlp.core.ui.thememanager.translate')
|
||||
|
@ -206,8 +206,8 @@ class TestThemeManager(TestCase):
|
|||
theme_manager.unzip_theme(theme_file, folder_path)
|
||||
|
||||
# THEN: Files should be unpacked
|
||||
self.assertTrue((folder_path / 'Moss on tree' / 'Moss on tree.xml').exists())
|
||||
self.assertEqual(mocked_critical_error_message_box.call_count, 0, 'No errors should have happened')
|
||||
assert (folder_path / 'Moss on tree' / 'Moss on tree.xml').exists() is True
|
||||
assert mocked_critical_error_message_box.call_count == 0, 'No errors should have happened'
|
||||
folder_path.rmtree()
|
||||
|
||||
def test_unzip_theme_invalid_version(self):
|
||||
|
@ -228,4 +228,4 @@ class TestThemeManager(TestCase):
|
|||
theme_manager.unzip_theme('theme.file', 'folder')
|
||||
|
||||
# THEN: The critical_error_message_box should have been called
|
||||
self.assertEqual(mocked_critical_error_message_box.call_count, 1, 'Should have been called once')
|
||||
assert mocked_critical_error_message_box.call_count == 1, 'Should have been called once'
|
||||
|
|
|
@ -51,7 +51,7 @@ class TestThemeTab(TestCase, TestMixin):
|
|||
themes_tab = ThemesTab(settings_form)
|
||||
|
||||
# THEN:
|
||||
self.assertEqual("Themes", themes_tab.tab_title, 'The tab title should be Theme')
|
||||
assert "Themes" == themes_tab.tab_title, 'The tab title should be Theme'
|
||||
|
||||
def test_save_triggers_processes_true(self):
|
||||
"""
|
||||
|
@ -66,7 +66,7 @@ class TestThemeTab(TestCase, TestMixin):
|
|||
themes_tab.save()
|
||||
|
||||
# THEN: we should have two post save processed to run
|
||||
self.assertEqual(1, len(settings_form.processes), 'One post save processes should be created')
|
||||
assert 1 == len(settings_form.processes), 'One post save processes should be created'
|
||||
|
||||
def test_save_triggers_processes_false(self):
|
||||
"""
|
||||
|
@ -81,4 +81,4 @@ class TestThemeTab(TestCase, TestMixin):
|
|||
themes_tab.save()
|
||||
|
||||
# THEN: we should have two post save processed to run
|
||||
self.assertEqual(0, len(settings_form.processes), 'No post save processes should be created')
|
||||
assert 0 == len(settings_form.processes), 'No post save processes should be created'
|
||||
|
|
|
@ -60,8 +60,7 @@ class TestColorDialog(TestCase):
|
|||
widget = ColorButton()
|
||||
|
||||
# THEN: The widget __init__ method should have the correct properties and methods called
|
||||
self.assertEqual(widget.parent, None,
|
||||
'The parent should be the same as the one that the class was instianted with')
|
||||
assert widget.parent is None, 'The parent should be the same as the one that the class was instianted with'
|
||||
self.mocked_change_color.assert_called_once_with('#ffffff')
|
||||
mocked_set_tool_tip.assert_called_once_with('Tool Tip Text')
|
||||
self.mocked_clicked.connect.assert_called_once_with(widget.on_clicked)
|
||||
|
@ -80,7 +79,7 @@ class TestColorDialog(TestCase):
|
|||
widget.change_color('#000000')
|
||||
|
||||
# THEN: The _color attribute should be set to #000000 and setStyleSheet should have been called twice
|
||||
self.assertEqual(widget._color, '#000000', '_color should have been set to #000000')
|
||||
assert widget._color == '#000000', '_color should have been set to #000000'
|
||||
mocked_set_style_sheet.assert_has_calls(
|
||||
[call('background-color: #ffffff'), call('background-color: #000000')])
|
||||
|
||||
|
@ -98,7 +97,7 @@ class TestColorDialog(TestCase):
|
|||
value = widget.color
|
||||
|
||||
# THEN: The value set in _color should be returned
|
||||
self.assertEqual(value, '#000000', 'The value returned should be equal to the one we set')
|
||||
assert value == '#000000', 'The value returned should be equal to the one we set'
|
||||
|
||||
# @patch('openlp.core.widgets.buttons.ColorButton.__init__', **{'return_value': None})
|
||||
def test_color_setter(self):
|
||||
|
@ -130,10 +129,10 @@ class TestColorDialog(TestCase):
|
|||
widget.on_clicked()
|
||||
|
||||
# THEN: change_color should not have been called and the colorChanged signal should not have been emitted
|
||||
self.assertFalse(self.mocked_change_color.called,
|
||||
'change_color should not have been called with an invalid color')
|
||||
self.assertFalse(self.mocked_color_changed.emit.called,
|
||||
'colorChange signal should not have been emitted with an invalid color')
|
||||
assert self.mocked_change_color.called is False, \
|
||||
'change_color should not have been called with an invalid color'
|
||||
assert self.mocked_color_changed.emit.called is False, \
|
||||
'colorChange signal should not have been emitted with an invalid color'
|
||||
|
||||
def test_on_clicked_same_color(self):
|
||||
"""
|
||||
|
@ -152,10 +151,10 @@ class TestColorDialog(TestCase):
|
|||
widget.on_clicked()
|
||||
|
||||
# THEN: change_color should not have been called and the colorChanged signal should not have been emitted
|
||||
self.assertFalse(self.mocked_change_color.called,
|
||||
'change_color should not have been called when the color has not changed')
|
||||
self.assertFalse(self.mocked_color_changed.emit.called,
|
||||
'colorChange signal should not have been emitted when the color has not changed')
|
||||
assert self.mocked_change_color.called is False, \
|
||||
'change_color should not have been called when the color has not changed'
|
||||
assert self.mocked_color_changed.emit.called is False, \
|
||||
'colorChange signal should not have been emitted when the color has not changed'
|
||||
|
||||
def test_on_clicked_new_color(self):
|
||||
"""
|
||||
|
|
|
@ -22,7 +22,7 @@ class TestFileDialogPatches(TestCase):
|
|||
instance = FileDialog()
|
||||
|
||||
# THEN: The instance should be an instance of QFileDialog
|
||||
self.assertIsInstance(instance, QtWidgets.QFileDialog)
|
||||
assert isinstance(instance, QtWidgets.QFileDialog)
|
||||
|
||||
def test_get_existing_directory_user_abort(self):
|
||||
"""
|
||||
|
@ -34,7 +34,7 @@ class TestFileDialogPatches(TestCase):
|
|||
result = FileDialog.getExistingDirectory()
|
||||
|
||||
# THEN: The result should be None
|
||||
self.assertEqual(result, None)
|
||||
assert result is None
|
||||
|
||||
def test_get_existing_directory_user_accepts(self):
|
||||
"""
|
||||
|
@ -47,7 +47,7 @@ class TestFileDialogPatches(TestCase):
|
|||
result = FileDialog.getExistingDirectory()
|
||||
|
||||
# THEN: getExistingDirectory() should return a Path object pointing to the chosen file
|
||||
self.assertEqual(result, Path('test', 'dir'))
|
||||
assert result == Path('test', 'dir')
|
||||
|
||||
def test_get_existing_directory_param_order(self):
|
||||
"""
|
||||
|
@ -77,7 +77,7 @@ class TestFileDialogPatches(TestCase):
|
|||
result = FileDialog.getOpenFileName()
|
||||
|
||||
# THEN: First value should be None
|
||||
self.assertEqual(result[0], None)
|
||||
assert result[0] is None
|
||||
|
||||
def test_get_open_file_name_user_accepts(self):
|
||||
"""
|
||||
|
@ -92,7 +92,7 @@ class TestFileDialogPatches(TestCase):
|
|||
|
||||
# THEN: getOpenFileName() should return a tuple with the first value set to a Path object pointing to the
|
||||
# chosen file
|
||||
self.assertEqual(result[0], Path('test', 'chosen.file'))
|
||||
assert result[0] == Path('test', 'chosen.file')
|
||||
|
||||
def test_get_open_file_name_selected_filter(self):
|
||||
"""
|
||||
|
@ -104,7 +104,7 @@ class TestFileDialogPatches(TestCase):
|
|||
result = FileDialog.getOpenFileName()
|
||||
|
||||
# THEN: getOpenFileName() should return a tuple with the second value set to a the selected filter
|
||||
self.assertEqual(result[1], 'selected filter')
|
||||
assert result[1] == 'selected filter'
|
||||
|
||||
def test_get_open_file_names_user_abort(self):
|
||||
"""
|
||||
|
@ -117,7 +117,7 @@ class TestFileDialogPatches(TestCase):
|
|||
result = FileDialog.getOpenFileNames()
|
||||
|
||||
# THEN: First value should be an empty list
|
||||
self.assertEqual(result[0], [])
|
||||
assert result[0] == []
|
||||
|
||||
def test_get_open_file_names_user_accepts(self):
|
||||
"""
|
||||
|
@ -132,7 +132,7 @@ class TestFileDialogPatches(TestCase):
|
|||
|
||||
# THEN: getOpenFileNames() should return a tuple with the first value set to a list of Path objects pointing
|
||||
# to the chosen file
|
||||
self.assertEqual(result[0], [Path('test', 'chosen.file1'), Path('test', 'chosen.file2')])
|
||||
assert result[0] == [Path('test', 'chosen.file1'), Path('test', 'chosen.file2')]
|
||||
|
||||
def test_get_open_file_names_selected_filter(self):
|
||||
"""
|
||||
|
@ -145,7 +145,7 @@ class TestFileDialogPatches(TestCase):
|
|||
result = FileDialog.getOpenFileNames()
|
||||
|
||||
# THEN: getOpenFileNames() should return a tuple with the second value set to a the selected filter
|
||||
self.assertEqual(result[1], 'selected filter')
|
||||
assert result[1] == 'selected filter'
|
||||
|
||||
def test_get_save_file_name_user_abort(self):
|
||||
"""
|
||||
|
@ -158,7 +158,7 @@ class TestFileDialogPatches(TestCase):
|
|||
result = FileDialog.getSaveFileName()
|
||||
|
||||
# THEN: First value should be None
|
||||
self.assertEqual(result[0], None)
|
||||
assert result[0] is None
|
||||
|
||||
def test_get_save_file_name_user_accepts(self):
|
||||
"""
|
||||
|
@ -173,7 +173,7 @@ class TestFileDialogPatches(TestCase):
|
|||
|
||||
# THEN: getSaveFileName() should return a tuple with the first value set to a Path object pointing to the
|
||||
# chosen file
|
||||
self.assertEqual(result[0], Path('test', 'chosen.file'))
|
||||
assert result[0] == Path('test', 'chosen.file')
|
||||
|
||||
def test_get_save_file_name_selected_filter(self):
|
||||
"""
|
||||
|
@ -185,4 +185,4 @@ class TestFileDialogPatches(TestCase):
|
|||
result = FileDialog.getSaveFileName()
|
||||
|
||||
# THEN: getSaveFileName() should return a tuple with the second value set to a the selected filter
|
||||
self.assertEqual(result[1], 'selected filter')
|
||||
assert result[1] == 'selected filter'
|
||||
|
|
|
@ -27,9 +27,9 @@ from unittest import TestCase
|
|||
from unittest.mock import MagicMock, PropertyMock, patch
|
||||
|
||||
from openlp.core.common.path import Path
|
||||
from openlp.core.widgets.edits import PathEdit
|
||||
from openlp.core.widgets.enums import PathEditType
|
||||
from openlp.core.widgets.dialogs import FileDialog
|
||||
from openlp.core.widgets.edits import PathEdit
|
||||
|
||||
|
||||
class TestPathEdit(TestCase):
|
||||
|
@ -49,7 +49,7 @@ class TestPathEdit(TestCase):
|
|||
|
||||
# WHEN: Reading the `path` property
|
||||
# THEN: The value that we set should be returned
|
||||
self.assertEqual(self.widget.path, Path('getter', 'test', 'pat.h'))
|
||||
assert self.widget.path == Path('getter', 'test', 'pat.h')
|
||||
|
||||
def test_path_setter(self):
|
||||
"""
|
||||
|
@ -63,7 +63,7 @@ class TestPathEdit(TestCase):
|
|||
|
||||
# THEN: The `_path` instance variable should be set with the test data. The `line_edit` text and tooltip
|
||||
# should have also been set.
|
||||
self.assertEqual(self.widget._path, Path('setter', 'test', 'pat.h'))
|
||||
assert self.widget._path == Path('setter', 'test', 'pat.h')
|
||||
self.widget.line_edit.setToolTip.assert_called_once_with(os.path.join('setter', 'test', 'pat.h'))
|
||||
self.widget.line_edit.setText.assert_called_once_with(os.path.join('setter', 'test', 'pat.h'))
|
||||
|
||||
|
@ -74,7 +74,7 @@ class TestPathEdit(TestCase):
|
|||
# GIVEN: An instance of PathEdit
|
||||
# WHEN: Reading the `path` property
|
||||
# THEN: The default value should be returned
|
||||
self.assertEqual(self.widget.path_type, PathEditType.Files)
|
||||
assert self.widget.path_type == PathEditType.Files
|
||||
|
||||
def test_path_type_setter(self):
|
||||
"""
|
||||
|
@ -88,7 +88,7 @@ class TestPathEdit(TestCase):
|
|||
|
||||
# THEN: The `_path_type` instance variable should be set with the test data and not the default. The
|
||||
# update_button_tool_tips should have been called.
|
||||
self.assertEqual(self.widget._path_type, PathEditType.Directories)
|
||||
assert self.widget._path_type == PathEditType.Directories
|
||||
mocked_update_button_tool_tips.assert_called_once_with()
|
||||
|
||||
def test_update_button_tool_tips_directories(self):
|
||||
|
@ -139,7 +139,7 @@ class TestPathEdit(TestCase):
|
|||
mocked_get_existing_directory.assert_called_once_with(self.widget, 'Select Directory',
|
||||
Path('test', 'path'),
|
||||
FileDialog.ShowDirsOnly)
|
||||
self.assertFalse(mocked_get_open_file_name.called)
|
||||
assert mocked_get_open_file_name.called is False
|
||||
|
||||
def test_on_browse_button_clicked_directory_custom_caption(self):
|
||||
"""
|
||||
|
@ -162,7 +162,7 @@ class TestPathEdit(TestCase):
|
|||
mocked_get_existing_directory.assert_called_once_with(self.widget, 'Directory Caption',
|
||||
Path('test', 'path'),
|
||||
FileDialog.ShowDirsOnly)
|
||||
self.assertFalse(mocked_get_open_file_name.called)
|
||||
assert mocked_get_open_file_name.called is False
|
||||
|
||||
def test_on_browse_button_clicked_file(self):
|
||||
"""
|
||||
|
@ -181,7 +181,7 @@ class TestPathEdit(TestCase):
|
|||
# THEN: The FileDialog.getOpenFileName should have been called with the default caption
|
||||
mocked_get_open_file_name.assert_called_once_with(self.widget, 'Select File', Path('test', 'pat.h'),
|
||||
self.widget.filters)
|
||||
self.assertFalse(mocked_get_existing_directory.called)
|
||||
assert mocked_get_existing_directory.called is False
|
||||
|
||||
def test_on_browse_button_clicked_file_custom_caption(self):
|
||||
"""
|
||||
|
@ -203,7 +203,7 @@ class TestPathEdit(TestCase):
|
|||
# THEN: The FileDialog.getOpenFileName should have been called with the custom caption
|
||||
mocked_get_open_file_name.assert_called_once_with(self.widget, 'File Caption', Path('test', 'pat.h'),
|
||||
self.widget.filters)
|
||||
self.assertFalse(mocked_get_existing_directory.called)
|
||||
assert mocked_get_existing_directory.called is False
|
||||
|
||||
def test_on_browse_button_clicked_user_cancels(self):
|
||||
"""
|
||||
|
@ -219,7 +219,7 @@ class TestPathEdit(TestCase):
|
|||
self.widget.on_browse_button_clicked()
|
||||
|
||||
# THEN: normpath should not have been called
|
||||
self.assertTrue(mocked_get_open_file_name.called)
|
||||
assert mocked_get_open_file_name.called is True
|
||||
|
||||
def test_on_browse_button_clicked_user_accepts(self):
|
||||
"""
|
||||
|
@ -236,8 +236,8 @@ class TestPathEdit(TestCase):
|
|||
self.widget.on_browse_button_clicked()
|
||||
|
||||
# THEN: normpath and `on_new_path` should have been called
|
||||
self.assertTrue(mocked_get_open_file_name.called)
|
||||
self.assertTrue(self.widget.on_new_path.called)
|
||||
assert mocked_get_open_file_name.called is True
|
||||
assert self.widget.on_new_path.called is True
|
||||
|
||||
def test_on_revert_button_clicked(self):
|
||||
"""
|
||||
|
@ -280,7 +280,7 @@ class TestPathEdit(TestCase):
|
|||
self.widget.on_new_path(Path('/old', 'test', 'pat.h'))
|
||||
|
||||
# THEN: The `pathChanged` signal should not be emitted
|
||||
self.assertFalse(self.widget.pathChanged.emit.called)
|
||||
assert self.widget.pathChanged.emit.called is False
|
||||
|
||||
def test_on_new_path_change(self):
|
||||
"""
|
||||
|
|
|
@ -71,8 +71,8 @@ class TestListPreviewWidget(TestCase):
|
|||
list_preview_widget = ListPreviewWidget(None, 1)
|
||||
|
||||
# THEN: The object is not None, and the _setup() method was called.
|
||||
self.assertIsNotNone(list_preview_widget, 'The ListPreviewWidget object should not be None')
|
||||
self.assertEquals(list_preview_widget.screen_ratio, 1, 'Should not be called')
|
||||
assert list_preview_widget is not None, 'The ListPreviewWidget object should not be None'
|
||||
assert list_preview_widget.screen_ratio == 1, 'Should not be called'
|
||||
|
||||
@patch(u'openlp.core.widgets.views.ListPreviewWidget.image_manager')
|
||||
@patch(u'openlp.core.widgets.views.ListPreviewWidget.resizeRowsToContents')
|
||||
|
@ -116,7 +116,7 @@ class TestListPreviewWidget(TestCase):
|
|||
list_preview_widget.replace_service_item(mocked_cmd_service_item, 200, 0)
|
||||
|
||||
# THEN: The ImageManager should be called in the appriopriate manner for each service item.
|
||||
self.assertEquals(mocked_image_manager.get_image.call_count, 4, 'Should be called once for each slide')
|
||||
assert mocked_image_manager.get_image.call_count == 4, 'Should be called once for each slide'
|
||||
calls = [call('TEST1', ImageSource.ImagePlugin), call('TEST2', ImageSource.ImagePlugin),
|
||||
call('TEST3', ImageSource.CommandPlugins), call('TEST4', ImageSource.CommandPlugins)]
|
||||
mocked_image_manager.get_image.assert_has_calls(calls)
|
||||
|
@ -150,8 +150,8 @@ class TestListPreviewWidget(TestCase):
|
|||
|
||||
# THEN: setRowHeight() should not be called, while resizeRowsToContents() should be called twice
|
||||
# (once each in __recalculate_layout and replace_service_item)
|
||||
self.assertEquals(mocked_resizeRowsToContents.call_count, 2, 'Should be called')
|
||||
self.assertEquals(mocked_setRowHeight.call_count, 0, 'Should not be called')
|
||||
assert mocked_resizeRowsToContents.call_count == 2, 'Should be called'
|
||||
assert mocked_setRowHeight.call_count == 0, 'Should not be called'
|
||||
|
||||
@patch(u'openlp.core.widgets.views.ListPreviewWidget.resizeRowsToContents')
|
||||
@patch(u'openlp.core.widgets.views.ListPreviewWidget.setRowHeight')
|
||||
|
@ -185,8 +185,8 @@ class TestListPreviewWidget(TestCase):
|
|||
|
||||
# THEN: resizeRowsToContents() should not be called, while setRowHeight() should be called
|
||||
# twice for each slide.
|
||||
self.assertEquals(mocked_resizeRowsToContents.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(mocked_setRowHeight.call_count, 6, 'Should be called 3 times for each slide')
|
||||
assert mocked_resizeRowsToContents.call_count == 0, 'Should not be called'
|
||||
assert mocked_setRowHeight.call_count == 6, 'Should be called 3 times for each slide'
|
||||
calls = [call(0, 200), call(1, 200), call(0, 400), call(1, 400), call(0, 400), call(1, 400)]
|
||||
mocked_setRowHeight.assert_has_calls(calls)
|
||||
|
||||
|
@ -220,8 +220,8 @@ class TestListPreviewWidget(TestCase):
|
|||
|
||||
# THEN: resizeRowsToContents() should not be called, while setRowHeight() should be called
|
||||
# twice for each slide.
|
||||
self.assertEquals(mocked_resizeRowsToContents.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(mocked_setRowHeight.call_count, 4, 'Should be called twice for each slide')
|
||||
assert mocked_resizeRowsToContents.call_count == 0, 'Should not be called'
|
||||
assert mocked_setRowHeight.call_count == 4, 'Should be called twice for each slide'
|
||||
calls = [call(0, 100), call(1, 100), call(0, 100), call(1, 100)]
|
||||
mocked_setRowHeight.assert_has_calls(calls)
|
||||
|
||||
|
@ -258,8 +258,8 @@ class TestListPreviewWidget(TestCase):
|
|||
|
||||
# THEN: resizeRowsToContents() should not be called, while setRowHeight() should be called
|
||||
# twice for each slide.
|
||||
self.assertEquals(mocked_resizeRowsToContents.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(mocked_setRowHeight.call_count, 6, 'Should be called 3 times for each slide')
|
||||
assert mocked_resizeRowsToContents.call_count == 0, 'Should not be called'
|
||||
assert mocked_setRowHeight.call_count == 6, 'Should be called 3 times for each slide'
|
||||
calls = [call(0, 100), call(1, 100), call(0, 150), call(1, 150), call(0, 100), call(1, 100)]
|
||||
mocked_setRowHeight.assert_has_calls(calls)
|
||||
|
||||
|
@ -295,7 +295,7 @@ class TestListPreviewWidget(TestCase):
|
|||
list_preview_widget.row_resized(0, 100, 150)
|
||||
|
||||
# THEN: self.cellWidget(row, 0).children()[1].setMaximumWidth() should not be called
|
||||
self.assertEquals(mocked_cellWidget_child.setMaximumWidth.call_count, 0, 'Should not be called')
|
||||
assert mocked_cellWidget_child.setMaximumWidth.call_count == 0, 'Should not be called'
|
||||
|
||||
@patch(u'openlp.core.widgets.views.ListPreviewWidget.resizeRowsToContents')
|
||||
@patch(u'openlp.core.widgets.views.ListPreviewWidget.setRowHeight')
|
||||
|
@ -332,7 +332,7 @@ class TestListPreviewWidget(TestCase):
|
|||
list_preview_widget.row_resized(0, 100, 150)
|
||||
|
||||
# THEN: self.cellWidget(row, 0).children()[1].setMaximumWidth() should not be called
|
||||
self.assertEquals(mocked_cellWidget_child.setMaximumWidth.call_count, 0, 'Should not be called')
|
||||
assert mocked_cellWidget_child.setMaximumWidth.call_count == 0, 'Should not be called'
|
||||
|
||||
@patch(u'openlp.core.widgets.views.ListPreviewWidget.resizeRowsToContents')
|
||||
@patch(u'openlp.core.widgets.views.ListPreviewWidget.setRowHeight')
|
||||
|
@ -435,10 +435,10 @@ class TestListPreviewWidget(TestCase):
|
|||
list_preview_widget.change_slide(0)
|
||||
|
||||
# THEN: no further functions should be called
|
||||
self.assertEquals(mocked_slide_count.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(mocked_scrollToItem.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(mocked_selectRow.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(mocked_item.call_count, 0, 'Should not be called')
|
||||
assert mocked_slide_count.call_count == 0, 'Should not be called'
|
||||
assert mocked_scrollToItem.call_count == 0, 'Should not be called'
|
||||
assert mocked_selectRow.call_count == 0, 'Should not be called'
|
||||
assert mocked_item.call_count == 0, 'Should not be called'
|
||||
|
||||
@patch(u'openlp.core.widgets.views.ListPreviewWidget.selectRow')
|
||||
@patch(u'openlp.core.widgets.views.ListPreviewWidget.scrollToItem')
|
||||
|
@ -463,10 +463,10 @@ class TestListPreviewWidget(TestCase):
|
|||
list_preview_widget.change_slide(0)
|
||||
|
||||
# THEN: no further functions should be called
|
||||
self.assertEquals(mocked_slide_count.call_count, 3, 'Should be called')
|
||||
self.assertEquals(mocked_scrollToItem.call_count, 2, 'Should be called')
|
||||
self.assertEquals(mocked_selectRow.call_count, 2, 'Should be called')
|
||||
self.assertEquals(mocked_item.call_count, 2, 'Should be called')
|
||||
assert mocked_slide_count.call_count == 3, 'Should be called'
|
||||
assert mocked_scrollToItem.call_count == 2, 'Should be called'
|
||||
assert mocked_selectRow.call_count == 2, 'Should be called'
|
||||
assert mocked_item.call_count == 2, 'Should be called'
|
||||
calls = [call(0, 0), call(0, 0)]
|
||||
mocked_item.assert_has_calls(calls)
|
||||
|
||||
|
@ -495,10 +495,10 @@ class TestListPreviewWidget(TestCase):
|
|||
list_preview_widget.change_slide(1)
|
||||
|
||||
# THEN: no further functions should be called
|
||||
self.assertEquals(mocked_slide_count.call_count, 3, 'Should be called')
|
||||
self.assertEquals(mocked_scrollToItem.call_count, 3, 'Should be called')
|
||||
self.assertEquals(mocked_selectRow.call_count, 3, 'Should be called')
|
||||
self.assertEquals(mocked_item.call_count, 3, 'Should be called')
|
||||
assert mocked_slide_count.call_count == 3, 'Should be called'
|
||||
assert mocked_scrollToItem.call_count == 3, 'Should be called'
|
||||
assert mocked_selectRow.call_count == 3, 'Should be called'
|
||||
assert mocked_item.call_count == 3, 'Should be called'
|
||||
calls = [call(0, 0), call(1, 0), call(2, 0)]
|
||||
mocked_item.assert_has_calls(calls)
|
||||
|
||||
|
@ -518,7 +518,7 @@ class TestListWidgetWithDnD(TestCase):
|
|||
widget.clear()
|
||||
|
||||
# THEN: The results text should be the standard 'no results' text.
|
||||
self.assertEqual(widget.no_results_text, UiStrings().NoResults)
|
||||
assert widget.no_results_text == UiStrings().NoResults
|
||||
|
||||
def test_clear_search_while_typing(self):
|
||||
"""
|
||||
|
@ -531,7 +531,7 @@ class TestListWidgetWithDnD(TestCase):
|
|||
widget.clear(search_while_typing=True)
|
||||
|
||||
# THEN: The results text should be the 'short results' text.
|
||||
self.assertEqual(widget.no_results_text, UiStrings().ShortResults)
|
||||
assert widget.no_results_text == UiStrings().ShortResults
|
||||
|
||||
def test_all_items_no_list_items(self):
|
||||
"""
|
||||
|
@ -546,8 +546,8 @@ class TestListWidgetWithDnD(TestCase):
|
|||
result = widget.allItems()
|
||||
|
||||
# THEN: An instance of a Generator object should be returned. The generator should not yeild any results
|
||||
self.assertIsInstance(result, GeneratorType)
|
||||
self.assertEqual(list(result), [])
|
||||
assert isinstance(result, GeneratorType)
|
||||
assert list(result) == []
|
||||
|
||||
def test_all_items_list_items(self):
|
||||
"""
|
||||
|
@ -562,8 +562,8 @@ class TestListWidgetWithDnD(TestCase):
|
|||
result = widget.allItems()
|
||||
|
||||
# THEN: An instance of a Generator object should be returned. The generator should not yeild any results
|
||||
self.assertIsInstance(result, GeneratorType)
|
||||
self.assertEqual(list(result), [5, 3])
|
||||
assert isinstance(result, GeneratorType)
|
||||
assert list(result) == [5, 3]
|
||||
|
||||
def test_paint_event(self):
|
||||
"""
|
||||
|
@ -582,7 +582,7 @@ class TestListWidgetWithDnD(TestCase):
|
|||
|
||||
# THEN: The overridden paintEvnet should have been called
|
||||
mocked_paint_event.assert_called_once_with(mocked_event)
|
||||
self.assertFalse(mocked_viewport.called)
|
||||
assert mocked_viewport.called is False
|
||||
|
||||
def test_paint_event_no_items(self):
|
||||
"""
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
Functional tests to test the Impress class and related methods.
|
||||
"""
|
||||
from unittest import TestCase
|
||||
from unittest.mock import MagicMock
|
||||
from unittest.mock import MagicMock, patch
|
||||
import shutil
|
||||
from tempfile import mkdtemp
|
||||
|
||||
|
@ -72,6 +72,60 @@ class TestImpressController(TestCase, TestMixin):
|
|||
self.assertEqual('Impress', controller.name,
|
||||
'The name of the presentation controller should be correct')
|
||||
|
||||
@patch('openlp.plugins.presentations.lib.impresscontroller.log')
|
||||
def test_check_available(self, mocked_log):
|
||||
"""
|
||||
Test `ImpressController.check_available` on Windows
|
||||
"""
|
||||
# GIVEN: An instance of :class:`ImpressController`
|
||||
controller = ImpressController(plugin=self.mock_plugin)
|
||||
|
||||
# WHEN: `check_available` is called on Windows and `get_com_servicemanager` returns None
|
||||
with patch('openlp.plugins.presentations.lib.impresscontroller.is_win', return_value=True), \
|
||||
patch.object(controller, 'get_com_servicemanager', return_value=None) as mocked_get_com_servicemanager:
|
||||
result = controller.check_available()
|
||||
|
||||
# THEN: `check_available` should return False
|
||||
assert mocked_get_com_servicemanager.called is True
|
||||
assert result is False
|
||||
|
||||
@patch('openlp.plugins.presentations.lib.impresscontroller.log')
|
||||
def test_check_available1(self, mocked_log):
|
||||
"""
|
||||
Test `ImpressController.check_available` on Windows
|
||||
"""
|
||||
# GIVEN: An instance of :class:`ImpressController`
|
||||
controller = ImpressController(plugin=self.mock_plugin)
|
||||
|
||||
# WHEN: `check_available` is called on Windows and `get_com_servicemanager` returns an object
|
||||
mocked_com_object = MagicMock()
|
||||
with patch('openlp.plugins.presentations.lib.impresscontroller.is_win', return_value=True), \
|
||||
patch.object(controller, 'get_com_servicemanager', return_value=mocked_com_object) \
|
||||
as mocked_get_com_servicemanager:
|
||||
result = controller.check_available()
|
||||
|
||||
# THEN: `check_available` should return True
|
||||
assert mocked_get_com_servicemanager.called is True
|
||||
assert result is True
|
||||
|
||||
@patch('openlp.plugins.presentations.lib.impresscontroller.log')
|
||||
@patch('openlp.plugins.presentations.lib.impresscontroller.is_win', return_value=False)
|
||||
def test_check_available2(self, mocked_is_win, mocked_log):
|
||||
"""
|
||||
Test `ImpressController.check_available` when not on Windows
|
||||
"""
|
||||
# GIVEN: An instance of :class:`ImpressController`
|
||||
controller = ImpressController(plugin=self.mock_plugin)
|
||||
|
||||
# WHEN: `check_available` is called on Windows and `uno_available` is True
|
||||
with patch('openlp.plugins.presentations.lib.impresscontroller.uno_available', True), \
|
||||
patch.object(controller, 'get_com_servicemanager') as mocked_get_com_servicemanager:
|
||||
result = controller.check_available()
|
||||
|
||||
# THEN: `check_available` should return True
|
||||
assert mocked_get_com_servicemanager.called is False
|
||||
assert result is True
|
||||
|
||||
|
||||
class TestImpressDocument(TestCase):
|
||||
"""
|
||||
|
|
|
@ -108,7 +108,7 @@ class EasyWorshipSongImportLogger(EasyWorshipSongImport):
|
|||
self._title_assignment_list.append(title)
|
||||
|
||||
|
||||
class TestFieldDesc:
|
||||
class DataTestFieldDesc:
|
||||
def __init__(self, name, field_type, size):
|
||||
self.name = name
|
||||
self.field_type = field_type
|
||||
|
@ -120,11 +120,11 @@ CODE_PAGE_MAPPINGS = [
|
|||
(852, 'cp1250'), (737, 'cp1253'), (775, 'cp1257'), (855, 'cp1251'), (857, 'cp1254'),
|
||||
(866, 'cp1251'), (869, 'cp1253'), (862, 'cp1255'), (874, 'cp874')]
|
||||
TEST_FIELD_DESCS = [
|
||||
TestFieldDesc('Title', FieldType.String, 50),
|
||||
TestFieldDesc('Text Percentage Bottom', FieldType.Int16, 2), TestFieldDesc('RecID', FieldType.Int32, 4),
|
||||
TestFieldDesc('Default Background', FieldType.Logical, 1), TestFieldDesc('Words', FieldType.Memo, 250),
|
||||
TestFieldDesc('Words', FieldType.Memo, 250), TestFieldDesc('BK Bitmap', FieldType.Blob, 10),
|
||||
TestFieldDesc('Last Modified', FieldType.Timestamp, 10)]
|
||||
DataTestFieldDesc('Title', FieldType.String, 50),
|
||||
DataTestFieldDesc('Text Percentage Bottom', FieldType.Int16, 2), DataTestFieldDesc('RecID', FieldType.Int32, 4),
|
||||
DataTestFieldDesc('Default Background', FieldType.Logical, 1), DataTestFieldDesc('Words', FieldType.Memo, 250),
|
||||
DataTestFieldDesc('Words', FieldType.Memo, 250), DataTestFieldDesc('BK Bitmap', FieldType.Blob, 10),
|
||||
DataTestFieldDesc('Last Modified', FieldType.Timestamp, 10)]
|
||||
TEST_FIELDS = [
|
||||
b'A Heart Like Thine\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0', 32868, 2147483750,
|
||||
129, b'{\\rtf1\\ansi\\deff0\\deftab254{\\fonttbl{\\f0\\fnil\\fcharset0 Arial;}{\\f1\\fnil\\fcharset0 Verdana;}}'
|
||||
|
|
|
@ -34,7 +34,7 @@ except ImportError:
|
|||
CAN_RUN_TESTS = False
|
||||
|
||||
|
||||
class TestRecord(object):
|
||||
class DBTestRecord(object):
|
||||
"""
|
||||
Microsoft Access Driver is not available on non Microsoft Systems for this reason the :class:`TestRecord` is used
|
||||
to simulate a recordset that would be returned by pyobdc.
|
||||
|
@ -66,12 +66,12 @@ if CAN_RUN_TESTS:
|
|||
self._title_assignment_list.append(title)
|
||||
|
||||
|
||||
RECORDSET_TEST_DATA = [TestRecord(1, 'TITLE', 'Amazing Grace'),
|
||||
TestRecord(1, 'AUTHOR', 'John Newton'),
|
||||
TestRecord(1, 'CCLISONGID', '12345'),
|
||||
TestRecord(1, 'COMMENTS', 'The original version'),
|
||||
TestRecord(1, 'COPY', 'Public Domain'),
|
||||
TestRecord(
|
||||
RECORDSET_TEST_DATA = [DBTestRecord(1, 'TITLE', 'Amazing Grace'),
|
||||
DBTestRecord(1, 'AUTHOR', 'John Newton'),
|
||||
DBTestRecord(1, 'CCLISONGID', '12345'),
|
||||
DBTestRecord(1, 'COMMENTS', 'The original version'),
|
||||
DBTestRecord(1, 'COPY', 'Public Domain'),
|
||||
DBTestRecord(
|
||||
1, 'LYRICS',
|
||||
'Amazing grace! How&crlf;sweet the sound&crlf;That saved a wretch like me!&crlf;'
|
||||
'I once was lost,&crlf;but now am found;&crlf;Was blind, but now I see.&crlf;&crlf;'
|
||||
|
@ -88,8 +88,8 @@ RECORDSET_TEST_DATA = [TestRecord(1, 'TITLE', 'Amazing Grace'),
|
|||
'Shall be forever mine.&crlf;&crlf;When we\'ve been there&crlf;ten thousand years,&crlf;'
|
||||
'Bright shining as the sun,&crlf;We\'ve no less days to&crlf;sing God\'s praise&crlf;'
|
||||
'Than when we\'d first begun.&crlf;&crlf;'),
|
||||
TestRecord(2, 'TITLE', 'Beautiful Garden Of Prayer, The'),
|
||||
TestRecord(
|
||||
DBTestRecord(2, 'TITLE', 'Beautiful Garden Of Prayer, The'),
|
||||
DBTestRecord(
|
||||
2, 'LYRICS',
|
||||
'There\'s a garden where&crlf;Jesus is waiting,&crlf;'
|
||||
'There\'s a place that&crlf;is wondrously fair,&crlf;For it glows with the&crlf;'
|
||||
|
|
Loading…
Reference in New Issue