From e0a4bc8f8bd72552286062ccc1705a11ed049b0e Mon Sep 17 00:00:00 2001 From: Alex Root Junior Date: Sun, 13 Aug 2023 17:16:01 +0300 Subject: [PATCH] Tests coverage --- aiogram/utils/text_decorations.py | 2 ++ tests/test_utils/test_text_decorations.py | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/aiogram/utils/text_decorations.py b/aiogram/utils/text_decorations.py index 693e0583..eaff6f2c 100644 --- a/aiogram/utils/text_decorations.py +++ b/aiogram/utils/text_decorations.py @@ -74,6 +74,8 @@ class TextDecoration(ABC): if entity.type == MessageEntityType.CUSTOM_EMOJI: return self.custom_emoji(value=text, custom_emoji_id=cast(str, entity.custom_emoji_id)) + # This case is not possible because of `if` above, but if any new entity is added to + # API it will be here too return self.quote(text) def unparse(self, text: str, entities: Optional[List[MessageEntity]] = None) -> str: diff --git a/tests/test_utils/test_text_decorations.py b/tests/test_utils/test_text_decorations.py index 7cf12bc7..25f222f0 100644 --- a/tests/test_utils/test_text_decorations.py +++ b/tests/test_utils/test_text_decorations.py @@ -113,6 +113,14 @@ class TestTextDecoration: ): assert decorator.apply_entity(entity, "test") == result + def test_unknown_apply_entity(self): + assert ( + html_decoration.apply_entity( + MessageEntity(type="unknown", offset=0, length=5), "" + ) + == "<test>" + ) + @pytest.mark.parametrize( "decorator,before,after", [