Archived
This commit is contained in:
1 parent
aadc19341d
commit
3841e93e32
13 files changed
+73
-24
No files matched your search
@@ -36,7 +36,7 @@ class HelpTranslationTests(unittest.TestCase):
|
||||
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.2')
|
||||
self.assertEqual((ROOT/'VERSION').read_text().strip(),'1.0.3')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,28 @@
|
||||
from app.core import audit, preferences
|
||||
|
||||
|
||||
def test_settings_are_loaded_in_batches(tmp_path, monkeypatch):
|
||||
monkeypatch.setattr(preferences, 'DATABASE_PATH', str(tmp_path / 'settings.db'))
|
||||
original = preferences._connect
|
||||
connections = []
|
||||
def connect():
|
||||
connections.append(1)
|
||||
return original()
|
||||
monkeypatch.setattr(preferences, '_connect', connect)
|
||||
assert preferences.get_preferences()['refresh_seconds'] == max(2, min(preferences.REFRESH_SECONDS, 60))
|
||||
assert len(connections) == 2
|
||||
connections.clear()
|
||||
assert preferences.get_branding()['name'] == 'WGTools-Extended'
|
||||
assert len(connections) == 2
|
||||
|
||||
|
||||
def test_historical_connection_lookup_uses_index(tmp_path, monkeypatch):
|
||||
monkeypatch.setattr(audit, 'DATABASE_PATH', str(tmp_path / 'audit.db'))
|
||||
audit.init_audit_database()
|
||||
with audit._connection() as conn:
|
||||
plan = conn.execute(
|
||||
"EXPLAIN QUERY PLAN SELECT created_at,details FROM audit_log "
|
||||
"WHERE action='wireguard.client_connected' AND object=? "
|
||||
"ORDER BY created_at DESC,id DESC LIMIT 1", ('wg0 · klient',)
|
||||
).fetchall()
|
||||
assert any('idx_audit_connection_lookup' in str(row[3]) for row in plan)
|
||||
@@ -15,7 +15,7 @@ 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.2')
|
||||
self.assertEqual((ROOT / 'VERSION').read_text().strip(), '1.0.3')
|
||||
en = json.loads((ROOT/'app/locales/en.json').read_text())
|
||||
self.assertGreaterEqual(len(en), 1098)
|
||||
for lang in LANGS:
|
||||
|
||||
Reference in new issue
Block a user