Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEVSHAD-96 feat contest catch exceptions #942

Merged
merged 20 commits into from
Feb 10, 2025

Conversation

cin-bun
Copy link
Collaborator

@cin-bun cin-bun commented Feb 6, 2025

https://st.yandex-team.ru/DEVSHAD-96
connected with: cscenter/site-frontend#500

Если нам вернулось 400 на запрос с message про дублирование

Screenshot 2025-02-06 at 18 46 57

Если нам вернулось 400 не про дублирование или другие code<500

Screenshot 2025-02-06 at 18 47 07

Если нам вернулось 5xx ошибки

Screenshot 2025-02-06 at 18 47 47

Если у нас Timeout или ConnectionError и мы делаем retry

Screenshot 2025-02-06 at 19 25 59

Checklist:

  • I have performed a self-review of my own code:
    • Good naming: make sure you would understand your code if you read it a few months from now.
    • No common performance issues (e.g. N + 1 problem)
    • Unrelated code has been removed (unused imports, print statements, unrelated template context variables, commented code, etc)
    • I have commented my code, particularly in hard-to-understand areas
  • I understand that short PRs lead to higher-quality code and faster delivery of features.
  • Linear history: my code has been rebased on the most recent commit in the master branch before opening PR
  • I have followed conventional commits specification for PR title
  • I have referenced YouTrack issue in the PR description for easy access
  • I have added tests that prove my code works

@cin-bun cin-bun requested a review from Dmi4er4 February 6, 2025 16:33
@cin-bun cin-bun marked this pull request as ready for review February 6, 2025 16:37
with patch("requests.get") as mock_get:
mock_get.return_value = MockResponse(status_code=500, text="Internal Server Error")
with pytest.raises(ContestAPIError):
YandexContestAPI.request_and_check(url, method="get")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Давай добавим не только проверку методов API, но и конечнго результата, то есть отрендеренного конфига вьюшки.
Нужно при помощи фактори замокать задание, отправить решение за студента, но замокать response нужной ручки на разные результаты и посмотреть, что на странице отображается то, что мы хотим. Для последнего у нас в тестах принято использовать BeautifulSoup.
Хочется проверить заранее обработанные ошибки и всякое разное неожиданное, которое должно отображаться в неизменном виде.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ты хочешь написать еще тесты на работу джобы добавления решения и отображения view submissions, я правильно поняла?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Написать тест на работу джобы можно, но это если не лень.
Основной запрос на тест конечной страницы, которую увидит пользователь. То есть обработать сценарий "студент зашел в лк > отправил задание -> увидел вердикт на странице". А для этого нужно замокать весь процесс со стороны системы, кроме поведения пользователя. В том числе и запуск джобы, потому что эмулировать запуск воркеров в тестах дело совсем неблагодарное. Поэтому достаточно будет просто менять submission.meta["verdict"] и submission.meta["status"], то есть мокать работу джобы отправки решения. И потом BeautifulSoup-ом проверять, что на странице видно то, что мы ожидаем там увидеть.

@cin-bun
Copy link
Collaborator Author

cin-bun commented Feb 7, 2025

Доработки в мониторинге

Ошибка с кодом 400 (берем сообщение из ответа)

Screenshot 2025-02-07 at 15 14 45

Ошибка с кодом 500

Screenshot 2025-02-07 at 15 21 44

Вернулась ошибка Unavailable

Screenshot 2025-02-07 at 15 27 00

verdict в ответе == 'No report' и delay_min запросов меньше или 10мин

Screenshot 2025-02-07 at 15 53 53

verdict в ответе == 'No report' и запросов уже больше 10мин

Screenshot 2025-02-07 at 15 57 43

@cin-bun
Copy link
Collaborator Author

cin-bun commented Feb 10, 2025

@Dmi4er4 Оставила один тест без параметров так как мы тестируем view, а она передает 1х1 значений из verdict

@cin-bun cin-bun merged commit 868cff5 into cscenter:master Feb 10, 2025
@cin-bun cin-bun deleted the 96_feat_contest_404 branch February 10, 2025 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants