add test and api calls#26
Merged
Merged
Conversation
☂️ Python Coverage
Overall Coverage
New Files
Modified Files
|
There was a problem hiding this comment.
Pull request overview
This PR adds end-to-end API tests plus JetBrains HTTP client request files to make it easier to validate and refactor the FastAPI endpoints while preserving current behavior.
Changes:
- Added a new
tests/api_tests/test_e2e.pysuite covering multi-endpoint CRUD flows, pagination/filter/sort behavior, and not-found scenarios. - Enhanced existing API tests to cross-check API responses against database state via
db_session. - Added
http/api.httpandhttp/http-client.env.jsonto support manual API calls via JetBrains HTTP client.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_main.py | Switches health test to use the shared client fixture. |
| tests/api_tests/test_persons.py | Adds DB-level assertions for person detail/create tests. |
| tests/api_tests/test_countries.py | Adds DB-level assertions for country detail/not-found tests. |
| tests/api_tests/test_continents.py | Adds DB-level assertions for continent detail/not-found tests. |
| tests/api_tests/test_e2e.py | Introduces new end-to-end API flow tests across persons/countries/continents/health. |
| http/http-client.env.json | Adds JetBrains HTTP client environment variables. |
| http/api.http | Adds example HTTP requests for manual endpoint testing. |
💡 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.
What?
end to end API tests and api calls using jetbrains http client
Why?
Make it easier to refactor in the future.
Anything Else?
Found out that fastapi does redirecting /xxx to /xxx/ and vice versa.
AI Summary (optional)
This pull request implements several improvements and additions to the FastAPI backend project, focusing on API conventions, endpoint consistency, enhanced testing, and improved documentation. The most significant changes are the enforcement of no trailing slashes on collection endpoints, the addition of comprehensive end-to-end and database verification tests, and the introduction of API usage documentation and examples.
API Consistency and Conventions
person.py,country.py, andcontinent.pyto use paths without a trailing slash (e.g.,/personsinstead of/persons/). This ensures canonical URLs and consistent redirect behavior. [1] [2] [3] [4]README.mdoutlining route, sort, and filter syntax conventions for the API.Testing Enhancements
test_e2e.pycovering CRUD flows, error handling, pagination, sorting, and cross-entity relationships, with database verification for persisted data.Documentation and Developer Experience
http/api.httpfile with example HTTP requests for all major API endpoints, facilitating manual testing and onboarding.http-client.env.jsonfile to support environment variable configuration for HTTP client tools.Test Infrastructure
tests/test_main.pyby using theclientfixture.These changes collectively improve the API's usability, maintainability, and test coverage.