From 987c6d6e48442c480c66df6670b290a60aa180d8 Mon Sep 17 00:00:00 2001 From: sheldygg Date: Mon, 31 Oct 2022 09:10:18 +0200 Subject: [PATCH] adding new tests --- tests/test_api/test_types/test_user.py | 4 ++-- .../test_types/test_user_mention_html.py | 20 +++++++++++++++++++ .../test_types/test_user_mention_markdown.py | 20 +++++++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 tests/test_api/test_types/test_user_mention_html.py create mode 100644 tests/test_api/test_types/test_user_mention_markdown.py diff --git a/tests/test_api/test_types/test_user.py b/tests/test_api/test_types/test_user.py index 98198dbd..0e99fb29 100644 --- a/tests/test_api/test_types/test_user.py +++ b/tests/test_api/test_types/test_user.py @@ -15,6 +15,6 @@ class TestUser: [" ", " ", " "], ], ) - def test_get_mention_html(self, first: str, last: str, result: bool): + def test_full_name(self, first: str, last: str, result: bool): user = User(id=42, is_bot=False, first_name=first, last_name=last) - assert user.mention_html() + assert user.full_name == result \ No newline at end of file diff --git a/tests/test_api/test_types/test_user_mention_html.py b/tests/test_api/test_types/test_user_mention_html.py new file mode 100644 index 00000000..98198dbd --- /dev/null +++ b/tests/test_api/test_types/test_user_mention_html.py @@ -0,0 +1,20 @@ +import pytest + +from aiogram.types import User + + +class TestUser: + @pytest.mark.parametrize( + "first,last,result", + [ + ["User", None, "User"], + ["", None, ""], + [" ", None, " "], + ["User", "Name", "User Name"], + ["User", " ", "User "], + [" ", " ", " "], + ], + ) + def test_get_mention_html(self, first: str, last: str, result: bool): + user = User(id=42, is_bot=False, first_name=first, last_name=last) + assert user.mention_html() diff --git a/tests/test_api/test_types/test_user_mention_markdown.py b/tests/test_api/test_types/test_user_mention_markdown.py new file mode 100644 index 00000000..d5602d6b --- /dev/null +++ b/tests/test_api/test_types/test_user_mention_markdown.py @@ -0,0 +1,20 @@ +import pytest + +from aiogram.types import User + + +class TestUser: + @pytest.mark.parametrize( + "first,last,result", + [ + ["User", None, "User"], + ["", None, ""], + [" ", None, " "], + ["User", "Name", "User Name"], + ["User", " ", "User "], + [" ", " ", " "], + ], + ) + def test_get_mention_markdown(self, first: str, last: str, result: bool): + user = User(id=42, is_bot=False, first_name=first, last_name=last) + assert user.mention_markdown()