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

Make patch route #10 #60

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open

Make patch route #10 #60

wants to merge 16 commits into from

Conversation

DR0P-database
Copy link
Contributor

Изменения #10

ВАЖНО: изменена ручка для patch/review комментария админами

Чтобы изменить комментарий ему нужно отправить все поля для схемы CommentPost, их можно предварительно получить из GET, и в комментарии перепишутся поля. Также можно сделать комментарий анонимным через PATCH.

Детали реализации

Check-List

  • Вы проверили свой код перед отправкой запроса?
  • Вы написали тесты к реализованным функциям?
  • Вы не забыли применить форматирование black и isort для Back-End или Prettier для Front-End?

- Add test to patch user comments routes
- Add fixture for this tests
- Add enable set anonym to patch comment
Copy link

💩 Code linting failed, use black and isort to fix it.

Copy link

github-actions bot commented Nov 23, 2024

Code Coverage

Coverage Report
FileStmtsMissCoverMissing
rating_api
   __main__.py440%1–7
   exceptions.py26292%35–36
rating_api/models
   base.py55198%76
   db.py73297%61, 74
rating_api/routes
   comment.py831384%31, 42–45, 108, 118–123, 130, 153, 164, 198
   exc_handlers.py20195%26
   lecturer.py841483%132–153, 169, 177, 195, 201
rating_api/schemas
   base.py12467%6–9
TOTAL4764191% 

Summary

Tests Skipped Failures Errors Time
51 0 💤 3 ❌ 0 🔥 3.486s ⏱️

Copy link
Member

@Temmmmmo Temmmmmo left a comment

Choose a reason for hiding this comment

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

Сделай тогда новую модельку и поправь тесты и код

rating_api/routes/comment.py Outdated Show resolved Hide resolved
rating_api/routes/comment.py Outdated Show resolved Hide resolved
rating_api/routes/comment.py Outdated Show resolved Hide resolved
rating_api/routes/comment.py Outdated Show resolved Hide resolved
- Fix up tests
- Make allow unnecessary attibutes to patch
- Add new scheme to CommentUpdate
tests/conftest.py Outdated Show resolved Hide resolved
tests/test_routes/test_comment.py Show resolved Hide resolved
rating_api/routes/comment.py Outdated Show resolved Hide resolved
tests/test_routes/test_comment.py Show resolved Hide resolved
tests/test_routes/test_comment.py Show resolved Hide resolved
- Validation if given attribute is still not changed
- Validation if no attributes given
- Add tests
Copy link

github-actions bot commented Dec 6, 2024

💩 Code linting failed, use black and isort to fix it.

@@ -133,7 +133,7 @@ async def get_comments(
return result


@comment.patch("/{uuid}", response_model=CommentGet)
@comment.patch("/{uuid}/review", response_model=CommentGet)
Copy link
Contributor

Choose a reason for hiding this comment

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

warning!
надо поддерджать это на Фронте, перед выкаткой напишите Илье Батуеву

rating_api/schemas/models.py Show resolved Hide resolved
rating_api/routes/comment.py Show resolved Hide resolved
rating_api/routes/comment.py Show resolved Hide resolved
raise HTTPException(status_code=409, detail="Provide any parametr") # 409

# Если хоть одно поле было передано неизменным
if set(comment.__dict__.items()).intersection(set(comment_update.model_dump(exclude_unset=True).items())):
Copy link
Member

Choose a reason for hiding this comment

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

можно и так, но я бы запрос в базу сделал просто через filter
если вернется объект, где все поля идентичны заданному, то тогда возвращать 409


# Если хоть одно поле было передано неизменным
if set(comment.__dict__.items()).intersection(set(comment_update.model_dump(exclude_unset=True).items())):
raise HTTPException(status_code=426, detail="No changes detected") # 426
Copy link
Member

Choose a reason for hiding this comment

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

426 не подходит, она про другое

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.

5 participants