From d0fca99ddad61470031fc86784b733ad2d833372 Mon Sep 17 00:00:00 2001 From: ENI Date: Tue, 27 Oct 2026 00:16:10 +0300 Subject: [PATCH] =?UTF-8?q?=D1=82=D0=B5=D1=81=D1=82=D1=8B:=20=D1=81=D0=B5?= =?UTF-8?q?=D1=81=D1=81=D0=B8=D1=8F=20=D0=B8=D0=B7=20data/tg.json=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=B4=D1=85=D0=B2=D0=B0=D1=82=D1=8B=D0=B2=D0=B0=D0=B5?= =?UTF-8?q?=D1=82=D1=81=D1=8F,=20=D0=B1=D0=B5=D0=B7=20=D1=84=D0=B0=D0=B9?= =?UTF-8?q?=D0=BB=D0=B0=20=E2=80=94=20=D0=B2=D1=8B=D0=BA=D0=BB=D1=8E=D1=87?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20(30=20passed)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_regress.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/test_regress.py b/tests/test_regress.py index 0bf96f9..7607016 100644 --- a/tests/test_regress.py +++ b/tests/test_regress.py @@ -186,8 +186,9 @@ def test_tag_command_readonly(monkeypatch): # ---------- 12. сессия Telegram: выключена без env, CVE в заголовке ---------- -def test_tgsess_disabled_without_env(monkeypatch): - from omni import tgsess +def test_tgsess_disabled_without_env(monkeypatch, tmp_path): + from omni import config, tgsess + monkeypatch.setattr(config, "DATA", tmp_path) # пустая папка: data/tg.json нет for k in ("OMNI_TG_SESSION", "OMNI_TG_API_ID", "OMNI_TG_API_HASH"): monkeypatch.delenv(k, raising=False) assert tgsess.enabled() is False @@ -195,6 +196,20 @@ def test_tgsess_disabled_without_env(monkeypatch): assert tgsess._key("@SomeChan/") == "SomeChan" +def test_tgsess_picks_up_file_config(monkeypatch, tmp_path): + """Креды из data/tg.json подхватываются без env.""" + import json as _json + from omni import config, tgsess + monkeypatch.setattr(config, "DATA", tmp_path) + for k in ("OMNI_TG_SESSION", "OMNI_TG_API_ID", "OMNI_TG_API_HASH", "OMNI_TG_LIMIT"): + monkeypatch.delenv(k, raising=False) + (tmp_path / "tg.json").write_text(_json.dumps( + {"session": "C:/tmp/x", "api_id": "123", "api_hash": "abc", "limit": "7"}), encoding="utf-8") + cfg = config.tg_cfg() + assert cfg["session"] == "C:/tmp/x" and cfg["limit"] == "7" + assert tgsess.enabled() is True + + def test_item_cve_prefix(): from types import SimpleNamespace from omni.feeds import _item