本文整理汇总了Python中beetsplug.thumbnails.ThumbnailsPlugin.config['force']方法的典型用法代码示例。如果您正苦于以下问题:Python ThumbnailsPlugin.config['force']方法的具体用法?Python ThumbnailsPlugin.config['force']怎么用?Python ThumbnailsPlugin.config['force']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类beetsplug.thumbnails.ThumbnailsPlugin
的用法示例。
在下文中一共展示了ThumbnailsPlugin.config['force']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_make_cover_thumbnail
# 需要导入模块: from beetsplug.thumbnails import ThumbnailsPlugin [as 别名]
# 或者: from beetsplug.thumbnails.ThumbnailsPlugin import config['force'] [as 别名]
def test_make_cover_thumbnail(self, mock_shutils, mock_os, mock_util,
mock_artresizer, _):
thumbnail_dir = os.path.normpath(b"/thumbnail/dir")
md5_file = os.path.join(thumbnail_dir, b"md5")
path_to_art = os.path.normpath(b"/path/to/art")
mock_os.path.join = os.path.join # don't mock that function
plugin = ThumbnailsPlugin()
plugin.add_tags = Mock()
album = Mock(artpath=path_to_art)
mock_util.syspath.side_effect = lambda x: x
plugin.thumbnail_file_name = Mock(return_value=b'md5')
mock_os.path.exists.return_value = False
def os_stat(target):
if target == md5_file:
return Mock(st_mtime=1)
elif target == path_to_art:
return Mock(st_mtime=2)
else:
raise ValueError(u"invalid target {0}".format(target))
mock_os.stat.side_effect = os_stat
plugin.make_cover_thumbnail(album, 12345, thumbnail_dir)
mock_os.path.exists.assert_called_once_with(md5_file)
mock_os.stat.has_calls([call(md5_file), call(path_to_art)],
any_order=True)
resize = mock_artresizer.shared.resize
resize.assert_called_once_with(12345, path_to_art, md5_file)
plugin.add_tags.assert_called_once_with(album, resize.return_value)
mock_shutils.move.assert_called_once_with(resize.return_value,
md5_file)
# now test with recent thumbnail & with force
mock_os.path.exists.return_value = True
plugin.force = False
resize.reset_mock()
def os_stat(target):
if target == md5_file:
return Mock(st_mtime=3)
elif target == path_to_art:
return Mock(st_mtime=2)
else:
raise ValueError(u"invalid target {0}".format(target))
mock_os.stat.side_effect = os_stat
plugin.make_cover_thumbnail(album, 12345, thumbnail_dir)
self.assertEqual(resize.call_count, 0)
# and with force
plugin.config['force'] = True
plugin.make_cover_thumbnail(album, 12345, thumbnail_dir)
resize.assert_called_once_with(12345, path_to_art, md5_file)