Exercise FastAPI endpoints through TestClient and mock FreshRSS transport - #22
Exercise FastAPI endpoints through TestClient and mock FreshRSS transport#22Skulldorom wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: db527ea78a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| from fastapi import HTTPException | ||
| import requests | ||
| from fastapi import HTTPException | ||
| from fastapi.testclient import TestClient |
There was a problem hiding this comment.
Add TestClient's required transport dependency
With the dependencies installed by .github/workflows/docker.yml via uv sync --frozen, this import fails during test collection because Starlette's TestClient requires the httpx2 package, while the locked dev dependencies include only pytest. I reproduced the resulting RuntimeError with .venv/bin/pytest -q; therefore every CI test run fails before executing a test, and the dependent Docker publishing job is blocked. Add the required TestClient dependency to pyproject.toml and regenerate uv.lock.
Useful? React with 👍 / 👎.
|
Superseded by #25 — all four PRs merged with conflict resolution and review fixes applied. |
Motivation
TestClientinstead of only calling functions directly.Description
main_modulefixture that imports the application under deterministicFRESHRSS_*environment variables and atest_clientfixture that yields aTestClientfor HTTP requests (tests/test_main.py).install_freshrss_transportto stub onlyrequests.postandrequests.get, leaving the HTTP surface untouched and capturing outbound calls for assertions (tests/test_main.py)./healthand/freshrss/unreadcovering default and explicitnandcategoryparameters, invalidnvalues (validation), encoded category values, authentication caching (login once), upstream 502 serialization, and response JSON shape (tests/test_main.py).get_greader_tokenfailure cases (failed login and missingAuth=line) while mocking only the transport (tests/test_main.py).quotefromurllib.parseinmain.py.Testing
python -m py_compile main.py tests/test_main.pywhich succeeded.git diff --checkwhich found no issues during the change validation step.uv run pytest -qbut test collection could not start becausestarlette.testclientrequires the optionalhttpx2package and the environment could not fetch packages from PyPI, sopytestcould not be executed here.httpx2to dev dependencies with the runtime tooling, but package installation failed due to lack of network access, so full test execution was not possible in this environment.Codex Task