From 9b2660bf7f98e0cece75fada6c322a40dc7fea5f Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Thu, 1 Jan 2015 17:41:32 +0000 Subject: [PATCH] Rewrote tests for webkit and phonon player --- .../openlp_core_ui_media/test_phononplayer.py | 36 ++++++++++++------ .../openlp_core_ui_media/test_webkitplayer.py | 38 +++++++++++++------ 2 files changed, 51 insertions(+), 23 deletions(-) diff --git a/tests/functional/openlp_core_ui_media/test_phononplayer.py b/tests/functional/openlp_core_ui_media/test_phononplayer.py index ac51def1d..d7c194e5d 100644 --- a/tests/functional/openlp_core_ui_media/test_phononplayer.py +++ b/tests/functional/openlp_core_ui_media/test_phononplayer.py @@ -30,9 +30,9 @@ Package to test the openlp.core.ui.media.phononplayer package. """ from unittest import TestCase +from tests.functional import patch from openlp.core.ui.media.phononplayer import PhononPlayer -from openlp.core.common import is_macosx class TestPhononPlayer(TestCase): @@ -40,18 +40,32 @@ class TestPhononPlayer(TestCase): Test the functions in the :mod:`phononplayer` module. """ - def check_available_test(self): + def check_available_mac_test(self): """ - Simple test of phononplayer availability + Simple test of phononplayer availability on Mac OS X """ - # GIVEN: A PhononPlayer - phonon_player = PhononPlayer(None) + # GIVEN: A PhononPlayer and a mocked is_macosx + with patch('openlp.core.ui.media.phononplayer.is_macosx') as mocked_is_macosx: + mocked_is_macosx.return_value = True + phonon_player = PhononPlayer(None) - # WHEN: An checking if the player is available - available = phonon_player.check_available() + # WHEN: An checking if the player is available + available = phonon_player.check_available() - # THEN: The player should be available, except on Mac OS X - if is_macosx(): + # THEN: The player should not be available on Mac OS X self.assertEqual(False, available, 'The PhononPlayer should not be available on Mac OS X.') - else: - self.assertEqual(True, available, 'The PhononPlayer should be available on this platform.') + + def check_available_non_mac_test(self): + """ + Simple test of phononplayer availability when not on Mac OS X + """ + # GIVEN: A PhononPlayer and a mocked is_macosx + with patch('openlp.core.ui.media.phononplayer.is_macosx') as mocked_is_macosx: + mocked_is_macosx.return_value = False + phonon_player = PhononPlayer(None) + + # WHEN: An checking if the player is available + available = phonon_player.check_available() + + # THEN: The player should be available when not on Mac OS X + self.assertEqual(True, available, 'The PhononPlayer should be available when not on Mac OS X.') diff --git a/tests/functional/openlp_core_ui_media/test_webkitplayer.py b/tests/functional/openlp_core_ui_media/test_webkitplayer.py index 70a6f6320..94eb3ea8d 100644 --- a/tests/functional/openlp_core_ui_media/test_webkitplayer.py +++ b/tests/functional/openlp_core_ui_media/test_webkitplayer.py @@ -30,28 +30,42 @@ Package to test the openlp.core.ui.media.webkitplayer package. """ from unittest import TestCase +from tests.functional import patch from openlp.core.ui.media.webkitplayer import WebkitPlayer -from openlp.core.common import is_macosx -class TestPhononPlayer(TestCase): +class TestWebkitPlayer(TestCase): """ Test the functions in the :mod:`webkitplayer` module. """ - def check_available_test(self): + def check_available_mac_test(self): """ - Simple test of webkitplayer availability + Simple test of webkitplayer availability on Mac OS X """ - # GIVEN: A WebkitPlayer - webkit_player = WebkitPlayer(None) + # GIVEN: A WebkitPlayer and a mocked is_macosx + with patch('openlp.core.ui.media.webkitplayer.is_macosx') as mocked_is_macosx: + mocked_is_macosx.return_value = True + webkit_player = WebkitPlayer(None) - # WHEN: An checking if the player is available - available = webkit_player.check_available() + # WHEN: An checking if the player is available + available = webkit_player.check_available() - # THEN: The player should be available, except on Mac OS X - if is_macosx(): + # THEN: The player should not be available on Mac OS X self.assertEqual(False, available, 'The WebkitPlayer should not be available on Mac OS X.') - else: - self.assertEqual(True, available, 'The WebkitPlayer should be available on this platform.') + + def check_available_non_mac_test(self): + """ + Simple test of webkitplayer availability when not on Mac OS X + """ + # GIVEN: A WebkitPlayer and a mocked is_macosx + with patch('openlp.core.ui.media.webkitplayer.is_macosx') as mocked_is_macosx: + mocked_is_macosx.return_value = False + webkit_player = WebkitPlayer(None) + + # WHEN: An checking if the player is available + available = webkit_player.check_available() + + # THEN: The player should be available when not on Mac OS X + self.assertEqual(True, available, 'The WebkitPlayer should be available when not on Mac OS X.')