From 892b8b3061e2b609b23d08cddce7a92eb9553e7f Mon Sep 17 00:00:00 2001 From: Fedor Borshev Date: Tue, 1 Oct 2024 11:37:52 +0300 Subject: [PATCH] Homework answers: better link display --- src/apps/homework/models/answer.py | 2 +- src/apps/homework/tests/homework/answers/tests_answer_str.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/apps/homework/models/answer.py b/src/apps/homework/models/answer.py index 67ded6ece9b..18d1506e158 100644 --- a/src/apps/homework/models/answer.py +++ b/src/apps/homework/models/answer.py @@ -102,7 +102,7 @@ def __str__(self) -> str: first_word = "" resource = urlparse(first_word).netloc if resource: - return f'Ссылка на {resource.split(".")[-2]}' + return f"Ссылка на {resource}" return textwrap.shorten(text, width=40) diff --git a/src/apps/homework/tests/homework/answers/tests_answer_str.py b/src/apps/homework/tests/homework/answers/tests_answer_str.py index 9e065b9bd1e..43ad3b8df05 100644 --- a/src/apps/homework/tests/homework/answers/tests_answer_str.py +++ b/src/apps/homework/tests/homework/answers/tests_answer_str.py @@ -27,8 +27,9 @@ def test_looooooong_words(mixer): @pytest.mark.parametrize( ("long_word", "expected_string"), [ - ("https://miro.com/app/board/asdasdzxcasd123=/?share_link_id=604444977722", "Ссылка на miro"), - ("1. http://pivo.com:8000/app/board/asdasdzxcasd123=/?share_link_id=604444977722\nNice work bro", "Ссылка на pivo"), + ("https://miro.com/app/board/asdasdzxcasd123=/?share_link_id=604444977722", "Ссылка на miro.com"), + ("1. http://pivo.com/app/board/asdasdzxcasd123=/?share_link_id=604444977722\nNice work bro", "Ссылка на pivo.com"), + ("https://drive.google.com/file/d/FhyDbwTAEbgSYQdv4vmceAkbsn7QKDFH/view?usp=sharing", "Ссылка на drive.google.com"), ], ) def test_starts_with_link(mixer, long_word, expected_string):