Skip to content

add test and api calls#26

Merged
heinrich10 merged 6 commits into
mainfrom
feat/api_tests
May 26, 2026
Merged

add test and api calls#26
heinrich10 merged 6 commits into
mainfrom
feat/api_tests

Conversation

@heinrich10
Copy link
Copy Markdown
Owner

@heinrich10 heinrich10 commented May 26, 2026

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

  • Enforced no trailing slashes on collection endpoints by updating all relevant route decorators in person.py, country.py, and continent.py to use paths without a trailing slash (e.g., /persons instead of /persons/). This ensures canonical URLs and consistent redirect behavior. [1] [2] [3] [4]
  • Added a new "API Conventions" section to the README.md outlining route, sort, and filter syntax conventions for the API.

Testing Enhancements

  • Added comprehensive end-to-end API tests in test_e2e.py covering CRUD flows, error handling, pagination, sorting, and cross-entity relationships, with database verification for persisted data.
  • Updated existing API tests for persons, countries, and continents to verify that API responses match the database state, improving test reliability and coverage. [1] [2] [3] [4] [5]

Documentation and Developer Experience

  • Added a new http/api.http file with example HTTP requests for all major API endpoints, facilitating manual testing and onboarding.
  • Introduced a http-client.env.json file to support environment variable configuration for HTTP client tools.

Test Infrastructure

  • Simplified and improved the health check test in tests/test_main.py by using the client fixture.

These changes collectively improve the API's usability, maintainability, and test coverage.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 26, 2026

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
924 902 98% 0% 🟢

New Files

File Coverage Status
tests/api_tests/test_e2e.py 100% 🟢
TOTAL 100% 🟢

Modified Files

File Coverage Status
pyfastapi/controllers/continent.py 100% 🟢
pyfastapi/controllers/country.py 100% 🟢
pyfastapi/controllers/person.py 92% 🟢
tests/api_tests/test_continents.py 100% 🟢
tests/api_tests/test_countries.py 100% 🟢
tests/api_tests/test_persons.py 100% 🟢
tests/test_main.py 100% 🟢
TOTAL 99% 🟢

updated for commit: 6d0288e by action🐍

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 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.py suite 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.http and http/http-client.env.json to 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.

Comment thread tests/api_tests/test_persons.py Outdated
Comment thread tests/api_tests/test_e2e.py Outdated
Comment thread tests/api_tests/test_e2e.py Outdated
Comment thread tests/api_tests/test_e2e.py
Comment thread http/api.http
Comment thread http/api.http
Comment thread http/api.http
Comment thread http/api.http
Comment thread http/api.http
@heinrich10 heinrich10 merged commit 56cd9f4 into main May 26, 2026
1 check passed
@heinrich10 heinrich10 deleted the feat/api_tests branch May 26, 2026 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants