Skip to content

Commit 4cec892

Browse files
committed
fix: 修复 test_jm_feature 测试失败,同步更新命名规则并新增 photo 级测试
1 parent ba87827 commit 4cec892

1 file changed

Lines changed: 21 additions & 7 deletions

File tree

tests/test_jmcomic/test_jm_feature.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,11 @@ def test_export_features(self):
126126
album, dler = jmcomic.download_album(album_id, self.option, extra=combo)
127127

128128
# 验证文件是否精确生成
129-
# 通过 download_album 注册,动态适配后:
130-
# PDF: Atitle(不变) → [album标题].pdf
131-
# ZIP: Ptitle→Atitle → [album标题].zip
132-
# PNG: Pid→Aid → [album_id].png
133-
pdf_name = DirRule.apply_rule_to_filename(album, None, 'Atitle') + '.pdf'
134-
zip_name = DirRule.apply_rule_to_filename(album, None, 'Atitle') + '.zip'
135-
png_name = DirRule.apply_rule_to_filename(album, None, 'Aid') + '.png'
129+
# 通过 download_album 注册,动态适配后默认规则均为:[JM{Aid}]{Atitle}
130+
rule = '[JM{Aid}]{Atitle}'
131+
pdf_name = DirRule.apply_rule_to_filename(album, None, rule) + '.pdf'
132+
zip_name = DirRule.apply_rule_to_filename(album, None, rule) + '.zip'
133+
png_name = DirRule.apply_rule_to_filename(album, None, rule) + '.png'
136134

137135
import os
138136
pdf_path = os.path.join(export_dir, pdf_name)
@@ -142,3 +140,19 @@ def test_export_features(self):
142140
self.assertTrue(os.path.exists(pdf_path), f"未生成精确匹配的 PDF 文件: {pdf_path}")
143141
self.assertTrue(os.path.exists(zip_path), f"未生成精确匹配的 ZIP 文件: {zip_path}")
144142
self.assertTrue(os.path.exists(png_path), f"未生成精确匹配的 PNG 长图: {png_path}")
143+
144+
def test_export_features_photo(self):
145+
photo_id = '438516'
146+
export_dir = self.option.dir_rule.base_dir
147+
148+
# 测试单个章节的 PDF 导出
149+
f_pdf = Feature.export_pdf(pdf_dir=export_dir)
150+
photo, dler = jmcomic.download_photo(photo_id, self.option, extra=f_pdf)
151+
152+
# 验证文件是否按照 [JM{Pid}]{Ptitle} 规则生成
153+
rule = '[JM{Pid}]{Ptitle}'
154+
pdf_name = DirRule.apply_rule_to_filename(None, photo, rule) + '.pdf'
155+
156+
import os
157+
pdf_path = os.path.join(export_dir, pdf_name)
158+
self.assertTrue(os.path.exists(pdf_path), f"未生成精确匹配的 PDF 文件 (章节级): {pdf_path}")

0 commit comments

Comments
 (0)