-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: add all database models, pydantic models for tasks, fixtures and tests for database #16
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Намного лучше, чем раньше, но делать еще оченб много.
.env.example
Outdated
|
||
POSTGRES_USER=admin | ||
POSTGRES_PASSWORD=admin | ||
POSTGRES_HOST=localhost | ||
POSTGRES_DB=desbordante | ||
POSTGRES_PORT=5432 | ||
|
||
POSTGRES_USER_TEST=admin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не дублируй, лучше подмени в тестах настройки
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
готово
@@ -18,11 +18,21 @@ jobs: | |||
with: | |||
python-version: '3.11' | |||
|
|||
- name: Set up docker |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Эта генерация от чат-гпт совсем не подходит по контексту.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
я конечно не чат-гпт, но согласен
@@ -18,11 +18,21 @@ jobs: | |||
with: | |||
python-version: '3.11' | |||
|
|||
- name: Set up docker | |||
uses: docker/login-action@v1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ты не пушишь ничего же, зачем?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
действительно зачем
.pre-commit-config.yaml
Outdated
@@ -26,6 +26,7 @@ repos: | |||
hooks: | |||
- id: ruff | |||
args: [ --fix, --exit-non-zero-on-fix ] | |||
exclude: tests/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Добавь опцию отключащую конкретную мешающую проверку, а не линтер на всех тестах.
tests/fixtures/insert_data_in_db.py
Outdated
session.add(new_task) | ||
session.commit() | ||
|
||
return add_task |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Весь файл очень большой, а каждая функция заменяется 2-3 строчками.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
удалил
@@ -0,0 +1,21 @@ | |||
from datetime import datetime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я бы предпочел испоьзование билблиотеки fake
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Они умеет генерить по схеме тестовые данные
tests/tests_data/file_info.py
Outdated
"renamed_header": "header", | ||
"rows_count": 4, | ||
"count_of_columns": 54, | ||
"path": "2///", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Плохие примерв. Напиши нормальные типы в схеме и генерь себе тестовые данные.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
поправил
@pytest.fixture(scope="function", autouse=True) | ||
def clean_tables(request, session_test): | ||
if "fixture_name" in request.fixturenames: | ||
yield |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Для чего тут yield?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
мы с помощью этого не перезапускаем наши фикстуры(у которых scope=function) между тестами одного параметризованного теста
tests/fixtures/fetch_data_from_db.py
Outdated
def fetch_first(model_name: str): | ||
with session_test() as session: | ||
with session.connection(): | ||
data = session.query(tables[model_name]).first() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
select вместо query используют
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✓
…d pydantic-validators
.pre-commit-config.yaml
Outdated
@@ -26,6 +26,7 @@ repos: | |||
hooks: | |||
- id: ruff | |||
args: [ --fix, --exit-non-zero-on-fix ] | |||
files: ^env\.py$ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Кажется ты полностью убил линтер, просто добавь правило в исключение в pyproject.toml
@@ -24,5 +24,8 @@ jobs: | |||
- name: Run all linters and formatters | |||
run: make lint | |||
|
|||
- name: Up all containers | |||
run: make up -d & |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Подумать как убрать необходимость в &
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Возможно это ломает CI
@@ -0,0 +1,29 @@ | |||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Файлы миграций назваются нечитаемо. В спецификации alembic есть возмоность генерировать нормальные имена.
app/tasks/schema/ar/config.py
Outdated
|
||
|
||
class ARTaskConfig(BaseTaskConfig): | ||
min_support_ar: Annotated[float, Field(ge=0, le=1, metadata={"decimal_places": 4})] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Поля metadata не существует у Field. Поправь везде, где встречается
("insert_task_data", "task", task_data), | ||
], | ||
) | ||
def test_database_queries( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Все еще большой
Add pydantic models for tasks config and result
Add database models for tasks, files and user information
Add empty migration and migration with tables
Add fixtures for tests, that interact with database
Add parametrized test for testing database queries
Add goal for up of docker container in CI and other small work