"""Tests for i18n module.""" import pytest from guarddog_nexus.i18n import LANGUAGES, t class TestTranslate: def test_english(self): assert t("nav_dashboard", "en") == "Dashboard" assert t("nav_scans", "en") == "Scans" def test_russian(self): assert t("nav_dashboard", "ru") == "Панель" assert t("nav_scans", "ru") == "Сканирования" def test_default_lang(self): assert t("nav_dashboard") == "Dashboard" def test_unknown_key(self): assert t("nonexistent_key", "en") == "nonexistent_key" def test_unknown_lang_falls_back(self): assert t("nav_dashboard", "fr") == "Dashboard" def test_positional_formatting(self): result = t("total_scans", "en", 42) assert "42" in result assert "total scans" in result.lower() def test_languages_dict(self): assert "en" in LANGUAGES assert "ru" in LANGUAGES @pytest.mark.asyncio async def test_web_lang_ru(client): resp = await client.get("/scans?lang=ru") assert resp.status_code == 200 assert "Сканирования" in resp.text @pytest.mark.asyncio async def test_web_lang_en(client): resp = await client.get("/scans?lang=en") assert resp.status_code == 200 assert "Scans" in resp.text