Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f85af90
Добавлены фикстуры: logging_sql_req_before_execute для логирования по…
CaseAsLimbo May 18, 2026
9ee4001
Добавлены relationship для таблиц Lectorer и LectorerUserComment с на…
CaseAsLimbo May 18, 2026
47b118c
В .gitignore добавлено исключение файла uv.lock для пакетного менедже…
CaseAsLimbo May 18, 2026
54ccba8
Добавлен мок пользователя с userdata
CaseAsLimbo May 18, 2026
944ae37
Изменил названия атрибута lecturer_comments на lecturer в таблице Lec…
CaseAsLimbo May 19, 2026
b00ad8b
Добавлена проверка корректности переданных в userdata параметров
CaseAsLimbo May 19, 2026
e5d6cf1
Были добавлены дополнительные слушатели событий BEGIN, COMMIT и ROLLB…
CaseAsLimbo May 19, 2026
810eeb4
Были применены black и isort T_T
CaseAsLimbo May 19, 2026
a118c23
Удалил личную информацию
CaseAsLimbo May 19, 2026
0342965
были удалены фикстры для логирования и переопределения dbsession
CaseAsLimbo May 19, 2026
81d86c5
Убрано каскадное удаление таблиц
CaseAsLimbo Jun 27, 2026
ce326eb
Возращена структура фикстуры lecturers; удалены лишние скоупы из мока…
CaseAsLimbo Jun 27, 2026
ad15093
Добавленая проверка user_id и fullname; убрана проверка полей userdat…
CaseAsLimbo Jun 27, 2026
39275f0
Применены black и isort T_T
CaseAsLimbo Jun 27, 2026
fda3bc8
удален uv.lock из gitignore
CaseAsLimbo Jun 27, 2026
e23ca7c
fix status
petrCher Jun 27, 2026
d1adcf8
fixes
petrCher Jun 27, 2026
887df60
fix
petrCher Jun 27, 2026
2e8f230
fix
petrCher Jun 27, 2026
6f19b2f
fix
petrCher Jun 27, 2026
2260655
Добавлен dbsession.flush() после добавления на удаление каждого элеме…
CaseAsLimbo Jun 27, 2026
42e40df
добавлен пакет aioresponses для перехвата aiohttp запросов
CaseAsLimbo Jun 28, 2026
9eb5806
Добавлена фикстура aiohttp_mp реализующая перехват всех aiohttp запросов
CaseAsLimbo Jun 28, 2026
1a635eb
Добавлены тесты на логику выдачи ачивок
CaseAsLimbo Jun 28, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions requirements.dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ pytest
pytest-cov
pytest-mock
testcontainers[postgres]
aioresponses
37 changes: 33 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import pytest
from _pytest.monkeypatch import MonkeyPatch
from aioresponses import aioresponses
from alembic import command
from alembic.config import Config as AlembicConfig
from fastapi.testclient import TestClient
Expand Down Expand Up @@ -43,6 +44,13 @@ def session_mp():
mp.undo()


@pytest.fixture(autouse=True)
def aiohttp_mp():
"""Фикстура для перехвата любых aiohttp запросов aiohttp.ClientSession()"""
with aioresponses() as aiohttp_mock:
yield aiohttp_mock


@pytest.fixture(scope='session')
def get_settings_mock(session_mp):
"""Переопределение get_settings в rating_api/settings.py и перезагрузка base.app."""
Expand Down Expand Up @@ -92,16 +100,37 @@ def dbsession(db_container):


@pytest.fixture
def client(mocker):
user_mock = mocker.patch('auth_lib.fastapi.UnionAuth.__call__')
user_mock.return_value = {
def authlib_user():
Comment thread
petrCher marked this conversation as resolved.
"""
Данные о пользователе, возвращаемые сервисом auth.
"""
return {
"session_scopes": [{"id": 0, "name": "string", "comment": "string"}],
"user_scopes": [{"id": 0, "name": "string", "comment": "string"}],
"indirect_groups": [{"id": 0, "name": "string", "parent_id": 0}],
"groups": [{"id": 0, "name": "string", "parent_id": 0}],
"id": 0,
"email": "string",
"userdata": [
{"category": "Личная информация", "param": "Полное имя", "value": "Тестовый Тест"},
],
}


@pytest.fixture()
Comment thread
petrCher marked this conversation as resolved.
def authlib_mock(mocker):
auth_mock = mocker.patch("auth_lib.fastapi.UnionAuth.__call__")
return auth_mock


@pytest.fixture()
def user_mock(authlib_mock, authlib_user):
authlib_mock.return_value = authlib_user
return authlib_mock


@pytest.fixture
def client(mocker, user_mock):
client = TestClient(app)
return client

Expand Down Expand Up @@ -218,7 +247,6 @@ def lecturers(dbsession):
dbsession.add(lecturer)
dbsession.commit()
yield lecturers

for lecturer in lecturers:
for row in lecturer.comments:
dbsession.delete(row)
Expand All @@ -227,6 +255,7 @@ def lecturers(dbsession):
)
for row in lecturer_user_comments:
dbsession.delete(row)
dbsession.flush()
dbsession.delete(lecturer)
dbsession.commit()

Expand Down
Loading
Loading