test fixing

This commit is contained in:
Tim Bentley 2018-12-13 19:25:20 +00:00
parent efa1114fa6
commit 71c1051f88
3 changed files with 12 additions and 13 deletions

View File

@ -60,11 +60,12 @@ class MediaPlayer(RegistryProperties):
""" """
pass pass
def load(self, display): def load(self, display, file):
""" """
Load a new media file and check if it is valid Load a new media file and check if it is valid
:param display: The display to be updated. :param display: The display to be updated.
:param file: The file to be loaded
""" """
return True return True

View File

@ -27,7 +27,7 @@ from unittest.mock import MagicMock, patch
from openlp.core.common.registry import Registry from openlp.core.common.registry import Registry
from openlp.core.ui.media.mediacontroller import MediaController from openlp.core.ui.media.mediacontroller import MediaController
from openlp.core.ui.media.mediaplayer import MediaPlayer from openlp.core.ui.media.vlcplayer import VlcPlayer
from tests.helpers.testmixin import TestMixin from tests.helpers.testmixin import TestMixin
from tests.utils.constants import RESOURCE_PATH from tests.utils.constants import RESOURCE_PATH
@ -49,10 +49,10 @@ class TestMediaController(TestCase, TestMixin):
""" """
# GIVEN: A MediaController and an active player with audio and video extensions # GIVEN: A MediaController and an active player with audio and video extensions
media_controller = MediaController() media_controller = MediaController()
media_controller.media_players = MediaPlayer(None) media_controller.vlc_player = VlcPlayer(None)
media_controller.media_players.is_active = True media_controller.vlc_player.is_active = True
media_controller.media_players.audio_extensions_list = ['*.mp3', '*.wav', '*.wma', '*.ogg'] media_controller.vlc_player.audio_extensions_list = ['*.mp3', '*.wav', '*.wma', '*.ogg']
media_controller.media_players.video_extensions_list = ['*.mp4', '*.mov', '*.avi', '*.ogm'] media_controller.vlc_player.video_extensions_list = ['*.mp4', '*.mov', '*.avi', '*.ogm']
# WHEN: calling _generate_extensions_lists # WHEN: calling _generate_extensions_lists
media_controller._generate_extensions_lists() media_controller._generate_extensions_lists()
@ -86,12 +86,10 @@ class TestMediaController(TestCase, TestMixin):
media_controller = MediaController() media_controller = MediaController()
mocked_controller = MagicMock() mocked_controller = MagicMock()
mocked_display = MagicMock() mocked_display = MagicMock()
mocked_service_item = MagicMock()
mocked_service_item.processor = 1
media_controller.media_players = MagicMock() media_controller.media_players = MagicMock()
# WHEN: calling _check_file_type when no players exists # WHEN: calling _check_file_type when no players exists
ret = media_controller._check_file_type(mocked_controller, mocked_display, mocked_service_item) ret = media_controller._check_file_type(mocked_controller, mocked_display)
# THEN: it should return False # THEN: it should return False
assert ret is False, '_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.'

View File

@ -368,7 +368,7 @@ class TestVLCPlayer(TestCase, TestMixin):
# WHEN: A video is loaded into VLC # WHEN: A video is loaded into VLC
with patch.object(vlc_player, 'volume') as mocked_volume: with patch.object(vlc_player, 'volume') as mocked_volume:
result = vlc_player.load(mocked_display) result = vlc_player.load(mocked_display, MagicMock())
# THEN: The video should be loaded # THEN: The video should be loaded
mocked_normcase.assert_called_with(media_path) mocked_normcase.assert_called_with(media_path)
@ -413,7 +413,7 @@ class TestVLCPlayer(TestCase, TestMixin):
# WHEN: An audio CD is loaded into VLC # WHEN: An audio CD is loaded into VLC
with patch.object(vlc_player, 'volume') as mocked_volume, \ with patch.object(vlc_player, 'volume') as mocked_volume, \
patch.object(vlc_player, 'media_state_wait'): patch.object(vlc_player, 'media_state_wait'):
result = vlc_player.load(mocked_display) result = vlc_player.load(mocked_display, MagicMock())
# THEN: The video should be loaded # THEN: The video should be loaded
mocked_normcase.assert_called_with(media_path) mocked_normcase.assert_called_with(media_path)
@ -458,7 +458,7 @@ class TestVLCPlayer(TestCase, TestMixin):
# WHEN: An audio CD is loaded into VLC # WHEN: An audio CD is loaded into VLC
with patch.object(vlc_player, 'volume') as mocked_volume, \ with patch.object(vlc_player, 'volume') as mocked_volume, \
patch.object(vlc_player, 'media_state_wait'): patch.object(vlc_player, 'media_state_wait'):
result = vlc_player.load(mocked_display) result = vlc_player.load(mocked_display, MagicMock())
# THEN: The video should be loaded # THEN: The video should be loaded
mocked_normcase.assert_called_with(media_path) mocked_normcase.assert_called_with(media_path)
@ -502,7 +502,7 @@ class TestVLCPlayer(TestCase, TestMixin):
# WHEN: An audio CD is loaded into VLC # WHEN: An audio CD is loaded into VLC
with patch.object(vlc_player, 'volume'), patch.object(vlc_player, 'media_state_wait'): with patch.object(vlc_player, 'volume'), patch.object(vlc_player, 'media_state_wait'):
result = vlc_player.load(mocked_display) result = vlc_player.load(mocked_display, MagicMock())
# THEN: The video should be loaded # THEN: The video should be loaded
mocked_normcase.assert_called_with(media_path) mocked_normcase.assert_called_with(media_path)