사용자가 필수로 지정한 게임 중 오버워치를 뺀 세 개가 빠져 있었다. - 레인보우 식스 시즈 67개 — 보강·하드브리치·앵커/로머·디퓨저·런아웃 - 배틀그라운드 66개 — 자기장·어부·낙하·파밍·3렙헬멧·스쿼드 콜 - 워치독스 59개 — 데드섹·ctOS·블룸·알비온 등 조직명과 해킹/잠입 용어 - 에이펙스 레전드 45개 — 링·배너·리스폰 비컨 (등등 항목으로 추가) 워치독스는 멀티 콜아웃이 아니라 스토리 대사가 주라, 번역기가 특히 잘 틀리는 고유명사(조직명)와 해킹 용어 위주로 골랐다. 전용 팩이 생긴 만큼 'FPS 공통' 설명을 장르 공통 콜로 좁혔다. 필수 게임이 빠지면 바로 잡히도록 test_required_games_are_bundled 추가. 번들 용어 304개 → 541개 (10개 팩) 검증: pytest 92개 통과, ruff clean Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
105 lines
4.0 KiB
Python
105 lines
4.0 KiB
Python
"""기본 제공 게임 용어집 팩."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from livesub.constants import LANGUAGE_CODES
|
|
from livesub.models.glossary import Glossary, GlossaryEntry
|
|
from livesub.models.packs import available_packs, build_glossary, get_pack
|
|
|
|
#: 사용자가 "필수 게임"으로 지정한 것 — 빠지면 테스트가 잡아낸다.
|
|
REQUIRED_GAMES = {"overwatch", "watchdogs", "pubg", "r6siege"}
|
|
EXPECTED_PACKS = REQUIRED_GAMES | {
|
|
"lol", "valorant", "apex", "fps-common", "minecraft", "streaming",
|
|
}
|
|
|
|
|
|
def test_bundled_packs_are_loadable():
|
|
keys = {p.key for p in available_packs()}
|
|
assert keys >= EXPECTED_PACKS, f"빠진 팩: {EXPECTED_PACKS - keys}"
|
|
|
|
|
|
def test_required_games_are_bundled():
|
|
"""사용자가 직접 지정한 게임은 반드시 들어 있어야 한다."""
|
|
keys = {p.key for p in available_packs()}
|
|
assert keys >= REQUIRED_GAMES, f"필수 게임 팩 누락: {REQUIRED_GAMES - keys}"
|
|
|
|
|
|
def test_every_pack_has_entries_and_metadata():
|
|
for pack in available_packs():
|
|
assert pack.name, pack.key
|
|
assert pack.description, pack.key
|
|
assert len(pack) >= 30, f"{pack.key} 는 용어가 너무 적습니다 ({len(pack)}개)"
|
|
|
|
|
|
def test_every_entry_has_a_korean_target():
|
|
"""주 용도가 '외국어 → 한국어' 이므로 한국어 역어는 반드시 있어야 한다."""
|
|
for pack in available_packs():
|
|
for entry in pack.entries:
|
|
assert entry.target_for("ko"), f"{pack.key}: {entry.source} 에 한국어 역어 없음"
|
|
|
|
|
|
def test_targets_only_use_supported_languages():
|
|
for pack in available_packs():
|
|
for entry in pack.entries:
|
|
unknown = set(entry.targets) - set(LANGUAGE_CODES)
|
|
assert not unknown, f"{pack.key}: {entry.source} 에 미지원 언어 {unknown}"
|
|
|
|
|
|
def test_no_duplicate_sources_inside_a_pack():
|
|
for pack in available_packs():
|
|
seen = [e.source.casefold() for e in pack.entries]
|
|
dupes = {s for s in seen if seen.count(s) > 1}
|
|
assert not dupes, f"{pack.key} 에 중복 용어: {dupes}"
|
|
|
|
|
|
def test_known_terms_are_present():
|
|
def sources_of(key: str) -> set[str]:
|
|
return {e.source.casefold() for e in get_pack(key).entries}
|
|
|
|
assert {"baron", "gank", "nexus", "ult"} <= sources_of("lol")
|
|
assert {"spike", "defuse", "eco", "retake"} <= sources_of("valorant")
|
|
assert {"drone", "anchor", "roamer", "defuser", "hard breach"} <= sources_of("r6siege")
|
|
assert {"blue zone", "third party", "chicken dinner", "knocked"} <= sources_of("pubg")
|
|
assert {"dedsec", "ctos", "blume", "backdoor"} <= sources_of("watchdogs")
|
|
assert {"ring", "banner", "respawn beacon"} <= sources_of("apex")
|
|
|
|
|
|
def test_get_pack_returns_none_for_unknown():
|
|
assert get_pack("no-such-game") is None
|
|
|
|
|
|
def test_build_glossary_merges_packs():
|
|
merged = build_glossary(Glossary(), ["lol"])
|
|
protected, repl = merged.protect("push to the Nexus", "ko")
|
|
# 'push' 와 'Nexus' 둘 다 LoL 팩에 있으므로 둘 다 잡힌다.
|
|
assert repl == ["푸시", "넥서스"]
|
|
assert "Nexus" not in protected
|
|
assert Glossary.restore(protected, repl) == "푸시 to the 넥서스"
|
|
|
|
|
|
def test_user_entry_beats_pack_entry():
|
|
"""기본 팩 역어가 마음에 안 들면 직접 등록한 것이 이겨야 한다."""
|
|
user = Glossary([GlossaryEntry("baron", {"ko": "바론둥이"})])
|
|
merged = build_glossary(user, ["lol"])
|
|
_, repl = merged.protect("baron", "ko")
|
|
assert repl == ["바론둥이"]
|
|
|
|
|
|
def test_unknown_pack_key_is_ignored_not_fatal():
|
|
merged = build_glossary(Glossary(), ["lol", "does-not-exist"])
|
|
assert len(merged) > 0
|
|
|
|
|
|
def test_multiple_packs_combine():
|
|
only_lol = build_glossary(Glossary(), ["lol"])
|
|
both = build_glossary(Glossary(), ["lol", "minecraft"])
|
|
assert len(both) > len(only_lol)
|
|
_, repl = both.protect("creeper", "ko")
|
|
assert repl == ["크리퍼"]
|
|
|
|
|
|
def test_no_packs_means_only_user_entries():
|
|
user = Glossary([GlossaryEntry("foo", {"ko": "푸"})])
|
|
merged = build_glossary(user, [])
|
|
assert len(merged) == 1
|