Update
This commit is contained in:
@@ -38,6 +38,32 @@ def test_private_text_message_emitted():
|
||||
assert messages[0]["chat_id"] == 42 and messages[0]["text"] == "hello"
|
||||
|
||||
|
||||
def test_callback_query_emitted():
|
||||
backend = FakeTelegramBackend()
|
||||
worker, frames = _worker(backend)
|
||||
_run(
|
||||
worker.process_update(
|
||||
{
|
||||
"update_id": 2,
|
||||
"callback_query": {
|
||||
"id": "cb1",
|
||||
"from": {"id": 7},
|
||||
"data": "i=del1;k=env;v=stg",
|
||||
"message": {
|
||||
"message_id": 9,
|
||||
"chat": {"id": 42, "type": "private"},
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
)
|
||||
callbacks = [f for f in frames if f["type"] == "callback"]
|
||||
assert len(callbacks) == 1
|
||||
assert callbacks[0]["chat_id"] == 42
|
||||
assert callbacks[0]["data"] == "i=del1;k=env;v=stg"
|
||||
assert callbacks[0]["callback_query_id"] == "cb1"
|
||||
|
||||
|
||||
def test_group_message_ignored():
|
||||
backend = FakeTelegramBackend()
|
||||
worker, frames = _worker(backend)
|
||||
@@ -78,14 +104,14 @@ def test_photo_becomes_data_uri():
|
||||
|
||||
def test_html_send_falls_back_to_plain_on_entity_error():
|
||||
class EntityBackend(FakeTelegramBackend):
|
||||
async def send_message(self, chat_id, text, parse_mode):
|
||||
async def send_message(self, chat_id, text, parse_mode, reply_markup=None):
|
||||
if parse_mode:
|
||||
return {
|
||||
"ok": False,
|
||||
"error_code": 400,
|
||||
"description": "Bad Request: can't parse entities",
|
||||
}
|
||||
return await super().send_message(chat_id, text, None)
|
||||
return await super().send_message(chat_id, text, None, reply_markup=reply_markup)
|
||||
|
||||
backend = EntityBackend()
|
||||
worker, frames = _worker(backend)
|
||||
|
||||
Reference in New Issue
Block a user