Skip to content

Добавлено получение лектора по tbid и соответствующие тесты#159

Open
DrNeumann388 wants to merge 1 commit intomainfrom
get_tbid_ipd
Open

Добавлено получение лектора по tbid и соответствующие тесты#159
DrNeumann388 wants to merge 1 commit intomainfrom
get_tbid_ipd

Conversation

@DrNeumann388
Copy link

@DrNeumann388 DrNeumann388 commented Mar 6, 2026

Изменения

Добавлена ручка, по которой можнр получить из БД лектора по timetable_id.

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

  1. Создан GET запрос, который реализован с помощью обращения к БД.
  2. Реализованы тесты, проверяющие работоспособность ручки при различных значениях в БД.

Check-List

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

@DrNeumann388 DrNeumann388 requested a review from petrCher March 6, 2026 20:46
@DrNeumann388 DrNeumann388 self-assigned this Mar 6, 2026
@github-actions
Copy link

github-actions bot commented Mar 6, 2026

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

@github-actions
Copy link

github-actions bot commented Mar 6, 2026

Code Coverage

Coverage Report
FileStmtsMissCoverMissing
rating_api
   __main__.py440%1–7
   exceptions.py43784%35–37, 48–50, 58
rating_api/models
   db.py1511292%115, 117, 119, 121, 132, 171, 189, 199, 213, 222–224
rating_api/routes
   base.py16194%41
   comment.py1283077%64, 82, 131–132, 153–162, 232–233, 235–236, 244–249, 276, 289, 316–327, 358
   exc_handlers.py32391%36, 43, 50
   lecturer.py1101388%70–71, 81, 87–88, 96–99, 215, 223, 241, 247
rating_api/schemas
   base.py12467%6–9
   models.py153398%187, 189, 199
rating_api/utils
   mark.py880%1–20
TOTAL7558589% 

Summary

Tests Skipped Failures Errors Time
79 0 💤 4 ❌ 0 🔥 26.919s ⏱️

@DrNeumann388 DrNeumann388 changed the title Убраны isort и black Добавлено получение лектора по tbid и соответствующие тесты Mar 6, 2026
@petrCher
Copy link
Member

petrCher commented Mar 6, 2026

https://github.com/profcomff/rating-api/blob/main/rating_api/exceptions.py#L18
убери пробел лишний в выделенной строке, пожалуйста. К тачку это не относится, но не хочу создавать пр из-за этого)


@lecturer.get("/timetable-id/{timetable_id}", response_model=LecturerGet)
async def get_lecturer_by_timetable_id(timetable_id: int) -> LecturerGet:
lecturer: Lecturer = Lecturer.query(session=db.session).filter(LEcturer.timetable_id == timetable_id).one_or_none()
Copy link
Member

Choose a reason for hiding this comment

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

опечатка в filter: ты написал LEcturer

lecturer: Lecturer = Lecturer.query(session=db.session).filter(LEcturer.timetable_id == timetable_id).one_or_none()
if lecturer is None:
raise ObjectNotFound(Lecturer, timetable_id)
result = LecturerGet.model_validate(lecturer)
Copy link
Member

Choose a reason for hiding this comment

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

здесь не надо создавать переменную result, лучше сразу делать return, чтобы не тратить время на ненужную переменную

assert get_response.status_code == response_status
if response_status == status.HTTP_200_OK:
json_response = get_response.json()
assert json_response["id"] == Lecturer.id
Copy link
Member

Choose a reason for hiding this comment

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

== lecturer.id
сейчас ты обращаешься к классу, а не объекту

return response_validated

@lecturer.get("/timetable-id/{timetable_id}", response_model=LecturerGet)
async def get_lecturer_by_timetable_id(timetable_id: int) -> LecturerGet:
Copy link
Member

Choose a reason for hiding this comment

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

после объявления функции надо добавить к ней описание на русском, посмотри соседние энпоинты например

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.

Сделать ручку get lecturer/timetable-id/{timetable_id}

2 participants