Reformat tests code and bump Makefile

This commit is contained in:
Alex Root Junior 2021-06-15 01:33:32 +03:00
parent 98de096f3b
commit 3d17984f59
16 changed files with 57 additions and 72 deletions

View file

@ -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)

View 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