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

feat: add all database models, pydantic models for tasks, fixtures and tests for database #16

Merged
merged 18 commits into from
Dec 22, 2023

Conversation

raf-nr
Copy link
Contributor

@raf-nr raf-nr commented Nov 27, 2023

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

Copy link
Collaborator

@toadharvard toadharvard left a 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
Copy link
Collaborator

Choose a reason for hiding this comment

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

не дублируй, лучше подмени в тестах настройки

Copy link
Contributor Author

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
Copy link
Collaborator

@toadharvard toadharvard Dec 12, 2023

Choose a reason for hiding this comment

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

Эта генерация от чат-гпт совсем не подходит по контексту.

Copy link
Contributor Author

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
Copy link
Collaborator

Choose a reason for hiding this comment

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

ты не пушишь ничего же, зачем?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

действительно зачем

.github/workflows/run-linter-and-tests.yaml Show resolved Hide resolved
@@ -26,6 +26,7 @@ repos:
hooks:
- id: ruff
args: [ --fix, --exit-non-zero-on-fix ]
exclude: tests/
Copy link
Collaborator

Choose a reason for hiding this comment

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

Добавь опцию отключащую конкретную мешающую проверку, а не линтер на всех тестах.

session.add(new_task)
session.commit()

return add_task
Copy link
Collaborator

@toadharvard toadharvard Dec 12, 2023

Choose a reason for hiding this comment

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

Весь файл очень большой, а каждая функция заменяется 2-3 строчками.

Copy link
Contributor Author

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
Copy link
Collaborator

Choose a reason for hiding this comment

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

Я бы предпочел испоьзование билблиотеки fake

Copy link
Collaborator

Choose a reason for hiding this comment

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

Они умеет генерить по схеме тестовые данные

"renamed_header": "header",
"rows_count": 4,
"count_of_columns": 54,
"path": "2///",
Copy link
Collaborator

@toadharvard toadharvard Dec 12, 2023

Choose a reason for hiding this comment

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

Плохие примерв. Напиши нормальные типы в схеме и генерь себе тестовые данные.

Copy link
Contributor Author

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
Copy link
Collaborator

@toadharvard toadharvard Dec 12, 2023

Choose a reason for hiding this comment

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

Для чего тут yield?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

мы с помощью этого не перезапускаем наши фикстуры(у которых scope=function) между тестами одного параметризованного теста

def fetch_first(model_name: str):
with session_test() as session:
with session.connection():
data = session.query(tables[model_name]).first()
Copy link
Collaborator

Choose a reason for hiding this comment

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

select вместо query используют

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@raf-nr raf-nr changed the title feat: add database models for user information, files and tasks feat: add all database models, pydantic models for tasks, fixtures and tests for database Dec 22, 2023
@@ -26,6 +26,7 @@ repos:
hooks:
- id: ruff
args: [ --fix, --exit-non-zero-on-fix ]
files: ^env\.py$
Copy link
Collaborator

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 &
Copy link
Collaborator

Choose a reason for hiding this comment

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

Подумать как убрать необходимость в &

Copy link
Collaborator

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 @@
"""
Copy link
Collaborator

Choose a reason for hiding this comment

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

Файлы миграций назваются нечитаемо. В спецификации alembic есть возмоность генерировать нормальные имена.



class ARTaskConfig(BaseTaskConfig):
min_support_ar: Annotated[float, Field(ge=0, le=1, metadata={"decimal_places": 4})]
Copy link
Collaborator

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(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Все еще большой

@toadharvard toadharvard merged commit 96fd16c into Desbordante:main Dec 22, 2023
2 checks passed
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