test: фаза 4 — тесты extractors, ecosystem, i18n, metrics
- test_nexus.py: extract_pypi/go/npm, dispatch, edge cases (16 тестов) - test_i18n.py: RU/EN переводы, fallback, форматирование, web UI (10 тестов) - test_metrics.py: Prometheus endpoint (4 теста) - test_webhooks.py: _detect_ecosystem (6 тестов), Go/npm webhook fixtures - conftest.py: sample_nexus_go/npm_webhook fixtures - Всего: 85 тестов (было 50)
This commit is contained in:
47
tests/test_i18n.py
Normal file
47
tests/test_i18n.py
Normal file
@@ -0,0 +1,47 @@
|
||||
"""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
|
||||
Reference in New Issue
Block a user