-
-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Expand file tree
/
Copy pathtest_jm_plugin.py
More file actions
37 lines (29 loc) · 1.39 KB
/
Copy pathtest_jm_plugin.py
File metadata and controls
37 lines (29 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from test_jmcomic import *
class Test_Plugin(JmTestConfigurable):
def test_plugin_missing_album_context(self):
"""
source: https://github.com/hect0x7/JMComic-Crawler-Python/issues/523
测试当仅下载单章(photo)时,如果上下文中缺少 album 对象,
各个包含路径生成的插件(如 download_cover, img2pdf, long_img, zip)
是否能正确从 photo.from_album 中提取专辑属性,
避免解析需要 {Atitle} 等本子级占位符时报错 KeyError。
"""
photo_id = '350234'
option = self.new_option()
flawed_rule = {
'base_dir': option.dir_rule.base_dir,
'rule': '{Atitle}/{Aid}_photo.jpg'
}
from jmcomic.jm_downloader import DoNotDownloadImage
# 将四个需要校验的插件全部进行孤立测试,避免前一个插件后续报错导致循环终端
test_plugins = ['download_cover', 'img2pdf', 'long_img', 'zip']
option.plugins['before_photo'] = [
{
'plugin': plugin_key,
'kwargs': {'dir_rule': flawed_rule},
'safe': False # 防止内部catch异常
}
for plugin_key in test_plugins
]
download_photo(photo_id, option, downloader=DoNotDownloadImage)
print('✅ All folder rule plugins assert completed safely without KeyError.')