mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Added support of "startapp" deep links (#1648)
* Added "startapp" deep link support * Remove link_type param, added create_startapp_link method * Write tests for create_startapp_link method * Refactor with black & isort * Added CHANGELOG
This commit is contained in:
parent
cd4e811856
commit
de240b62ac
3 changed files with 50 additions and 2 deletions
|
|
@ -1,6 +1,10 @@
|
|||
import pytest
|
||||
|
||||
from aiogram.utils.deep_linking import create_start_link, create_startgroup_link
|
||||
from aiogram.utils.deep_linking import (
|
||||
create_start_link,
|
||||
create_startapp_link,
|
||||
create_startgroup_link,
|
||||
)
|
||||
from aiogram.utils.payload import decode_payload, encode_payload
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
|
@ -44,6 +48,10 @@ class TestDeepLinking:
|
|||
link = await create_startgroup_link(bot, payload)
|
||||
assert link == f"https://t.me/tbot?startgroup={payload}"
|
||||
|
||||
async def test_get_startapp_link(self, bot: MockedBot, payload: str):
|
||||
link = await create_startapp_link(bot, payload)
|
||||
assert link == f"https://t.me/tbot?startapp={payload}"
|
||||
|
||||
async def test_filter_encode_and_decode(self, payload: str):
|
||||
encoded = encode_payload(payload)
|
||||
decoded = decode_payload(encoded)
|
||||
|
|
@ -85,6 +93,15 @@ class TestDeepLinking:
|
|||
|
||||
assert link == f"https://t.me/tbot?start={encoded_payload}"
|
||||
|
||||
async def test_get_startapp_link_with_encoding(self, bot: MockedBot, wrong_payload: str):
|
||||
# define link
|
||||
link = await create_startapp_link(bot, wrong_payload, encode=True)
|
||||
|
||||
# define reference link
|
||||
encoded_payload = encode_payload(wrong_payload)
|
||||
|
||||
assert link == f"https://t.me/tbot?startapp={encoded_payload}"
|
||||
|
||||
async def test_64_len_payload(self, bot: MockedBot):
|
||||
payload = "p" * 64
|
||||
link = await create_start_link(bot, payload)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue