From 3e14a23e0214bd59341859127708efdafddd8568 Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Thu, 7 May 2026 22:27:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20markets=20=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=EF=BC=9A=E7=A7=BB=E9=99=A4=E5=AF=B9=E5=B7=B2=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=87=BD=E6=95=B0=20build=5Fmarket=5Fmonitor=5Fdigest?= =?UTF-8?q?=20=E7=9A=84=20monkeypatch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tested: python -m pytest tests/test_bot_basic_handler.py -xvs --- tests/test_bot_basic_handler.py | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/tests/test_bot_basic_handler.py b/tests/test_bot_basic_handler.py index 68b838fc..663026ad 100644 --- a/tests/test_bot_basic_handler.py +++ b/tests/test_bot_basic_handler.py @@ -76,7 +76,7 @@ def test_basic_handler_diag_returns_html(): assert "Bot 启动诊断" in bot.replies[0]["text"] -def test_basic_handler_markets_returns_summary(monkeypatch): +def test_basic_handler_markets_returns_summary(): bot = DummyBot() io_layer = SimpleNamespace( build_welcome_text=lambda: "WELCOME", @@ -95,25 +95,11 @@ def test_basic_handler_markets_returns_summary(monkeypatch): config={}, ) - monkeypatch.setattr( - "src.utils.telegram_push.build_market_monitor_digest", - lambda config, slot_label="当前概览", top_n=None, force_refresh=False: "MARKET DIGEST", - ) - monkeypatch.setattr( - "src.utils.telegram_push.load_cached_market_monitor_digest", - lambda: "", - ) - monkeypatch.setattr( - "src.bot.handlers.basic.threading.Thread", - lambda target, name=None, daemon=None: SimpleNamespace(start=target), - ) - handler.handle_markets(_message("/markets")) assert len(bot.replies) == 1 - assert "正在生成当前市场概览" in bot.replies[0]["text"] - assert len(bot.sent_messages) == 1 - assert bot.sent_messages[0]["text"] == "MARKET DIGEST" + assert "市场概览" in bot.replies[0]["text"] + assert "已移除" in bot.replies[0]["text"] def test_basic_handler_markets_rejects_channel_chat():