Files
live-app-translator/tests/test_config.py
EJClaw 8b36b244ff feat: LiveSub 2차 — 자막 on/off, 모니터·위치 선택, GPU 저부하, 게임 용어집
이름을 Hearo → LiveSub 로 변경. 말장난보다 하는 일이 바로 보이는 쪽이 낫다.

자막 on/off
- 전역 단축키 Ctrl+Alt+S (자막) / Ctrl+Alt+D (번역) — Windows RegisterHotKey +
  네이티브 이벤트 필터라 게임 창이 떠 있어도 동작. 다른 OS 에서는 no-op
- 단축키·체크박스·우클릭 메뉴가 모두 같은 경로를 타도록 통합

모니터 선택 + 디스코드식 배치
- placement.py: Qt 비의존 배치 계산 (모니터 목록 → 9분할 좌표)
- AnchorGrid 위젯으로 3x3 위치 선택, 드래그하면 자유 배치로 전환
- 모니터 구성이 바뀌어도 자막이 화면 밖으로 사라지지 않도록 클램프

GPU 저부하 모드 (기본 켜짐)
- 연산 정밀도 int8 강등, VRAM 상한 35%, 추론 후 60ms 양보,
  300초 무음 시 모델 언로드, 중간 결과 비활성
- 기본 티어를 균형(6GB) → 신속(4GB) 으로 하향
- 8GB GPU 기준 자막 2.8GB / 게임 5.2GB

게임 용어집 번들 (304개)
- 롤 74 · 발로란트 59 · 오버워치2 49 · FPS공통 46 · 마크 38 · 방송 38
- 체크박스로 켜고 끄며, 사용자가 직접 등록한 항목이 항상 우선

검증: pytest 91개 통과 (배치 14 + 팩 12 + UI 6 신규), ruff clean

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-09-21 17:49:26 +09:00

59 lines
1.7 KiB
Python

import json
from livesub.config import AppConfig
from livesub.models.tiers import DEFAULT_TIER
def test_defaults_are_sane():
cfg = AppConfig()
assert cfg.models.tier == DEFAULT_TIER
assert cfg.models.target_lang == "ko"
assert cfg.subtitle.font_size > 0
assert cfg.audio.silence_ms > 0
def test_save_load_roundtrip(tmp_path):
path = tmp_path / "config.json"
cfg = AppConfig()
cfg.subtitle.font_size = 52
cfg.subtitle.text_color = "#FF00AA"
cfg.models.tier = "precision"
cfg.audio.target_pid = 4242
cfg.save(path)
loaded = AppConfig.load(path)
assert loaded.subtitle.font_size == 52
assert loaded.subtitle.text_color == "#FF00AA"
assert loaded.models.tier == "precision"
assert loaded.audio.target_pid == 4242
def test_missing_file_gives_defaults(tmp_path):
assert AppConfig.load(tmp_path / "nope.json").models.tier == DEFAULT_TIER
def test_corrupt_file_gives_defaults(tmp_path):
path = tmp_path / "config.json"
path.write_text("{ this is not json", encoding="utf-8")
assert AppConfig.load(path).models.tier == DEFAULT_TIER
def test_unknown_keys_are_ignored_and_missing_keys_defaulted(tmp_path):
"""스키마가 바뀌어도 사용자의 기존 설정이 깨지면 안 된다."""
path = tmp_path / "config.json"
path.write_text(
json.dumps(
{
"theme": "light",
"removed_option": True,
"subtitle": {"font_size": 40, "gone_field": 1},
}
),
encoding="utf-8",
)
cfg = AppConfig.load(path)
assert cfg.theme == "light"
assert cfg.subtitle.font_size == 40
assert cfg.subtitle.bold is True # 기본값 유지
assert not hasattr(cfg, "removed_option")