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


Python MagicMock.supports方法代码示例

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


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

示例1: test_start_presentation_with_no_player

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

示例2: build_file_mask_string_test

# 需要导入模块: from tests.functional import MagicMock [as 别名]
# 或者: from tests.functional.MagicMock import supports [as 别名]
    def build_file_mask_string_test(self):
        """
        Test the build_file_mask_string() method
        """
        # GIVEN: Different controllers.
        impress_controller = MagicMock()
        impress_controller.enabled.return_value = True
        impress_controller.supports = ['odp']
        impress_controller.also_supports = ['ppt']
        presentation_controller = MagicMock()
        presentation_controller.enabled.return_value = True
        presentation_controller.supports = ['ppt']
        presentation_controller.also_supports = []
        presentation_viewer_controller = MagicMock()
        presentation_viewer_controller.enabled.return_value = False
        pdf_controller = MagicMock()
        pdf_controller.enabled.return_value = True
        pdf_controller.supports = ['pdf']
        pdf_controller.also_supports = ['xps', 'oxps']
        # Mock the controllers.
        self.media_item.controllers = {
            'Impress': impress_controller,
            'Powerpoint': presentation_controller,
            'Powerpoint Viewer': presentation_viewer_controller,
            'Pdf': pdf_controller
        }

        # WHEN: Build the file mask.
        with patch('openlp.plugins.presentations.lib.mediaitem.translate') as mocked_translate:
            mocked_translate.side_effect = lambda module, string_to_translate: string_to_translate
            self.media_item.build_file_mask_string()

        # THEN: The file mask should be generated correctly
        self.assertIn('*.odp', self.media_item.on_new_file_masks, 'The file mask should contain the odp extension')
        self.assertIn('*.ppt', self.media_item.on_new_file_masks, 'The file mask should contain the ppt extension')
        self.assertIn('*.pdf', self.media_item.on_new_file_masks, 'The file mask should contain the pdf extension')
        self.assertIn('*.xps', self.media_item.on_new_file_masks, 'The file mask should contain the xps extension')
        self.assertIn('*.oxps', self.media_item.on_new_file_masks, 'The file mask should contain the oxps extension')
开发者ID:crossroadchurch,项目名称:paul,代码行数:40,代码来源:test_mediaitem.py

示例3: clean_up_thumbnails_missing_file_test

# 需要导入模块: from tests.functional import MagicMock [as 别名]
# 或者: from tests.functional.MagicMock import supports [as 别名]
    def clean_up_thumbnails_missing_file_test(self):
        """
        Test that the clean_up_thumbnails method works as expected when file is missing.
        """
        # GIVEN: A mocked controller, and mocked os.path.exists
        mocked_controller = MagicMock()
        mocked_doc = MagicMock()
        mocked_controller.add_document.return_value = mocked_doc
        mocked_controller.supports = ['tmp']
        self.media_item.controllers = {
            'Mocked': mocked_controller
        }
        presentation_file = 'file.tmp'
        with patch('openlp.plugins.presentations.lib.mediaitem.os.path.exists') as mocked_exists:
            mocked_exists.return_value = False

            # WHEN: calling clean_up_thumbnails
            self.media_item.clean_up_thumbnails(presentation_file, True)

        # THEN: doc.presentation_deleted should have been called since the presentation file did not exists.
        mocked_doc.assert_has_calls([call.get_thumbnail_path(1, True), call.presentation_deleted()], True)
开发者ID:crossroadchurch,项目名称:paul,代码行数:23,代码来源:test_mediaitem.py

示例4: clean_up_thumbnails_test

# 需要导入模块: from tests.functional import MagicMock [as 别名]
# 或者: from tests.functional.MagicMock import supports [as 别名]
    def clean_up_thumbnails_test(self):
        """
        Test that the clean_up_thumbnails method works as expected when files exists.
        """
        # GIVEN: A mocked controller, and mocked os.path.getmtime
        mocked_controller = MagicMock()
        mocked_doc = MagicMock()
        mocked_controller.add_document.return_value = mocked_doc
        mocked_controller.supports = ['tmp']
        self.media_item.controllers = {
            'Mocked': mocked_controller
        }
        presentation_file = 'file.tmp'
        with patch('openlp.plugins.presentations.lib.mediaitem.os.path.getmtime') as mocked_getmtime, \
                patch('openlp.plugins.presentations.lib.mediaitem.os.path.exists') as mocked_exists:
            mocked_getmtime.side_effect = [100, 200]
            mocked_exists.return_value = True

            # WHEN: calling clean_up_thumbnails
            self.media_item.clean_up_thumbnails(presentation_file, True)

        # THEN: doc.presentation_deleted should have been called since the thumbnails mtime will be greater than
        #       the presentation_file's mtime.
        mocked_doc.assert_has_calls([call.get_thumbnail_path(1, True), call.presentation_deleted()], True)
开发者ID:crossroadchurch,项目名称:paul,代码行数:26,代码来源:test_mediaitem.py


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