+ Add pytest db and migrations creation fixtures#83
+ Add pytest db and migrations creation fixtures#83
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the testing infrastructure by introducing a robust set of pytest fixtures and utilities for managing test databases and migrations. It refactors core SQL storage components to incorporate extensive type hinting and a flexible environment-based configuration system for database engines. These changes aim to provide developers with powerful tools for creating isolated and reliable testing environments, ultimately improving the overall quality and testability of database-dependent features. Highlights
Changelog
Ignored Files
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive testing framework using pytest, focusing on database and migration management. It adds support for multiple database engines configurable via environment variables, which is a significant enhancement. The changes include new pytest fixtures, testing utilities, and extensive type hinting across the storage layer, which greatly improves code quality and maintainability. I've identified a few issues, including a critical bug in path resolution for migrations, some potential crashes if configurations are incomplete, and some non-portable SQL in the testing utilities that could limit database compatibility. Addressing these points will make the new testing infrastructure more robust and reliable.
| from restalchemy.storage.sql.dialect import mysql | ||
| from restalchemy.storage.sql.dialect import pgsql | ||
| from restalchemy.storage.sql import sessions | ||
| from restalchemy.storage.sql.env_config import ( |
There was a problem hiding this comment.
This imports have that form especial for reexport.
| from restalchemy.storage.sql import engines | ||
| from restalchemy.storage.sql import tables | ||
| from restalchemy.storage.sql.sessions import AbstractSession | ||
| from restalchemy.storage.base import OptionalFilters, OptionalOrderBy |
There was a problem hiding this comment.
changing this import to
from restalchemy.storage import baseand following usage like
base.OptionalFiltersWould not improve code readability and clearance.
Module name base is too common.
There was a problem hiding this comment.
from restalchemy.storage import base as base_storage| RowType = tp.Tuple[tp.Any, ...] | ||
| DictRowType = tp.Dict[str, tp.Any] | ||
|
|
||
| if tp.TYPE_CHECKING: |
There was a problem hiding this comment.
In this case import module directly is impossible.
| @@ -0,0 +1,7 @@ | |||
| from .db import ( | |||
There was a problem hiding this comment.
Reexport for simplifying usage. It must be kept as is.
| env_configs, | ||
| DEFAULT_NAME, | ||
| ) | ||
| from restalchemy.testing.typing import SimpleGenerator, WorkerID |
There was a problem hiding this comment.
from restalchemy.testing import typing as WHAT| DEFAULT_NAME, | ||
| ) | ||
| from restalchemy.testing.typing import SimpleGenerator, WorkerID | ||
| from restalchemy.testing.utils.db import ( |
There was a problem hiding this comment.
from restalchemy.testing.utils import db # `db` is too commonThere was a problem hiding this comment.
from restalchemy.testing.utils import db as db_utils| import pytest | ||
|
|
||
| from restalchemy.testing.typing import SimpleGenerator | ||
| from restalchemy.testing.utils.migrations import ( |
There was a problem hiding this comment.
from restalchemy.testing.utils import migrations # `migrations` name is too common| @@ -0,0 +1,8 @@ | |||
| from .db import ( | |||
There was a problem hiding this comment.
Reexport for simplifying usage. It must be kept as is.
Issue # 82
Closes #82.