fix up some tests

This commit is contained in:
Tim Bentley 2016-02-27 14:03:52 +00:00
parent 071dfa6299
commit af51d10fad
4 changed files with 20 additions and 14 deletions

View File

@ -148,6 +148,7 @@ class ThemeForm(QtWidgets.QWizard, Ui_ThemeWizard, RegistryProperties):
def update_lines_text(self, lines):
"""
Updates the lines on a page on the wizard
:param lines: then number of lines to be displayed
"""
self.main_line_count_label.setText(
translate('OpenLP.ThemeForm', '(approximately %d lines per slide)') % int(lines))
@ -187,6 +188,7 @@ class ThemeForm(QtWidgets.QWizard, Ui_ThemeWizard, RegistryProperties):
def on_current_id_changed(self, page_id):
"""
Detects Page changes and updates as appropriate.
:param page_id: current page number
"""
enabled = self.page(page_id) == self.area_position_page
self.setOption(QtWidgets.QWizard.HaveCustomButton1, enabled)

View File

@ -111,6 +111,7 @@ class OpenLPWizard(QtWidgets.QWizard, RegistryProperties):
def setupUi(self, image):
"""
Set up the wizard UI.
:param image: path to start up image
"""
self.setWindowIcon(build_icon(u':/icon/openlp-logo.svg'))
self.setModal(True)
@ -210,6 +211,7 @@ class OpenLPWizard(QtWidgets.QWizard, RegistryProperties):
def on_current_id_changed(self, page_id):
"""
Perform necessary functions depending on which wizard page is active.
:param page_id: current page number
"""
if self.with_progress_page and self.page(page_id) == self.progress_page:
self.pre_wizard()
@ -221,6 +223,7 @@ class OpenLPWizard(QtWidgets.QWizard, RegistryProperties):
def custom_page_changed(self, page_id):
"""
Called when changing to a page other than the progress page
:param page_id: current page number
"""
pass

View File

@ -78,10 +78,11 @@ class TestMediaController(TestCase, TestMixin):
"""
Test that we don't try to play media when no players available
"""
# GIVEN: A mocked UiStrings, get_media_players, controller, display and service_item
with patch('openlp.core.ui.media.mediacontroller.get_media_players') as mocked_get_media_players,\
# GIVEN: A mocked UiStrings, get_used_players, controller, display and service_item
with patch('openlp.core.ui.media.mediacontroller.MediaController._get_used_players') as \
mocked_get_used_players,\
patch('openlp.core.ui.media.mediacontroller.UiStrings') as mocked_uistrings:
mocked_get_media_players.return_value = ([], '')
mocked_get_used_players.return_value = ([])
mocked_ret_uistrings = MagicMock()
mocked_ret_uistrings.Automatic = 1
mocked_uistrings.return_value = mocked_ret_uistrings
@ -97,14 +98,14 @@ class TestMediaController(TestCase, TestMixin):
# THEN: it should return False
self.assertFalse(ret, '_check_file_type should return False when no mediaplayers are available.')
@patch('openlp.core.ui.media.mediacontroller.get_media_players')
@patch('openlp.core.ui.media.mediacontroller.MediaController._get_used_players')
@patch('openlp.core.ui.media.mediacontroller.UiStrings')
def check_file_type_no_processor_test(self, mocked_uistrings, mocked_get_media_players):
def check_file_type_no_processor_test(self, mocked_uistrings, mocked_get_used_players):
"""
Test that we don't try to play media when the processor for the service item is None
"""
# GIVEN: A mocked UiStrings, get_media_players, controller, display and service_item
mocked_get_media_players.return_value = ([], '')
mocked_get_used_players.return_value = ([], '')
mocked_ret_uistrings = MagicMock()
mocked_ret_uistrings.Automatic = 1
mocked_uistrings.return_value = mocked_ret_uistrings
@ -120,14 +121,14 @@ class TestMediaController(TestCase, TestMixin):
# THEN: it should return False
self.assertFalse(ret, '_check_file_type should return False when the processor for service_item is None.')
@patch('openlp.core.ui.media.mediacontroller.get_media_players')
@patch('openlp.core.ui.media.mediacontroller.MediaController._get_used_players')
@patch('openlp.core.ui.media.mediacontroller.UiStrings')
def check_file_type_automatic_processor_test(self, mocked_uistrings, mocked_get_media_players):
def check_file_type_automatic_processor_test(self, mocked_uistrings, mocked_get_used_players):
"""
Test that we can play media when players are available and we have a automatic processor from the service item
"""
# GIVEN: A mocked UiStrings, get_media_players, controller, display and service_item
mocked_get_media_players.return_value = (['vlc', 'webkit'], '')
mocked_get_used_players.return_value = (['vlc', 'webkit'])
mocked_ret_uistrings = MagicMock()
mocked_ret_uistrings.Automatic = 1
mocked_uistrings.return_value = mocked_ret_uistrings
@ -150,21 +151,21 @@ class TestMediaController(TestCase, TestMixin):
self.assertTrue(ret, '_check_file_type should return True when mediaplayers are available and '
'the service item has an automatic processor.')
@patch('openlp.core.ui.media.mediacontroller.get_media_players')
@patch('openlp.core.ui.media.mediacontroller.MediaController._get_used_players')
@patch('openlp.core.ui.media.mediacontroller.UiStrings')
def check_file_type_processor_different_from_available_test(self, mocked_uistrings, mocked_get_media_players):
def check_file_type_processor_different_from_available_test(self, mocked_uistrings, mocked_get_used_players):
"""
Test that we can play media when players available are different from the processor from the service item
"""
# GIVEN: A mocked UiStrings, get_media_players, controller, display and service_item
mocked_get_media_players.return_value = (['phonon'], '')
mocked_get_used_players.return_value = (['system'])
mocked_ret_uistrings = MagicMock()
mocked_ret_uistrings.Automatic = 'automatic'
mocked_uistrings.return_value = mocked_ret_uistrings
media_controller = MediaController()
mocked_phonon = MagicMock()
mocked_phonon.video_extensions_list = ['*.mp4']
media_controller.media_players = {'phonon': mocked_phonon}
media_controller.media_players = {'system': mocked_phonon}
mocked_controller = MagicMock()
mocked_suffix = MagicMock()
mocked_suffix.return_value = 'mp4'

View File

@ -900,7 +900,7 @@ class TestVLCPlayer(TestCase, TestMixin):
# WHEN: reset() is called
vlc_player.reset(mocked_display)
# THEN: The media should be stopped and invsibile
# 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.state)