1.0.7 - polski interfejs i porządki w dokumentacji
Wydanie WGTools-Extended / release (push) Successful in 8s

This commit is contained in:
asminme committed 2026-10-30 15:04:45 +01:00
1 parent 97f73a6277
commit babbdee26d
39 files changed
+142 -24356

No files matched your search

+5 -39
View File
@@ -1,42 +1,8 @@
"""Prevent non-Russian, non-English help falling back to English again."""
from __future__ import annotations
import json
import unittest
from pathlib import Path
from app.core.help_content import HELP, get_help_sections
ROOT = Path(__file__).resolve().parents[1]
LANGUAGES = ('de', 'fr', 'it', 'es', 'pl')
class HelpTranslationTests(unittest.TestCase):
def test_all_five_help_dictionaries_loaded(self):
original = get_help_sections('en')
for language in LANGUAGES:
with self.subTest(language=language):
file = ROOT/'app/core/help_locales'/f'{language}.json'
self.assertTrue(file.is_file())
data = json.loads(file.read_text(encoding='utf8'))
self.assertEqual(data, get_help_sections(language))
self.assertEqual(len(data),len(original))
self.assertEqual([s['id'] for s in data], [s['id'] for s in original])
self.assertNotEqual(data[0]['title'], original[0]['title'])
self.assertNotEqual(data[0]['topics'][0]['paragraphs'][0],original[0]['topics'][0]['paragraphs'][0])
for section, ref_section in zip(data, original):
self.assertTrue(section['title'].strip())
self.assertTrue(section['intro'].strip())
self.assertEqual(len(section['topics']),len(ref_section['topics']))
for topic, reference in zip(section['topics'],ref_section['topics']):
self.assertTrue(topic['title'].strip())
self.assertTrue(all(x.strip() for x in topic['paragraphs']))
self.assertEqual(bool(topic['example_lines']),bool(reference['example_lines']))
self.assertEqual(bool(topic['warning']),bool(reference['warning']))
# Common technical terms such as Diagnostics can legitimately match English.
self.assertNotEqual(topic['paragraphs'][0],reference['paragraphs'][0],"untranslated help paragraph")
self.assertTrue(all(x.strip() for x in topic['bullets']))
def test_unknown_language_defaults_to_english(self):
self.assertEqual(get_help_sections('non-existent-language'), HELP['en'])
def test_version(self):
self.assertEqual((ROOT/'VERSION').read_text().strip(),'1.0.6')
if __name__ == '__main__':
unittest.main()
def test_help_is_polish():
sections = get_help_sections("pl")
assert sections and sections == HELP["pl"]
assert get_help_sections("en") == sections
assert all(section["title"] and section["topics"] for section in sections)
+8 -15
View File
@@ -15,21 +15,14 @@ LANGS = ('en', 'ru', 'de', 'fr', 'it', 'es', 'pl')
class CandidateTests(unittest.TestCase):
def test_versions_and_locale_fallback_contract(self):
self.assertEqual((ROOT / 'VERSION').read_text().strip(), '1.0.6')
en = json.loads((ROOT/'app/locales/en.json').read_text())
self.assertGreaterEqual(len(en), 1098)
for lang in LANGS:
content=(ROOT/'app/locales'/f'{lang}.json').read_bytes()
self.assertEqual(content,(ROOT/'app/static'/f'{lang}.json').read_bytes())
self.assertEqual(content,(ROOT/'app/static/locales'/f'{lang}.json').read_bytes())
data=json.loads(content)
self.assertEqual(set(data),set(en),lang)
# Every supported language resolves every possible UI key through English.
merged={**en,**data}
self.assertEqual(set(merged),set(en))
for key,value in data.items():
self.assertEqual(set(re.findall(r'\{\w+\}',value)),
set(re.findall(r'\{\w+\}',en[key])),(lang,key))
self.assertEqual((ROOT / 'VERSION').read_text().strip(), '1.0.7')
content = (ROOT / 'app/locales/pl.json').read_bytes()
self.assertEqual(content, (ROOT / 'app/static/pl.json').read_bytes())
self.assertEqual(content, (ROOT / 'app/static/locales/pl.json').read_bytes())
self.assertGreaterEqual(len(json.loads(content)), 1098)
# Poprzedni aktualizator wymaga tych plików podczas instalacji pakietu.
for old in ('en', 'ru'):
self.assertEqual(json.loads((ROOT / 'app/locales' / f'{old}.json').read_text()), {})
def test_delete_returns_exact_client_name_for_audit(self):
helper=runpy.run_path(str(ROOT/'scripts/wgtools-helper'))
+2 -2
View File
@@ -40,7 +40,7 @@ class Release405Tests(unittest.TestCase):
self.assertEqual([x["id"] for x in newer["items"]], [x["id"] for x in older["items"]])
self.assertNotIn("details", older["items"][0])
text, keyboard = telegram_bot.audit_screen("ru", recent)
self.assertIn("аудита", text)
self.assertIn("audytu", text)
self.assertIn("peer-44", text)
self.assertTrue(any(btn.get("callback_data", "").startswith("audit:before") for row in keyboard["inline_keyboard"] for btn in row))
@@ -88,7 +88,7 @@ class Release405Tests(unittest.TestCase):
with patch.object(telegram_bot, "send_message", lambda *a, **kw: sent.append(a[2])), patch.object(telegram_bot,"answer_callback"):
telegram_bot.handle_update(event, {"language":"en", "allowed_user_ids":[]}, "token")
self.assertEqual(len(sent), 1)
self.assertIn("Access denied", sent[0])
self.assertIn("Brak dostępu", sent[0])
def test_theme_and_audit_global_modal(self):
root = Path(__file__).resolve().parents[1]
+3 -3
View File
@@ -24,7 +24,7 @@ class AuditPresentationTests(unittest.TestCase):
def test_menu_label_and_clean_arrows(self):
menu = bot.main_keyboard("ru", 42)["inline_keyboard"]
audit_button = next(btn for row in menu for btn in row if btn["callback_data"] == "audit:latest")
self.assertEqual(audit_button["text"], "🧾 Аудит")
self.assertEqual(audit_button["text"], "🧾 Audyt")
for i in range(45):
audit.write_audit("admin", "client.created", object=f"wg0 · test-{i}", result="created")
newest = audit.list_audit_page(limit=20)
@@ -33,11 +33,11 @@ class AuditPresentationTests(unittest.TestCase):
self.assertIn("<code>", newest_text)
self.assertIn("test-44", newest_text)
self.assertEqual(len(newest["items"]), 20)
self.assertEqual([b["text"] for row in newest_kb["inline_keyboard"] for b in row], ["➡️", "⬅️ Меню"])
self.assertEqual([b["text"] for row in newest_kb["inline_keyboard"] for b in row], ["➡️", "⬅️ Menu"])
self.assertTrue(all(b["callback_data"] != "audit:latest" for row in newest_kb["inline_keyboard"] for b in row))
old = audit.list_audit_page(before_id=newest["items"][-1]["id"])
old_txt, old_kb = bot.audit_screen("ru", old)
self.assertEqual([b["text"] for row in old_kb["inline_keyboard"] for b in row], ["⬅️", "➡️", "⬅️ Меню"])
self.assertEqual([b["text"] for row in old_kb["inline_keyboard"] for b in row], ["⬅️", "➡️", "⬅️ Menu"])
self.assertEqual(old_kb["inline_keyboard"][0][0]["callback_data"], f"audit:after:{old['items'][0]['id']}")
self.assertEqual(old_kb["inline_keyboard"][0][1]["callback_data"], f"audit:before:{old['items'][-1]['id']}")
self.assertLess(len(old_txt), 4096)