Skip to content

Conversation

@eecavanna
Copy link
Collaborator

@eecavanna eecavanna commented Jul 19, 2025

On this branch, I added the first few tests that hit the BERtron API.

I also fixed a type inconsistency, where—as far as our type hints indicate—we could have passed a non-string value to a parameter (i.e. the version parameter of the FastAPI function) designed to be passed a string.

I also introduced httpx as a development dependency. It is a dependency of FastAPI's TestClient class.

I did not include any tests that involve the MongoDB server. I think that will happen alongside #53, separately from this.

@eecavanna eecavanna self-assigned this Jul 19, 2025
@eecavanna eecavanna linked an issue Jul 19, 2025 that may be closed by this pull request
@eecavanna eecavanna requested review from jeff-cohere and shreddd July 19, 2025 02:08
@eecavanna eecavanna requested a review from Copilot July 19, 2025 02:17
Copy link
Contributor

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 introduces the first set of API tests for the BERtron FastAPI application, adding test infrastructure to validate endpoint responses. The changes include setting up a test client, implementing basic endpoint tests, and fixing a type inconsistency in the FastAPI version parameter.

  • Adds test infrastructure with FastAPI TestClient and pytest fixtures
  • Implements tests for root redirect and version endpoint response validation
  • Fixes type consistency by ensuring version parameter is explicitly a string

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/tests/test_server.py New test file with API endpoint tests using FastAPI TestClient
src/server.py Fixes version parameter type by adding explicit string formatting
src/models.py Adds strict validation configuration to prevent extra fields in responses
src/README.md Updates documentation to include tests directory
pyproject.toml Adds httpx dependency required for FastAPI TestClient
Comments suppressed due to low confidence (1)

src/tests/test_server.py:18

  • [nitpick] The variable name test_client inside the fixture function shadows the fixture name itself. Consider renaming the variable to client or api_client for clarity.
    test_client = TestClient(app)

Copy link
Collaborator

@jeff-cohere jeff-cohere left a comment

Choose a reason for hiding this comment

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

Looks great. Thanks @eecavanna !

@eecavanna
Copy link
Collaborator Author

Thanks, @jeff-cohere! Merging.

@eecavanna eecavanna merged commit c53e7c6 into main Jul 19, 2025
2 checks passed
@eecavanna eecavanna deleted the 42-add-tests-beyond-existing-hello-world branch July 19, 2025 02:35
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.

Add tests beyond existing "hello world"

3 participants