mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Reformat tests code and bump Makefile
This commit is contained in:
parent
98de096f3b
commit
3d17984f59
16 changed files with 57 additions and 72 deletions
|
|
@ -7,12 +7,8 @@ from aiogram.utils.deep_linking import (
|
|||
decode_payload,
|
||||
encode_payload,
|
||||
)
|
||||
|
||||
# enable asyncio mode
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
PAYLOADS = [
|
||||
"foo",
|
||||
"AAbbCCddEEff1122334455",
|
||||
|
|
@ -58,6 +54,7 @@ def get_bot_user_fixture(monkeypatch):
|
|||
monkeypatch.setattr(MockedBot, "me", get_bot_user_mock)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
class TestDeepLinking:
|
||||
async def test_get_start_link(self, bot, payload):
|
||||
link = await create_start_link(bot=bot, payload=payload)
|
||||
|
|
|
|||
24
tests/test_utils/test_link.py
Normal file
24
tests/test_utils/test_link.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
from typing import Any, Dict
|
||||
|
||||
import pytest
|
||||
|
||||
from aiogram.utils.link import create_telegram_link, create_tg_link
|
||||
|
||||
|
||||
class TestLink:
|
||||
@pytest.mark.parametrize(
|
||||
"base,params,result",
|
||||
[["user", dict(id=42), "tg://user?id=42"]],
|
||||
)
|
||||
def test_create_tg_link(self, base: str, params: Dict[str, Any], result: str):
|
||||
assert create_tg_link(base, **params) == result
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"base,params,result",
|
||||
[
|
||||
["username", dict(), "https://t.me/username"],
|
||||
["username", dict(start="test"), "https://t.me/username?start=test"],
|
||||
],
|
||||
)
|
||||
def test_create_telegram_link(self, base: str, params: Dict[str, Any], result: str):
|
||||
assert create_telegram_link(base, **params) == result
|
||||
Loading…
Add table
Add a link
Reference in a new issue