Skip to content

Initialize modules, enhance API, and add CI for testing#3

Merged
WillianSilva51 merged 5 commits intomainfrom
feat/tests-api
Mar 28, 2026
Merged

Initialize modules, enhance API, and add CI for testing#3
WillianSilva51 merged 5 commits intomainfrom
feat/tests-api

Conversation

@WillianSilva51
Copy link
Copy Markdown
Owner

This pull request introduces several improvements across the codebase, focusing on security best practices, API parameter validation, test coverage, and project structure. Notably, it enhances API key management, adds parameter constraints to API endpoints, introduces initial unit tests for the quote service, and improves Python module organization. Additionally, a GitHub Actions workflow for Python testing and linting is added.

Security and API Key Management:

  • Replaced hardcoded API keys in api/.env-example and API test files with placeholders and environment variables, and updated the local environment config to mark the API key as secret. [1] [2] [3]
  • Improved API key authentication in core/security.py by providing better error handling, logging, and descriptive metadata for the API key header.

API Endpoint Improvements:

  • Added validation constraints (ge and le) to limit, skip, and size query parameters in quote-related endpoints to prevent invalid or excessive requests. [1] [2]

Testing and CI/CD:

  • Added initial unit tests for the QuoteService in api/tests/test_quote_service.py, using pytest and async mocks to ensure correct behavior.
  • Introduced a GitHub Actions workflow (.github/workflows/python-tests.yml) to automate linting and testing with Python 3.13 and the latest dependencies.

Project Structure and Imports:

  • Added explicit __init__.py files with __all__ declarations for all major modules to improve import clarity and maintainability. [1] [2] [3] [4] [5] [6] [7] [8]

Other Improvements:

  • Enhanced the cacheable decorator in core/cache.py to accept either a callable or integer for the expiration parameter, increasing flexibility. [1] [2]
  • Added new development dependencies (pytest-asyncio, ruff) to pyproject.toml for improved testing and linting.

@WillianSilva51 WillianSilva51 self-assigned this Mar 28, 2026
Copilot AI review requested due to automatic review settings March 28, 2026 16:34
@WillianSilva51 WillianSilva51 added documentation Improvements or additions to documentation enhancement New feature or request labels Mar 28, 2026
@WillianSilva51 WillianSilva51 merged commit 3796fd8 into main Mar 28, 2026
4 of 5 checks passed
@WillianSilva51 WillianSilva51 deleted the feat/tests-api branch March 28, 2026 16:35
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the API’s security posture, adds parameter validation to quote endpoints, introduces initial unit tests + CI, and formalizes Python package/module structure.

Changes:

  • Harden API key handling (env placeholders; improved auth errors/logging; secret config).
  • Add query parameter constraints to quote endpoints to prevent excessive/invalid requests.
  • Add pytest-based unit test(s) and a GitHub Actions workflow for linting/testing; add module __init__.py exports.

Reviewed changes

Copilot reviewed 17 out of 20 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
requirements.txt Adds pinned dependency set (likely for reproducible installs).
pyproject.toml Adds pytest-asyncio and ruff dependencies.
api/utils/init.py Exposes utils module via __all__.
api/tests/test_quote_service.py Adds an async unit test for QuoteService.create_quote.
api/tests/init.py Declares tests package exports.
api/services/init.py Declares services package exports.
api/schemas/init.py Declares schemas package exports.
api/routers/quotes.py Adds ge/le constraints for pagination/random query params.
api/routers/init.py Declares routers package exports.
api/repositories/init.py Declares repositories package exports.
api/models/init.py Declares models package exports.
api/core/security.py Improves API key header metadata and auth error handling/logging.
api/core/cache.py Makes cache expiration accept int or callable; adds default expiry.
api/core/init.py Adds core package exports/imports.
api/FinFrases/environments/local.yml Marks API key as secret in local environment config.
api/FinFrases/Quotes/Create Quote.yml Uses env var for API key; tweaks request script randomization.
api/.env-example Replaces hardcoded API key with placeholder value.
.github/workflows/python-tests.yml Adds CI workflow to lint with ruff and run pytest via uv.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants