fix(anime): 파이프라인 5건 수정 — 에피소드 정규식(v2/S01E), 릴리스 그룹 필터, 자막 보호, 배치 다운로드, 타임아웃
This commit is contained in:
119
tests/test_cli_tools.py
Normal file
119
tests/test_cli_tools.py
Normal file
@@ -0,0 +1,119 @@
|
||||
"""Full integration test — all tools + architecture + pipeline."""
|
||||
import sys, os, asyncio
|
||||
_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
sys.path.insert(0, _root)
|
||||
OUT = os.path.join(_root, "tests", "cli_test_output.txt")
|
||||
|
||||
lines = []
|
||||
|
||||
# ===== 1. Architecture: imports =====
|
||||
lines.append("=== Architecture Imports ===")
|
||||
tests = [
|
||||
("core.gemini_caller", "GeminiCaller, GeminiCallError"),
|
||||
("core.orchestrator", "Orchestrator"),
|
||||
("core.task_pipeline", "TaskPipeline"),
|
||||
("tools.anime_pipeline", "AnimePipeline"),
|
||||
("tools.anissia_client", "AnissiaClient"),
|
||||
("tools.nyaa_client", "NyaaClient"),
|
||||
("tools.qbit_client", "QBitClient"),
|
||||
("tools.nas_scanner", "NasScanner"),
|
||||
("tools.title_matcher", "match_titles, japanese_to_romaji"),
|
||||
("tools.subtitle_downloader", "SubtitleDownloader"),
|
||||
("handlers.renderer", "safe_send_embed"),
|
||||
]
|
||||
for mod, names in tests:
|
||||
try:
|
||||
exec(f"from {mod} import {names}")
|
||||
lines.append(f" OK {mod}")
|
||||
except Exception as e:
|
||||
lines.append(f" FAIL {mod}: {e}")
|
||||
|
||||
# ===== 2. Deleted files =====
|
||||
lines.append("\n=== Deleted Files ===")
|
||||
for f in ["tools/base.py", "tools/registry.py", "tools/anime_tool.py",
|
||||
"prompts/planner.md", "prompts/coder.md", "prompts/summarizer.md"]:
|
||||
exists = os.path.exists(os.path.join(_root, f))
|
||||
lines.append(f" {'FAIL exists' if exists else 'OK deleted'} {f}")
|
||||
|
||||
# ===== 3. Required files =====
|
||||
lines.append("\n=== Required Files ===")
|
||||
for f in ["prompts/agent.md", "prompts/unified.md", "prompts/reviewer.md",
|
||||
".gemini/skills/anime/SKILL.md"]:
|
||||
exists = os.path.exists(os.path.join(_root, f))
|
||||
lines.append(f" {'OK' if exists else 'FAIL missing'} {f}")
|
||||
|
||||
# ===== 4. Title Matcher (pykakasi) =====
|
||||
lines.append("\n=== Title Matcher ===")
|
||||
from tools.title_matcher import japanese_to_romaji, title_similarity
|
||||
cases = [
|
||||
("sousouno furiiren", "sousou no furiiren"),
|
||||
("Sousou no Frieren", "sousou no furiiren"),
|
||||
]
|
||||
romaji = japanese_to_romaji("sousouno furiiren")
|
||||
lines.append(f" pykakasi('sousouno furiiren'): {romaji}")
|
||||
for a, b in cases:
|
||||
sim = title_similarity(a, b)
|
||||
lines.append(f" sim('{a[:30]}', '{b[:30]}'): {sim:.3f}")
|
||||
|
||||
# ===== 5. NAS Scanner =====
|
||||
lines.append("\n=== NAS Scanner ===")
|
||||
from tools.nas_scanner import NasScanner
|
||||
scanner = NasScanner()
|
||||
lines.append(f" accessible: {scanner.is_accessible()}")
|
||||
if scanner.is_accessible():
|
||||
folders = scanner.list_anime_folders()
|
||||
lines.append(f" total folders: {len(folders)}")
|
||||
current = scanner.get_current_quarter_anime()
|
||||
lines.append(f" current quarter: {len(current)} anime")
|
||||
for f in current[:5]:
|
||||
lines.append(f" {f.folder_name} vid:{f.video_count} sub:{f.subtitle_count}")
|
||||
|
||||
# ===== 6. Async tests =====
|
||||
async def async_tests():
|
||||
# 6a. Anissia search
|
||||
lines.append("\n=== Anissia Search ===")
|
||||
from tools.anissia_client import AnissiaClient
|
||||
ac = AnissiaClient()
|
||||
for kw in ["frieren", "sousou"]:
|
||||
r = await ac.search_anime(kw)
|
||||
lines.append(f" '{kw}': {len(r)} results")
|
||||
|
||||
# 6b. Nyaa search
|
||||
lines.append("\n=== Nyaa Search ===")
|
||||
from tools.nyaa_client import NyaaClient
|
||||
nc = NyaaClient()
|
||||
r = await nc.search("Sousou no Frieren", use_default_suffix=True)
|
||||
lines.append(f" 'Sousou no Frieren ASW HEVC': {len(r)} results")
|
||||
if r:
|
||||
lines.append(f" top: [{r[0].group}] {r[0].title[:50]} S:{r[0].seeders}")
|
||||
|
||||
# 6c. Pipeline search
|
||||
lines.append("\n=== Pipeline Search ===")
|
||||
from tools.anime_pipeline import AnimePipeline
|
||||
pipe = AnimePipeline()
|
||||
try:
|
||||
result = await pipe.search("sousou")
|
||||
lines.append(f" success: {result.success}")
|
||||
lines.append(f" anime: {result.anime.subject if result.anime else 'None'}")
|
||||
lines.append(f" captions: {len(result.captions)}")
|
||||
lines.append(f" torrents: {len(result.torrents)}")
|
||||
lines.append(f" nas_folder: {result.nas_folder}")
|
||||
if result.errors:
|
||||
lines.append(f" errors: {'; '.join(result.errors[:3])}")
|
||||
except Exception as e:
|
||||
lines.append(f" ERROR: {e}")
|
||||
|
||||
# 6d. qBittorrent
|
||||
lines.append("\n=== qBittorrent ===")
|
||||
from tools.qbit_client import QBitClient
|
||||
qb = QBitClient()
|
||||
info = await qb.test_connection()
|
||||
lines.append(f" connected: {info.get('connected')}")
|
||||
if info.get('connected'):
|
||||
lines.append(f" version: {info.get('version')}")
|
||||
|
||||
asyncio.run(async_tests())
|
||||
|
||||
lines.append("\n=== ALL TESTS DONE ===")
|
||||
with open(OUT, "w", encoding="utf-8-sig") as f:
|
||||
f.write("\n".join(lines))
|
||||
Reference in New Issue
Block a user