修正 Telegram 分類按鈕預設 callback
All checks were successful
CD Pipeline / deploy (push) Successful in 55s
All checks were successful
CD Pipeline / deploy (push) Successful in 55s
This commit is contained in:
@@ -164,7 +164,7 @@ class TrendTelegramBot:
|
||||
]
|
||||
return InlineKeyboardMarkup(keyboard)
|
||||
|
||||
def _get_category_keyboard(self, callback_prefix: str = "cat"):
|
||||
def _get_category_keyboard(self, callback_prefix: str = "trend"):
|
||||
"""建立分類選擇按鈕"""
|
||||
# 每行 3 個按鈕
|
||||
keyboard = []
|
||||
|
||||
@@ -50,6 +50,21 @@ def _run(coro):
|
||||
return asyncio.run(coro)
|
||||
|
||||
|
||||
def test_default_category_keyboard_uses_handled_trend_prefix():
|
||||
from services.telegram_bot_service import CATEGORIES, TrendTelegramBot
|
||||
|
||||
bot = TrendTelegramBot(token="dummy")
|
||||
keyboard = bot._get_category_keyboard()
|
||||
callback_values = [
|
||||
button.callback_data
|
||||
for row in keyboard.inline_keyboard
|
||||
for button in row
|
||||
]
|
||||
|
||||
assert f"trend_{CATEGORIES[0]}" in callback_values
|
||||
assert not any(value.startswith("cat_") for value in callback_values)
|
||||
|
||||
|
||||
def test_polling_callback_dedup_without_update_id(monkeypatch):
|
||||
from services.telegram_bot_service import TrendTelegramBot
|
||||
|
||||
|
||||
Reference in New Issue
Block a user