Initialize modules, enhance API, and add CI for testing#3
Merged
WillianSilva51 merged 5 commits intomainfrom Mar 28, 2026
Merged
Initialize modules, enhance API, and add CI for testing#3WillianSilva51 merged 5 commits intomainfrom
WillianSilva51 merged 5 commits intomainfrom
Conversation
…ns, models, repositories, routers, schemas, services, and tests
…he and security handling
… request data fixture
…pdate dependencies
There was a problem hiding this comment.
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__.pyexports.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
api/.env-exampleand API test files with placeholders and environment variables, and updated the local environment config to mark the API key as secret. [1] [2] [3]core/security.pyby providing better error handling, logging, and descriptive metadata for the API key header.API Endpoint Improvements:
geandle) tolimit,skip, andsizequery parameters in quote-related endpoints to prevent invalid or excessive requests. [1] [2]Testing and CI/CD:
QuoteServiceinapi/tests/test_quote_service.py, using pytest and async mocks to ensure correct behavior..github/workflows/python-tests.yml) to automate linting and testing with Python 3.13 and the latest dependencies.Project Structure and Imports:
__init__.pyfiles with__all__declarations for all major modules to improve import clarity and maintainability. [1] [2] [3] [4] [5] [6] [7] [8]Other Improvements:
cacheabledecorator incore/cache.pyto accept either a callable or integer for the expiration parameter, increasing flexibility. [1] [2]pytest-asyncio,ruff) topyproject.tomlfor improved testing and linting.