Refactor pytest config, enforce 80% coverage, and add basic FastAPI tests #12

Merged
Riverfount merged 5 commits from :main into main 2025-10-08 13:10:31 -03:00
Member

This pull request includes several important improvements and additions:

  • Pytest configuration cleanup:
    Removed explicit python_files, incorrect testpaths, and redundant minversion from pyproject.toml.
    This aligns test discovery with the new project structure, where tests are kept in a separate directory outside the source code, facilitating containerization by excluding tests from the build context.
    Also keeps verbosity flags to improve test output clarity.

  • Coverage enforcement:
    Added --cov-fail-under=80 to the coverage test command as per project requirements specified by Guto, ensuring the test suite fails if coverage drops below 80%.
    This helps maintain consistent code quality and encourages adequate test coverage.

  • Initial API tests:
    Introduced a basic test setup for the FastAPI app:

    • A pytest fixture providing a TestClient for easy API interaction in tests.
    • A simple test verifying the root endpoint (/) returns {'Hello': 'World'}.

These changes establish a solid foundation for testing practices and code quality assurance going forward.

This pull request includes several important improvements and additions: * **Pytest configuration cleanup:** Removed explicit `python_files`, incorrect `testpaths`, and redundant `minversion` from `pyproject.toml`. This aligns test discovery with the new project structure, where tests are kept in a separate directory outside the source code, facilitating containerization by excluding tests from the build context. Also keeps verbosity flags to improve test output clarity. * **Coverage enforcement:** Added `--cov-fail-under=80` to the coverage test command as per project requirements specified by Guto, ensuring the test suite fails if coverage drops below 80%. This helps maintain consistent code quality and encourages adequate test coverage. * **Initial API tests:** Introduced a basic test setup for the FastAPI app: * A pytest fixture providing a `TestClient` for easy API interaction in tests. * A simple test verifying the root endpoint (`/`) returns `{'Hello': 'World'}`. These changes establish a solid foundation for testing practices and code quality assurance going forward.
- Removed `python_files` to support using a separate test directory outside the source code. This helps in containerization by avoiding the need to copy test files into the container.
- Removed `minversion` since pytest version is already pinned in the project as `pytest>=8.4.2`, making this redundant.
- Removed incorrect `testpaths` configuration. The previous paths were misconfigured.

These changes streamline the test configuration and align with the new project structure for better containerization.
- Added `--cov-fail-under=80` to the `test-cov` command to ensure that test coverage remains at or above 80%. This change aligns with the project requirements specified by Guto.
- This enforces a minimum coverage level, helping to maintain code quality and ensuring that sufficient tests are in place.
- Created `tests/__init__.py` to mark the tests directory as a package.
- Added `tests/conftest.py` with a pytest fixture `client` that provides a `TestClient` for the FastAPI app, enabling easy API testing.
- Added a basic test in `tests/test_base_app.py` to verify that the root endpoint (`/`) returns the expected JSON response `{'Hello': 'World'}`.

These tests establish a foundation for API testing and ensure the main app is reachable and responds correctly.
- Removed `tests/__init__.py` which was mistakenly included in the previous commit.
- This file is not needed as the tests directory is already used for testing purposes and does not require explicit package initialization.

This cleanup ensures the project remains tidy and free from unnecessary files.
- Set up the initial skeleton for the project documentation using MkDocs.
- Configured the Material theme for MkDocs to provide a clean, modern look.
- Created the base `mkdocs.yml` configuration file and the initial `docs/index.md` page.

This setup provides the foundation for project documentation, which can be expanded with more details as the project progresses.
Riverfount approved these changes 2025-10-08 13:09:32 -03:00
Riverfount left a comment
Owner

Great work!

Great work!
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: vitae/backend-vitae#12
No description provided.