testing new features
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
from cli.i18n import Translator, get_lang, set_lang, setup_i18n, t
|
||||
|
||||
|
||||
class TestTranslator:
|
||||
def test_ru_by_default(self):
|
||||
setup_i18n()
|
||||
assert get_lang() == "ru"
|
||||
|
||||
def test_ru_returns_russian(self):
|
||||
tr = Translator("ru")
|
||||
assert "финансовую" in tr.t("cmd.init.help")
|
||||
|
||||
def test_en_fallback_to_ru(self):
|
||||
tr = Translator("en")
|
||||
result = tr.t("cmd.init.help")
|
||||
assert "финансовую" in result
|
||||
|
||||
def test_unknown_key_returns_key(self):
|
||||
tr = Translator("ru")
|
||||
assert tr.t("nonexistent.key") == "nonexistent.key"
|
||||
|
||||
def test_set_lang(self):
|
||||
setup_i18n()
|
||||
set_lang("en")
|
||||
assert get_lang() == "en"
|
||||
|
||||
def test_t_function(self):
|
||||
setup_i18n()
|
||||
result = t("cmd.init.ok", path="data/model.json")
|
||||
assert "data/model.json" in result
|
||||
assert "Пустая" in result
|
||||
|
||||
def test_global_ok(self):
|
||||
result = t("global.ok")
|
||||
assert result == "OK"
|
||||
|
||||
def test_prompt_analyze(self):
|
||||
result = t("prompt.analyze")
|
||||
assert "AI-ассистент" in result
|
||||
|
||||
def test_custom_lang_init(self):
|
||||
tr = Translator("de")
|
||||
result = tr.t("cmd.init.help")
|
||||
assert "финансовую" in result # fallback to ru
|
||||
Reference in New Issue
Block a user