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


Python ThumbnailsPlugin._check_local_ok方法代码示例

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


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

示例1: test_check_local_ok

# 需要导入模块: from beetsplug.thumbnails import ThumbnailsPlugin [as 别名]
# 或者: from beetsplug.thumbnails.ThumbnailsPlugin import _check_local_ok [as 别名]
    def test_check_local_ok(self, mock_giouri, mock_pil, mock_im,
                            mock_artresizer, mock_os):
        # test local resizing capability
        mock_artresizer.shared.local = False
        plugin = ThumbnailsPlugin()
        self.assertFalse(plugin._check_local_ok())

        # test dirs creation
        mock_artresizer.shared.local = True

        def exists(path):
            if path == NORMAL_DIR:
                return False
            if path == LARGE_DIR:
                return True
            raise ValueError(u"unexpected path {0!r}".format(path))
        mock_os.path.exists = exists
        plugin = ThumbnailsPlugin()
        mock_os.makedirs.assert_called_once_with(NORMAL_DIR)
        self.assertTrue(plugin._check_local_ok())

        # test metadata writer function
        mock_os.path.exists = lambda _: True
        mock_pil.return_value = False
        mock_im.return_value = False
        with self.assertRaises(AssertionError):
            ThumbnailsPlugin()

        mock_pil.return_value = True
        self.assertEqual(ThumbnailsPlugin().write_metadata, write_metadata_pil)

        mock_im.return_value = True
        self.assertEqual(ThumbnailsPlugin().write_metadata, write_metadata_im)

        mock_pil.return_value = False
        self.assertEqual(ThumbnailsPlugin().write_metadata, write_metadata_im)

        self.assertTrue(ThumbnailsPlugin()._check_local_ok())

        # test URI getter function
        giouri_inst = mock_giouri.return_value
        giouri_inst.available = True
        self.assertEqual(ThumbnailsPlugin().get_uri, giouri_inst.uri)

        giouri_inst.available = False
        self.assertEqual(ThumbnailsPlugin().get_uri.__self__.__class__,
                         PathlibURI)
开发者ID:bryan-snyder,项目名称:beets,代码行数:49,代码来源:test_thumbnails.py


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