当前位置: 首页>>代码示例>>Python>>正文


Python MagicMock.Automatic方法代码示例

本文整理汇总了Python中tests.functional.MagicMock.Automatic方法的典型用法代码示例。如果您正苦于以下问题:Python MagicMock.Automatic方法的具体用法?Python MagicMock.Automatic怎么用?Python MagicMock.Automatic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tests.functional.MagicMock的用法示例。


在下文中一共展示了MagicMock.Automatic方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_check_file_type_processor_different_from_available

# 需要导入模块: from tests.functional import MagicMock [as 别名]
# 或者: from tests.functional.MagicMock import Automatic [as 别名]
    def test_check_file_type_processor_different_from_available(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_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 = {'system': mocked_phonon}
        mocked_controller = MagicMock()
        mocked_suffix = MagicMock()
        mocked_suffix.return_value = 'mp4'
        mocked_controller.media_info.file_info.suffix = mocked_suffix
        mocked_display = MagicMock()
        mocked_service_item = MagicMock()
        mocked_service_item.processor = 'vlc'

        # WHEN: calling _check_file_type when the processor for the service item is None
        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.')
开发者ID:imkernel,项目名称:openlp,代码行数:29,代码来源:test_mediacontroller.py

示例2: test_check_file_type_automatic_processor

# 需要导入模块: from tests.functional import MagicMock [as 别名]
# 或者: from tests.functional.MagicMock import Automatic [as 别名]
    def test_check_file_type_automatic_processor(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_used_players.return_value = (['vlc', 'webkit'])
        mocked_ret_uistrings = MagicMock()
        mocked_ret_uistrings.Automatic = 1
        mocked_uistrings.return_value = mocked_ret_uistrings
        media_controller = MediaController()
        mocked_vlc = MagicMock()
        mocked_vlc.video_extensions_list = ['*.mp4']
        media_controller.media_players = {'vlc': mocked_vlc, 'webkit': MagicMock()}
        mocked_controller = MagicMock()
        mocked_suffix = MagicMock()
        mocked_suffix.return_value = 'mp4'
        mocked_controller.media_info.file_info.suffix = mocked_suffix
        mocked_display = MagicMock()
        mocked_service_item = MagicMock()
        mocked_service_item.processor = 1

        # WHEN: calling _check_file_type when the processor for the service item is None
        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.')
开发者ID:imkernel,项目名称:openlp,代码行数:29,代码来源:test_mediacontroller.py

示例3: check_file_type_no_processor_test

# 需要导入模块: from tests.functional import MagicMock [as 别名]
# 或者: from tests.functional.MagicMock import Automatic [as 别名]
    def check_file_type_no_processor_test(self, mocked_uistrings, mocked_get_media_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_ret_uistrings = MagicMock()
        mocked_ret_uistrings.Automatic = 1
        mocked_uistrings.return_value = mocked_ret_uistrings
        media_controller = MediaController()
        mocked_controller = MagicMock()
        mocked_display = MagicMock()
        mocked_service_item = MagicMock()
        mocked_service_item.processor = None

        # WHEN: calling _check_file_type when the processor for the service item is None
        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.')
开发者ID:crossroadchurch,项目名称:paul,代码行数:22,代码来源:test_mediacontroller.py

示例4: check_file_type_no_players_test

# 需要导入模块: from tests.functional import MagicMock [as 别名]
# 或者: from tests.functional.MagicMock import Automatic [as 别名]
    def check_file_type_no_players_test(self):
        """
        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,\
                patch('openlp.core.ui.media.mediacontroller.UiStrings') as mocked_uistrings:
            mocked_get_media_players.return_value = ([], '')
            mocked_ret_uistrings = MagicMock()
            mocked_ret_uistrings.Automatic = 1
            mocked_uistrings.return_value = mocked_ret_uistrings
            media_controller = MediaController()
            mocked_controller = MagicMock()
            mocked_display = MagicMock()
            mocked_service_item = MagicMock()
            mocked_service_item.processor = 1

            # WHEN: calling _check_file_type when no players exists
            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.')
开发者ID:crossroadchurch,项目名称:paul,代码行数:24,代码来源:test_mediacontroller.py


注:本文中的tests.functional.MagicMock.Automatic方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。