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


Python MagicMock.processor方法代码示例

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


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

示例1: test_check_file_type_processor_different_from_available

# 需要导入模块: from tests.functional import MagicMock [as 别名]
# 或者: from tests.functional.MagicMock import processor [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 processor [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: test_start_presentation_with_no_player

# 需要导入模块: from tests.functional import MagicMock [as 别名]
# 或者: from tests.functional.MagicMock import processor [as 别名]
    def test_start_presentation_with_no_player(self, media_mock):
        """
        Find and chose a controller to play a presentations when the player is not available.
        """
        # GIVEN: A single controller and service item wanting to use the controller
        mock_item = MagicMock()
        mock_item.processor = 'Powerpoint'
        mock_item.get_frame_path.return_value = "test.ppt"
        self.media_item.automatic = False
        mocked_controller = MagicMock()
        mocked_controller.available = True
        mocked_controller.supports = ['ppt']
        mocked_controller1 = MagicMock()
        mocked_controller1.available = False
        mocked_controller1.supports = ['ppt']
        controllers = {
            'Impress': mocked_controller,
            'Powerpoint': mocked_controller1
        }
        ml = MessageListener(self.media_item)
        ml.media_item = self.media_item
        ml.controllers = controllers
        ml.preview_handler = MagicMock()
        ml.timer = MagicMock()

        # WHEN: request the presentation to start
        ml.startup([mock_item, False, False, False])

        # THEN: The controllers will be setup.
        self.assertTrue(len(controllers), 'We have loaded a controller')
开发者ID:imkernel,项目名称:openlp,代码行数:32,代码来源:test_messagelistener.py

示例4: test_start_pdf_presentation

# 需要导入模块: from tests.functional import MagicMock [as 别名]
# 或者: from tests.functional.MagicMock import processor [as 别名]
    def test_start_pdf_presentation(self, media_mock):
        """
        Test the startup of pdf presentation succeed.
        """
        # GIVEN: A sservice item with a pdf
        mock_item = MagicMock()
        mock_item.processor = 'Pdf'
        mock_item.get_frame_path.return_value = "test.pdf"
        self.media_item.generate_slide_data = MagicMock()
        ml = MessageListener(self.media_item)
        ml.media_item = self.media_item
        ml.preview_handler = MagicMock()

        # WHEN: request the presentation to start
        ml.startup([mock_item, False, False, False])

        # THEN: The handler should be set to None
        self.assertIsNone(ml.handler, 'The handler should be None')
开发者ID:imkernel,项目名称:openlp,代码行数:20,代码来源:test_messagelistener.py

示例5: check_file_type_no_processor_test

# 需要导入模块: from tests.functional import MagicMock [as 别名]
# 或者: from tests.functional.MagicMock import processor [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

示例6: check_file_type_no_players_test

# 需要导入模块: from tests.functional import MagicMock [as 别名]
# 或者: from tests.functional.MagicMock import processor [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.processor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。