Skip to content

Commit

Permalink
Homework answers: better link display (#2420)
Browse files Browse the repository at this point in the history
  • Loading branch information
f213 authored Oct 1, 2024
1 parent 1949999 commit 7775fb8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/apps/homework/models/answer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
5 changes: 3 additions & 2 deletions src/apps/homework/tests/homework/answers/tests_answer_str.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 7775fb8

Please sign in to comment.