Feat: Add a pytest test suite for sync-microservice and run it in CI
Describe the feature
Feat: Add a pytest test suite for sync-microservice and run it in CI
Describe the feature
backend/ has about 60 test files and a CI "Run Tests" step, but
sync-microservice/ has no tests at all, and the PR check workflow only runs
cd backend && pytest. Regressions in the folder watcher or its routes
can therefore merge unnoticed.
Proposal
- Add pytest (and httpx for FastAPI's TestClient, already pinned) to sync-microservice/requirements.txt.
- Add sync-microservice/pytest.ini and a tests/ folder, mirroring backend/pytest.ini (pythonpath = ., testpaths = tests).
- Add a "Run Tests (Sync Microservice)" step to .github/workflows/pr-check.yml.
- Write the first tests for the smallest modules:
- app/routes/health.py
- app/routes/shutdown.py (mock the delayed shutdown so the test process isn't killed)
- app/utils/watcher_helpers.py Follow-up PRs can cover routes/folders.py, routes/watcher.py and utils/watcher.py.
Acceptance criteria
cd sync-microservice && pytestpasses locally and in CI.- At least the three modules above have tests.
Add ScreenShots
Add ScreenShots N/A (no UI change)
Record
- [x] I agree to follow this project's Code of Conduct
- [x] I want to work on this issue
👋 Thanks for opening this issue! The maintainers will review it shortly. Till then, do not open any PR. This is a strict rule we like to follow around here :)
⚠️ Potential Duplicate Issue (Semantic Match)
This issue appears semantically similar to the following issues in AOSSIE-Org/PictoPy:
-
Add unit test coverage for system health and core server endpoints (#1011, open) https://github.com/AOSSIE-Org/PictoPy/issues/1011 Similarity: 69.2%
-
BUG: Missing 'requests' in requirements.txt causes ModuleNotFoundError in API utils (#1533, open) https://github.com/AOSSIE-Org/PictoPy/issues/1533 Similarity: 62.1%
-
**Write Unit Tests for backend ** (#74, closed) https://github.com/AOSSIE-Org/PictoPy/issues/74 Similarity: 60.4%
Please review before proceeding.
Link your account with Gitcord
Thanks for opening this issue, @Omega-127!
To receive Discord notifications and contributor tracking for this organization:
- Join Discord: https://discord.gg/hjUhu33uAn
- In Discord, run
/link Omega-127 - Paste the verification code into your GitHub bio (or a public gist)
- Click Verify in Discord (or run
/verify-link Omega-127)
Once linked, Gitcord can notify you about assignments, mentions, and more.
— Posted by Gitcord
Hi @rohan-pandeyy, I'd like to work on this issue.
I already have a working implementation locally and will wait for assignment before opening a PR:
- sync-microservice/pytest.ini (pythonpath = ., testpaths = tests) mirroring backend
- pytest and pytest-asyncio added to sync-microservice/requirements.txt (httpx was already pinned)
- tests for app/routes/health.py, app/routes/shutdown.py (the delayed shutdown is mocked so the test process isn't killed) and app/utils/watcher_helpers.py
- a "Run Tests (Sync Microservice)" step in .github/workflows/pr-check.yml
- a conftest guard so tests can never touch a real PictoPy database
12 tests pass locally in a clean venv. Could you please assign this to me? Follow-up PRs can cover routes/folders.py, routes/watcher.py and utils/watcher.py.