test(telegram): cover smart_deny 2-button row structure

Follow-up for salvaged PR #70615 — the 2-button smart_deny case
(Allow Once + Deny only) was exercised by an existing test but only
at the flat-label level, not asserting the row pairing. Adds the
missing row-structure assertion using the same capture pattern as
the 4-button and 3-button tests.
This commit is contained in:
kshitijk4poor 2026-07-24 23:01:01 +05:00 committed by kshitij
parent 116a44f46e
commit 6ad632bf9b

View file

@ -196,6 +196,30 @@ class TestTelegramExecApproval:
["❌ Deny"],
]
@pytest.mark.asyncio
async def test_smart_deny_two_buttons_share_one_row(self, monkeypatch):
"""smart_deny yields 2 buttons — they pair into a single readable row."""
adapter = _make_adapter()
adapter._bot.send_message = AsyncMock(return_value=SimpleNamespace(message_id=42))
captured_rows = []
monkeypatch.setattr(
"plugins.platforms.telegram.adapter.InlineKeyboardButton",
lambda text, callback_data: text,
)
monkeypatch.setattr(
"plugins.platforms.telegram.adapter.InlineKeyboardMarkup",
lambda rows: captured_rows.extend(rows) or rows,
)
await adapter.send_exec_approval(
chat_id="12345", command="curl example.test", session_key="s",
allow_permanent=False, smart_denied=True,
)
assert captured_rows == [
["✅ Allow Once", "❌ Deny"],
]
@pytest.mark.asyncio
async def test_stores_approval_state(self):
adapter = _make_adapter()