forked from openlp/openlp
lib done
This commit is contained in:
parent
9f735e0cc5
commit
f76f04994d
@ -69,11 +69,11 @@ class TestMediaManagerItem(TestCase, TestMixin):
|
|||||||
# WHEN: Object is created
|
# WHEN: Object is created
|
||||||
mmi.required_icons()
|
mmi.required_icons()
|
||||||
# THEN: Default icons should be populated
|
# THEN: Default icons should be populated
|
||||||
self.assertFalse(mmi.has_import_icon, 'There should be no import icon by default')
|
assert mmi.has_import_icon is False, 'There should be no import icon by default'
|
||||||
self.assertTrue(mmi.has_new_icon, 'By default a new icon should be present')
|
assert mmi.has_new_icon is True, 'By default a new icon should be present'
|
||||||
self.assertFalse(mmi.has_file_icon, 'There should be no file icon by default')
|
assert mmi.has_file_icon is False, 'There should be no file icon by default'
|
||||||
self.assertTrue(mmi.has_delete_icon, 'By default a delete icon should be present')
|
assert mmi.has_delete_icon is True, '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.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.Settings')
|
||||||
@patch('openlp.core.lib.mediamanageritem.MediaManagerItem.on_live_click')
|
@patch('openlp.core.lib.mediamanageritem.MediaManagerItem.on_live_click')
|
||||||
@ -111,5 +111,5 @@ class TestMediaManagerItem(TestCase, TestMixin):
|
|||||||
mmi.on_double_clicked()
|
mmi.on_double_clicked()
|
||||||
|
|
||||||
# THEN: on_live_click() should have been called
|
# 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')
|
assert 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_preview_click.call_count, 'on_preview_click() should not have been called'
|
||||||
|
@ -64,8 +64,8 @@ class TestPluginManager(TestCase):
|
|||||||
plugin_manager.hook_media_manager()
|
plugin_manager.hook_media_manager()
|
||||||
|
|
||||||
# THEN: The create_media_manager_item() method should have been called
|
# THEN: The create_media_manager_item() method should have been called
|
||||||
self.assertEqual(0, mocked_plugin.create_media_manager_item.call_count,
|
assert 0 == mocked_plugin.create_media_manager_item.call_count, \
|
||||||
'The create_media_manager_item() method should not have been called.')
|
'The create_media_manager_item() method should not have been called.'
|
||||||
|
|
||||||
def test_hook_media_manager_with_active_plugin(self):
|
def test_hook_media_manager_with_active_plugin(self):
|
||||||
"""
|
"""
|
||||||
@ -97,8 +97,8 @@ class TestPluginManager(TestCase):
|
|||||||
plugin_manager.hook_settings_tabs()
|
plugin_manager.hook_settings_tabs()
|
||||||
|
|
||||||
# THEN: The hook_settings_tabs() method should have been called
|
# THEN: The hook_settings_tabs() method should have been called
|
||||||
self.assertEqual(0, mocked_plugin.create_media_manager_item.call_count,
|
assert 0 == mocked_plugin.create_media_manager_item.call_count, \
|
||||||
'The create_media_manager_item() method should not have been called.')
|
'The create_media_manager_item() method should not have been called.'
|
||||||
|
|
||||||
def test_hook_settings_tabs_with_disabled_plugin_and_mocked_form(self):
|
def test_hook_settings_tabs_with_disabled_plugin_and_mocked_form(self):
|
||||||
"""
|
"""
|
||||||
@ -117,10 +117,10 @@ class TestPluginManager(TestCase):
|
|||||||
plugin_manager.hook_settings_tabs()
|
plugin_manager.hook_settings_tabs()
|
||||||
|
|
||||||
# THEN: The create_settings_tab() method should not have been called, but the plugins lists should be the same
|
# 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,
|
assert 0 == mocked_plugin.create_settings_tab.call_count, \
|
||||||
'The create_media_manager_item() method should not have been called.')
|
'The create_media_manager_item() method should not have been called.'
|
||||||
self.assertEqual(mocked_settings_form.plugin_manager.plugins, plugin_manager.plugins,
|
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')
|
'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):
|
def test_hook_settings_tabs_with_active_plugin_and_mocked_form(self):
|
||||||
"""
|
"""
|
||||||
@ -139,10 +139,10 @@ class TestPluginManager(TestCase):
|
|||||||
plugin_manager.hook_settings_tabs()
|
plugin_manager.hook_settings_tabs()
|
||||||
|
|
||||||
# THEN: The create_media_manager_item() method should have been called with the mocked settings form
|
# 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,
|
assert 1 == mocked_plugin.create_settings_tab.call_count, \
|
||||||
'The create_media_manager_item() method should have been called once.')
|
'The create_media_manager_item() method should have been called once.'
|
||||||
self.assertEqual(plugin_manager.plugins, mocked_settings_form.plugin_manager.plugins,
|
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')
|
'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):
|
def test_hook_settings_tabs_with_active_plugin_and_no_form(self):
|
||||||
"""
|
"""
|
||||||
@ -174,8 +174,8 @@ class TestPluginManager(TestCase):
|
|||||||
plugin_manager.hook_import_menu()
|
plugin_manager.hook_import_menu()
|
||||||
|
|
||||||
# THEN: The create_media_manager_item() method should have been called
|
# THEN: The create_media_manager_item() method should have been called
|
||||||
self.assertEqual(0, mocked_plugin.add_import_menu_item.call_count,
|
assert 0 == mocked_plugin.add_import_menu_item.call_count, \
|
||||||
'The add_import_menu_item() method should not have been called.')
|
'The add_import_menu_item() method should not have been called.'
|
||||||
|
|
||||||
def test_hook_import_menu_with_active_plugin(self):
|
def test_hook_import_menu_with_active_plugin(self):
|
||||||
"""
|
"""
|
||||||
@ -207,8 +207,8 @@ class TestPluginManager(TestCase):
|
|||||||
plugin_manager.hook_export_menu()
|
plugin_manager.hook_export_menu()
|
||||||
|
|
||||||
# THEN: The add_export_menu_item() method should not have been called
|
# THEN: The add_export_menu_item() method should not have been called
|
||||||
self.assertEqual(0, mocked_plugin.add_export_menu_item.call_count,
|
assert 0 == mocked_plugin.add_export_menu_item.call_count, \
|
||||||
'The add_export_menu_item() method should not have been called.')
|
'The add_export_menu_item() method should not have been called.'
|
||||||
|
|
||||||
def test_hook_export_menu_with_active_plugin(self):
|
def test_hook_export_menu_with_active_plugin(self):
|
||||||
"""
|
"""
|
||||||
@ -241,8 +241,8 @@ class TestPluginManager(TestCase):
|
|||||||
plugin_manager.hook_upgrade_plugin_settings(settings)
|
plugin_manager.hook_upgrade_plugin_settings(settings)
|
||||||
|
|
||||||
# THEN: The upgrade_settings() method should not have been called
|
# THEN: The upgrade_settings() method should not have been called
|
||||||
self.assertEqual(0, mocked_plugin.upgrade_settings.call_count,
|
assert 0 == mocked_plugin.upgrade_settings.call_count, \
|
||||||
'The upgrade_settings() method should not have been called.')
|
'The upgrade_settings() method should not have been called.'
|
||||||
|
|
||||||
def test_hook_upgrade_plugin_settings_with_active_plugin(self):
|
def test_hook_upgrade_plugin_settings_with_active_plugin(self):
|
||||||
"""
|
"""
|
||||||
@ -275,8 +275,8 @@ class TestPluginManager(TestCase):
|
|||||||
plugin_manager.hook_tools_menu()
|
plugin_manager.hook_tools_menu()
|
||||||
|
|
||||||
# THEN: The add_tools_menu_item() method should have been called
|
# THEN: The add_tools_menu_item() method should have been called
|
||||||
self.assertEqual(0, mocked_plugin.add_tools_menu_item.call_count,
|
assert 0 == mocked_plugin.add_tools_menu_item.call_count, \
|
||||||
'The add_tools_menu_item() method should not have been called.')
|
'The add_tools_menu_item() method should not have been called.'
|
||||||
|
|
||||||
def test_hook_tools_menu_with_active_plugin(self):
|
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
|
# THEN: The is_active() method should have been called, and initialise() method should NOT have been called
|
||||||
mocked_plugin.is_active.assert_called_with()
|
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):
|
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
|
# THEN: The is_active() method should have been called, and initialise() method should NOT have been called
|
||||||
mocked_plugin.is_active.assert_called_with()
|
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):
|
def test_finalise_plugins_with_active_plugin(self):
|
||||||
"""
|
"""
|
||||||
@ -380,7 +380,7 @@ class TestPluginManager(TestCase):
|
|||||||
result = plugin_manager.get_plugin_by_name('Missing Plugin')
|
result = plugin_manager.get_plugin_by_name('Missing Plugin')
|
||||||
|
|
||||||
# THEN: The is_active() and finalise() methods should have been called
|
# 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):
|
def test_get_plugin_by_name_exists(self):
|
||||||
"""
|
"""
|
||||||
@ -396,7 +396,7 @@ class TestPluginManager(TestCase):
|
|||||||
result = plugin_manager.get_plugin_by_name('Mocked Plugin')
|
result = plugin_manager.get_plugin_by_name('Mocked Plugin')
|
||||||
|
|
||||||
# THEN: The is_active() and finalise() methods should have been called
|
# 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):
|
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
|
# THEN: The isActive() method should have been called, and initialise() method should NOT have been called
|
||||||
mocked_plugin.is_active.assert_called_with()
|
mocked_plugin.is_active.assert_called_with()
|
||||||
self.assertEqual(0, mocked_plugin.new_service_created.call_count,
|
assert 0 == mocked_plugin.new_service_created.call_count, \
|
||||||
'The new_service_created() method should not have been called.')
|
'The new_service_created() method should not have been called.'
|
||||||
|
|
||||||
def test_new_service_created_with_active_plugin(self):
|
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 import md5_hash
|
||||||
from openlp.core.common.registry import Registry
|
from openlp.core.common.registry import Registry
|
||||||
|
from openlp.core.common.settings import Settings
|
||||||
from openlp.core.lib import ItemCapabilities, ServiceItem, ServiceItemType, FormattingTags
|
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
|
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']
|
FOOTER = ['Arky Arky (Unknown)', 'Public Domain', 'CCLI 123456']
|
||||||
TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'service'))
|
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):
|
def setUp(self):
|
||||||
"""
|
"""
|
||||||
Set up the Registry
|
Set up the Registry
|
||||||
"""
|
"""
|
||||||
|
self.build_settings()
|
||||||
|
Settings().extend_default_settings(__default_settings__)
|
||||||
Registry.create()
|
Registry.create()
|
||||||
mocked_renderer = MagicMock()
|
mocked_renderer = MagicMock()
|
||||||
mocked_renderer.format_slide.return_value = [VERSE]
|
mocked_renderer.format_slide.return_value = [VERSE]
|
||||||
Registry().register('renderer', mocked_renderer)
|
Registry().register('renderer', mocked_renderer)
|
||||||
Registry().register('image_manager', MagicMock())
|
Registry().register('image_manager', MagicMock())
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
"""
|
||||||
|
Clean up
|
||||||
|
"""
|
||||||
|
self.destroy_settings()
|
||||||
|
|
||||||
def test_service_item_basic(self):
|
def test_service_item_basic(self):
|
||||||
"""
|
"""
|
||||||
Test the Service Item - basic test
|
Test the Service Item - basic test
|
||||||
@ -82,8 +96,8 @@ class TestServiceItem(TestCase):
|
|||||||
service_item = ServiceItem(None)
|
service_item = ServiceItem(None)
|
||||||
|
|
||||||
# THEN: We should get back a valid service item
|
# 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'
|
||||||
self.assertTrue(service_item.missing_frames(), 'There should not be any frames in the service item')
|
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):
|
def test_service_item_load_custom_from_service(self):
|
||||||
"""
|
"""
|
||||||
@ -99,7 +113,7 @@ class TestServiceItem(TestCase):
|
|||||||
service_item.set_from_service(line)
|
service_item.set_from_service(line)
|
||||||
|
|
||||||
# THEN: We should get back a valid service item
|
# 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, 'The new service item should be valid'
|
||||||
assert_length(0, service_item._display_frames, 'The service item should have no display frames')
|
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')
|
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)
|
service_item.render(True)
|
||||||
|
|
||||||
# THEN: The frames should also be valid
|
# THEN: The frames should also be valid
|
||||||
self.assertEqual('Test Custom', service_item.get_display_title(), 'The title should be "Test Custom"')
|
assert 'Test Custom' == service_item.get_display_title(), 'The title should be "Test Custom"'
|
||||||
self.assertEqual(CLEANED_VERSE[:-1], service_item.get_frames()[0]['text'],
|
assert CLEANED_VERSE[:-1] == service_item.get_frames()[0]['text'], \
|
||||||
'The returned text matches the input, except the last line feed')
|
'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),
|
assert RENDERED_VERSE.split('\n', 1)[0] == service_item.get_rendered_frame(1), \
|
||||||
'The first line has been returned')
|
'The first line has been returned'
|
||||||
self.assertEqual('Slide 1', service_item.get_frame_title(0), '"Slide 1" has been returned as the title')
|
assert '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')
|
assert '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 '' == 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):
|
def test_service_item_load_image_from_service(self):
|
||||||
"""
|
"""
|
||||||
@ -138,26 +152,22 @@ class TestServiceItem(TestCase):
|
|||||||
service_item.set_from_service(line, TEST_PATH)
|
service_item.set_from_service(line, TEST_PATH)
|
||||||
|
|
||||||
# THEN: We should get back a valid service item
|
# 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'
|
||||||
self.assertEqual(os.path.normpath(test_file), os.path.normpath(service_item.get_rendered_frame(0)),
|
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')
|
'The first frame should match the path to the image'
|
||||||
self.assertEqual(frame_array, service_item.get_frames()[0],
|
assert frame_array == service_item.get_frames()[0], 'The return should match frame array1'
|
||||||
'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'
|
||||||
self.assertEqual(test_file, service_item.get_frame_path(0),
|
assert image_name == service_item.get_frame_title(0), 'The frame title should match the image name'
|
||||||
'The frame path should match the full path to the image')
|
assert image_name == service_item.get_display_title(), 'The display title should match the first image name'
|
||||||
self.assertEqual(image_name, service_item.get_frame_title(0),
|
assert service_item.is_image() is True, 'This service item should be of an "image" type'
|
||||||
'The frame title should match the image name')
|
assert service_item.is_capable(ItemCapabilities.CanMaintain) is True, \
|
||||||
self.assertEqual(image_name, service_item.get_display_title(),
|
'This service item should be able to be Maintained'
|
||||||
'The display title should match the first image name')
|
assert service_item.is_capable(ItemCapabilities.CanPreview) is True, \
|
||||||
self.assertTrue(service_item.is_image(), 'This service item should be of an "image" type')
|
'This service item should be able to be be Previewed'
|
||||||
self.assertTrue(service_item.is_capable(ItemCapabilities.CanMaintain),
|
assert service_item.is_capable(ItemCapabilities.CanLoop) is True, \
|
||||||
'This service item should be able to be Maintained')
|
'This service item should be able to be run in a can be made to Loop'
|
||||||
self.assertTrue(service_item.is_capable(ItemCapabilities.CanPreview),
|
assert service_item.is_capable(ItemCapabilities.CanAppend) is True, \
|
||||||
'This service item should be able to be be Previewed')
|
'This service item should be able to have new items added to it'
|
||||||
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')
|
|
||||||
|
|
||||||
def test_service_item_load_image_from_local_service(self):
|
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
|
# 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.
|
# 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')
|
assert service_item.is_valid is True, 'The first service item should be valid'
|
||||||
self.assertTrue(service_item2.is_valid, 'The second 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
|
# These test will fail on windows due to the difference in folder seperators
|
||||||
if os.name != 'nt':
|
if os.name != 'nt':
|
||||||
self.assertEqual(test_file1, service_item.get_rendered_frame(0),
|
assert test_file1 == service_item.get_rendered_frame(0), \
|
||||||
'The first frame should match the path to the image')
|
'The first frame should match the path to the image'
|
||||||
self.assertEqual(test_file2, service_item2.get_rendered_frame(0),
|
assert test_file2 == service_item2.get_rendered_frame(0), \
|
||||||
'The Second frame should match the path to the image')
|
'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')
|
assert 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')
|
assert frame_array2 == service_item2.get_frames()[0], 'The return should match the frame array2'
|
||||||
self.assertEqual(test_file1, service_item.get_frame_path(0),
|
assert test_file1 == service_item.get_frame_path(0), \
|
||||||
'The frame path should match the full path to the image')
|
'The frame path should match the full path to the image'
|
||||||
self.assertEqual(test_file2, service_item2.get_frame_path(0),
|
assert test_file2 == service_item2.get_frame_path(0), \
|
||||||
'The frame path should match the full path to the image')
|
'The frame path should match the full path to the image'
|
||||||
self.assertEqual(image_name1, service_item.get_frame_title(0),
|
assert image_name1 == service_item.get_frame_title(0), 'The 1st frame title should match the image name'
|
||||||
'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'
|
||||||
self.assertEqual(image_name2, service_item2.get_frame_title(0),
|
assert service_item.name == service_item.title.lower(), \
|
||||||
'The 2nd frame title should match the image name')
|
'The plugin name should match the display title, as there are > 1 Images'
|
||||||
self.assertEqual(service_item.name, service_item.title.lower(),
|
assert service_item.is_image() is True, 'This service item should be of an "image" type'
|
||||||
'The plugin name should match the display title, as there are > 1 Images')
|
assert service_item.is_capable(ItemCapabilities.CanMaintain) is True, \
|
||||||
self.assertTrue(service_item.is_image(), 'This service item should be of an "image" type')
|
'This service item should be able to be Maintained'
|
||||||
self.assertTrue(service_item.is_capable(ItemCapabilities.CanMaintain),
|
assert service_item.is_capable(ItemCapabilities.CanPreview) is True, \
|
||||||
'This service item should be able to be Maintained')
|
'This service item should be able to be be Previewed'
|
||||||
self.assertTrue(service_item.is_capable(ItemCapabilities.CanPreview),
|
assert service_item.is_capable(ItemCapabilities.CanLoop) is True, \
|
||||||
'This service item should be able to be be Previewed')
|
'This service item should be able to be run in a can be made to Loop'
|
||||||
self.assertTrue(service_item.is_capable(ItemCapabilities.CanLoop),
|
assert service_item.is_capable(ItemCapabilities.CanAppend) is True, \
|
||||||
'This service item should be able to be run in a can be made to Loop')
|
'This service item should be able to have new items added to it'
|
||||||
self.assertTrue(service_item.is_capable(ItemCapabilities.CanAppend),
|
|
||||||
'This service item should be able to have new items added to it')
|
|
||||||
|
|
||||||
def test_add_from_command_for_a_presentation(self):
|
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)
|
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
|
# 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')
|
assert 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.get_frames()[0] == frame, 'Frames should match'
|
||||||
|
|
||||||
def test_add_from_comamnd_without_display_title_and_notes(self):
|
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)
|
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
|
# 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')
|
assert 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.get_frames()[0] == frame, 'Frames should match'
|
||||||
|
|
||||||
@patch(u'openlp.core.lib.serviceitem.ServiceItem.image_manager')
|
@patch(u'openlp.core.lib.serviceitem.ServiceItem.image_manager')
|
||||||
@patch('openlp.core.lib.serviceitem.AppLocation.get_section_data_path')
|
@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)
|
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
|
# 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')
|
assert 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.get_frames()[0] == frame, 'Frames should match'
|
||||||
self.assertEqual(1, mocked_image_manager.add_image.call_count, 'image_manager should be used')
|
assert 1 == mocked_image_manager.add_image.call_count, 'image_manager should be used'
|
||||||
|
|
||||||
def test_service_item_load_optical_media_from_service(self):
|
def test_service_item_load_optical_media_from_service(self):
|
||||||
"""
|
"""
|
||||||
@ -306,11 +314,11 @@ class TestServiceItem(TestCase):
|
|||||||
service_item.set_from_service(line)
|
service_item.set_from_service(line)
|
||||||
|
|
||||||
# THEN: We should get back a valid service item with optical media info
|
# 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')
|
assert service_item.is_valid is True, 'The service item should be valid'
|
||||||
self.assertTrue(service_item.is_capable(ItemCapabilities.IsOptical), 'The item should be Optical')
|
assert service_item.is_capable(ItemCapabilities.IsOptical) is True, 'The item should be Optical'
|
||||||
self.assertEqual(service_item.start_time, 654.375, 'Start time should be 654.375')
|
assert 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')
|
assert 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.media_length == 17.694, 'Media length should be 17.694'
|
||||||
|
|
||||||
def test_service_item_load_song_and_audio_from_service(self):
|
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/')
|
service_item.set_from_service(line, '/test/')
|
||||||
|
|
||||||
# THEN: We should get back a valid service item
|
# 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, 'The new service item should be valid'
|
||||||
assert_length(0, service_item._display_frames, 'The service item should have no display frames')
|
assert 0 == len(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 7 == len(service_item.capabilities), 'There should be 7 default custom item capabilities'
|
||||||
|
|
||||||
# WHEN: We render the frames of the service item
|
# WHEN: We render the frames of the service item
|
||||||
service_item.render(True)
|
service_item.render(True)
|
||||||
|
|
||||||
# THEN: The frames should also be valid
|
# THEN: The frames should also be valid
|
||||||
self.assertEqual('Amazing Grace', service_item.get_display_title(), 'The title should be "Amazing Grace"')
|
assert 'Amazing Grace' == service_item.get_display_title(), 'The title should be "Amazing Grace"'
|
||||||
self.assertEqual(CLEANED_VERSE[:-1], service_item.get_frames()[0]['text'],
|
assert CLEANED_VERSE[:-1] == service_item.get_frames()[0]['text'], \
|
||||||
'The returned text matches the input, except the last line feed')
|
'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),
|
assert RENDERED_VERSE.split('\n', 1)[0] == service_item.get_rendered_frame(1), \
|
||||||
'The first line has been returned')
|
'The first line has been returned'
|
||||||
self.assertEqual('Amazing Grace! how sweet the s', service_item.get_frame_title(0),
|
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')
|
'"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),
|
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')
|
'"’Twas grace that taught my hea" has been returned as the title'
|
||||||
self.assertEqual('/test/amazing_grace.mp3', service_item.background_audio[0],
|
assert '/test/amazing_grace.mp3' == service_item.background_audio[0], \
|
||||||
'"/test/amazing_grace.mp3" should be in the background_audio list')
|
'"/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
|
# THEN: The filename of the background should be correct
|
||||||
expected_filename = path / 'MyBeautifulTheme' / 'video.mp4'
|
expected_filename = path / 'MyBeautifulTheme' / 'video.mp4'
|
||||||
self.assertEqual(expected_filename, theme.background_filename)
|
assert expected_filename == theme.background_filename
|
||||||
self.assertEqual('MyBeautifulTheme', theme.theme_name)
|
assert 'MyBeautifulTheme' == theme.theme_name
|
||||||
|
|
||||||
def test_save_retrieve(self):
|
def test_save_retrieve(self):
|
||||||
"""
|
"""
|
||||||
@ -107,9 +107,9 @@ class TestTheme(TestCase):
|
|||||||
self.check_theme(lt)
|
self.check_theme(lt)
|
||||||
|
|
||||||
def check_theme(self, theme):
|
def check_theme(self, theme):
|
||||||
self.assertEqual('#000000', theme.background_border_color, 'background_border_color should be "#000000"')
|
assert '#000000' == theme.background_border_color, 'background_border_color should be "#000000"'
|
||||||
self.assertEqual('solid', theme.background_type, 'background_type should be "solid"')
|
assert 'solid' == theme.background_type, 'background_type should be "solid"'
|
||||||
self.assertEqual(0, theme.display_vertical_align, 'display_vertical_align should be 0')
|
assert 0 == theme.display_vertical_align, 'display_vertical_align should be 0'
|
||||||
self.assertFalse(theme.font_footer_bold, 'font_footer_bold should be False')
|
assert theme.font_footer_bold is False, 'font_footer_bold should be False'
|
||||||
self.assertEqual('Arial', theme.font_main_name, 'font_main_name should be "Arial"')
|
assert 'Arial' == theme.font_main_name, 'font_main_name should be "Arial"'
|
||||||
self.assertEqual(47, len(theme.__dict__), 'The theme should have 47 attributes')
|
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')
|
add_welcome_page(wizard, ':/wizards/wizard_firsttime.bmp')
|
||||||
|
|
||||||
# THEN: The wizard should have one page with a pixmap.
|
# THEN: The wizard should have one page with a pixmap.
|
||||||
self.assertEqual(1, len(wizard.pageIds()), 'The wizard should have one page.')
|
assert 1 == len(wizard.pageIds()), 'The wizard should have one page.'
|
||||||
self.assertIsInstance(wizard.page(0).pixmap(QtWidgets.QWizard.WatermarkPixmap), QtGui.QPixmap)
|
assert isinstance(wizard.page(0).pixmap(QtWidgets.QWizard.WatermarkPixmap), QtGui.QPixmap)
|
||||||
|
|
||||||
def test_create_button_box(self):
|
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'])
|
btnbox = create_button_box(dialog, 'my_btns', ['ok', 'save', 'cancel', 'close', 'defaults'])
|
||||||
|
|
||||||
# THEN: We should get a QDialogButtonBox with five buttons
|
# THEN: We should get a QDialogButtonBox with five buttons
|
||||||
self.assertIsInstance(btnbox, QtWidgets.QDialogButtonBox)
|
assert isinstance(btnbox, QtWidgets.QDialogButtonBox)
|
||||||
self.assertEqual(5, len(btnbox.buttons()))
|
assert 5 == len(btnbox.buttons())
|
||||||
|
|
||||||
# WHEN: We create the button box with a custom button
|
# WHEN: We create the button box with a custom button
|
||||||
btnbox = create_button_box(dialog, 'my_btns', None, [QtWidgets.QPushButton('Custom')])
|
btnbox = create_button_box(dialog, 'my_btns', None, [QtWidgets.QPushButton('Custom')])
|
||||||
# THEN: We should get a QDialogButtonBox with one button
|
# THEN: We should get a QDialogButtonBox with one button
|
||||||
self.assertIsInstance(btnbox, QtWidgets.QDialogButtonBox)
|
assert isinstance(btnbox, QtWidgets.QDialogButtonBox)
|
||||||
self.assertEqual(1, len(btnbox.buttons()))
|
assert 1 == len(btnbox.buttons())
|
||||||
|
|
||||||
# WHEN: We create the button box with a custom button and a custom role
|
# WHEN: We create the button box with a custom button and a custom role
|
||||||
btnbox = create_button_box(dialog, 'my_btns', None,
|
btnbox = create_button_box(dialog, 'my_btns', None,
|
||||||
[(QtWidgets.QPushButton('Help'), QtWidgets.QDialogButtonBox.HelpRole)])
|
[(QtWidgets.QPushButton('Help'), QtWidgets.QDialogButtonBox.HelpRole)])
|
||||||
# THEN: We should get a QDialogButtonBox with one button with a certain role
|
# THEN: We should get a QDialogButtonBox with one button with a certain role
|
||||||
self.assertIsInstance(btnbox, QtWidgets.QDialogButtonBox)
|
assert isinstance(btnbox, QtWidgets.QDialogButtonBox)
|
||||||
self.assertEqual(1, len(btnbox.buttons()))
|
assert 1 == len(btnbox.buttons())
|
||||||
self.assertEqual(QtWidgets.QDialogButtonBox.HelpRole, btnbox.buttonRole(btnbox.buttons()[0]))
|
assert QtWidgets.QDialogButtonBox.HelpRole, btnbox.buttonRole(btnbox.buttons()[0])
|
||||||
|
|
||||||
def test_create_horizontal_adjusting_combo_box(self):
|
def test_create_horizontal_adjusting_combo_box(self):
|
||||||
"""
|
"""
|
||||||
@ -91,9 +91,9 @@ class TestUi(TestCase):
|
|||||||
combo = create_horizontal_adjusting_combo_box(dialog, 'combo1')
|
combo = create_horizontal_adjusting_combo_box(dialog, 'combo1')
|
||||||
|
|
||||||
# THEN: We should get a ComboBox
|
# THEN: We should get a ComboBox
|
||||||
self.assertIsInstance(combo, QtWidgets.QComboBox)
|
assert isinstance(combo, QtWidgets.QComboBox)
|
||||||
self.assertEqual('combo1', combo.objectName())
|
assert 'combo1' == combo.objectName()
|
||||||
self.assertEqual(QtWidgets.QComboBox.AdjustToMinimumContentsLength, combo.sizeAdjustPolicy())
|
assert QtWidgets.QComboBox.AdjustToMinimumContentsLength == combo.sizeAdjustPolicy()
|
||||||
|
|
||||||
def test_create_button(self):
|
def test_create_button(self):
|
||||||
"""
|
"""
|
||||||
@ -106,26 +106,26 @@ class TestUi(TestCase):
|
|||||||
btn = create_button(dialog, 'my_btn')
|
btn = create_button(dialog, 'my_btn')
|
||||||
|
|
||||||
# THEN: We should get a button with a name
|
# THEN: We should get a button with a name
|
||||||
self.assertIsInstance(btn, QtWidgets.QPushButton)
|
assert isinstance(btn, QtWidgets.QPushButton)
|
||||||
self.assertEqual('my_btn', btn.objectName())
|
assert 'my_btn' == btn.objectName()
|
||||||
self.assertTrue(btn.isEnabled())
|
assert btn.isEnabled() is True
|
||||||
|
|
||||||
# WHEN: We create a button with some attributes
|
# WHEN: We create a button with some attributes
|
||||||
btn = create_button(dialog, 'my_btn', text='Hello', tooltip='How are you?', enabled=False)
|
btn = create_button(dialog, 'my_btn', text='Hello', tooltip='How are you?', enabled=False)
|
||||||
|
|
||||||
# THEN: We should get a button with those attributes
|
# THEN: We should get a button with those attributes
|
||||||
self.assertIsInstance(btn, QtWidgets.QPushButton)
|
assert isinstance(btn, QtWidgets.QPushButton)
|
||||||
self.assertEqual('Hello', btn.text())
|
assert 'Hello' == btn.text()
|
||||||
self.assertEqual('How are you?', btn.toolTip())
|
assert 'How are you?' == btn.toolTip()
|
||||||
self.assertFalse(btn.isEnabled())
|
assert btn.isEnabled() is False
|
||||||
|
|
||||||
# WHEN: We create a toolbutton
|
# WHEN: We create a toolbutton
|
||||||
btn = create_button(dialog, 'my_btn', btn_class='toolbutton')
|
btn = create_button(dialog, 'my_btn', btn_class='toolbutton')
|
||||||
|
|
||||||
# THEN: We should get a toolbutton
|
# THEN: We should get a toolbutton
|
||||||
self.assertIsInstance(btn, QtWidgets.QToolButton)
|
assert isinstance(btn, QtWidgets.QToolButton)
|
||||||
self.assertEqual('my_btn', btn.objectName())
|
assert 'my_btn' == btn.objectName()
|
||||||
self.assertTrue(btn.isEnabled())
|
assert btn.isEnabled() is True
|
||||||
|
|
||||||
def test_create_action(self):
|
def test_create_action(self):
|
||||||
"""
|
"""
|
||||||
@ -138,19 +138,19 @@ class TestUi(TestCase):
|
|||||||
action = create_action(dialog, 'my_action')
|
action = create_action(dialog, 'my_action')
|
||||||
|
|
||||||
# THEN: We should get a QAction
|
# THEN: We should get a QAction
|
||||||
self.assertIsInstance(action, QtWidgets.QAction)
|
assert isinstance(action, QtWidgets.QAction)
|
||||||
self.assertEqual('my_action', action.objectName())
|
assert 'my_action' == action.objectName()
|
||||||
|
|
||||||
# WHEN: We create an action with some properties
|
# WHEN: We create an action with some properties
|
||||||
action = create_action(dialog, 'my_action', text='my text', icon=':/wizards/wizard_firsttime.bmp',
|
action = create_action(dialog, 'my_action', text='my text', icon=':/wizards/wizard_firsttime.bmp',
|
||||||
tooltip='my tooltip', statustip='my statustip')
|
tooltip='my tooltip', statustip='my statustip')
|
||||||
|
|
||||||
# THEN: These properties should be set
|
# THEN: These properties should be set
|
||||||
self.assertIsInstance(action, QtWidgets.QAction)
|
assert isinstance(action, QtWidgets.QAction)
|
||||||
self.assertEqual('my text', action.text())
|
assert 'my text' == action.text()
|
||||||
self.assertIsInstance(action.icon(), QtGui.QIcon)
|
assert isinstance(action.icon(), QtGui.QIcon)
|
||||||
self.assertEqual('my tooltip', action.toolTip())
|
assert 'my tooltip' == action.toolTip()
|
||||||
self.assertEqual('my statustip', action.statusTip())
|
assert 'my statustip' == action.statusTip()
|
||||||
|
|
||||||
def test_create_action_on_mac_osx(self):
|
def test_create_action_on_mac_osx(self):
|
||||||
"""
|
"""
|
||||||
@ -186,8 +186,8 @@ class TestUi(TestCase):
|
|||||||
create_action(dialog, 'my_action')
|
create_action(dialog, 'my_action')
|
||||||
|
|
||||||
# THEN: setIconVisibleInMenu should not be called
|
# THEN: setIconVisibleInMenu should not be called
|
||||||
self.assertEqual(0, mocked_action.setIconVisibleInMenu.call_count,
|
assert 0 == mocked_action.setIconVisibleInMenu.call_count, \
|
||||||
'setIconVisibleInMenu should not have been called')
|
'setIconVisibleInMenu should not have been called'
|
||||||
|
|
||||||
def test_create_checked_disabled_invisible_action(self):
|
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)
|
action = create_action(dialog, 'my_action', checked=True, enabled=False, visible=False)
|
||||||
|
|
||||||
# THEN: These properties should be set
|
# THEN: These properties should be set
|
||||||
self.assertTrue(action.isChecked(), 'The action should be checked')
|
assert action.isChecked() is True, 'The action should be checked'
|
||||||
self.assertFalse(action.isEnabled(), 'The action should be disabled')
|
assert action.isEnabled() is False, 'The action should be disabled'
|
||||||
self.assertFalse(action.isVisible(), 'The action should be invisble')
|
assert action.isVisible() is False, 'The action should be invisble'
|
||||||
|
|
||||||
def test_create_action_separator(self):
|
def test_create_action_separator(self):
|
||||||
"""
|
"""
|
||||||
@ -215,7 +215,7 @@ class TestUi(TestCase):
|
|||||||
action = create_action(dialog, 'my_action', separator=True)
|
action = create_action(dialog, 'my_action', separator=True)
|
||||||
|
|
||||||
# THEN: The action should be a separator
|
# 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):
|
def test_create_valign_selection_widgets(self):
|
||||||
"""
|
"""
|
||||||
@ -228,11 +228,11 @@ class TestUi(TestCase):
|
|||||||
label, combo = create_valign_selection_widgets(dialog)
|
label, combo = create_valign_selection_widgets(dialog)
|
||||||
|
|
||||||
# THEN: We should get a label and a combobox.
|
# THEN: We should get a label and a combobox.
|
||||||
self.assertEqual(translate('OpenLP.Ui', '&Vertical Align:'), label.text())
|
assert translate('OpenLP.Ui', '&Vertical Align:') == label.text()
|
||||||
self.assertIsInstance(combo, QtWidgets.QComboBox)
|
assert isinstance(combo, QtWidgets.QComboBox)
|
||||||
self.assertEqual(combo, label.buddy())
|
assert combo == label.buddy()
|
||||||
for text in [UiStrings().Top, UiStrings().Middle, UiStrings().Bottom]:
|
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):
|
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)
|
find_and_set_in_combo_box(combo, 'Four', set_missing=False)
|
||||||
|
|
||||||
# THEN: The index should not have changed
|
# 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
|
# WHEN: We call the method with a non-existing value
|
||||||
find_and_set_in_combo_box(combo, 'Four')
|
find_and_set_in_combo_box(combo, 'Four')
|
||||||
|
|
||||||
# THEN: The index should have been reset
|
# 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
|
# WHEN: We call the method with the default behavior
|
||||||
find_and_set_in_combo_box(combo, 'Three')
|
find_and_set_in_combo_box(combo, 'Three')
|
||||||
|
|
||||||
# THEN: The index should have changed
|
# THEN: The index should have changed
|
||||||
self.assertEqual(2, combo.currentIndex())
|
assert 2 == combo.currentIndex()
|
||||||
|
|
||||||
def test_create_widget_action(self):
|
def test_create_widget_action(self):
|
||||||
"""
|
"""
|
||||||
@ -272,8 +272,8 @@ class TestUi(TestCase):
|
|||||||
action = create_widget_action(button, 'some action')
|
action = create_widget_action(button, 'some action')
|
||||||
|
|
||||||
# THEN: The action should be returned
|
# THEN: The action should be returned
|
||||||
self.assertIsInstance(action, QtWidgets.QAction)
|
assert isinstance(action, QtWidgets.QAction)
|
||||||
self.assertEqual(action.objectName(), 'some action')
|
assert action.objectName() == 'some action'
|
||||||
|
|
||||||
def test_set_case_insensitive_completer(self):
|
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
|
# THEN: The Combobox should have a completer which is case insensitive
|
||||||
completer = line_edit.completer()
|
completer = line_edit.completer()
|
||||||
self.assertIsInstance(completer, QtWidgets.QCompleter)
|
assert isinstance(completer, QtWidgets.QCompleter)
|
||||||
self.assertEqual(completer.caseSensitivity(), QtCore.Qt.CaseInsensitive)
|
assert completer.caseSensitivity() == QtCore.Qt.CaseInsensitive
|
||||||
|
Loading…
Reference in New Issue
Block a user