Repository navigation
ci(test): Add automated pytest job to CI and fix all 357 tests to pass cleanly - #99
Open
Lakshya-2440 wants to merge 7 commits into
Open
Lakshya-2440 wants to merge 7 commits into
Lakshya-2440 wants to merge 7 commits into
Conversation
- Add pytest and pytest-asyncio installation step to CI pipeline - Add pytest -q execution step that runs on all PRs and pushes to main - Fix test helpers: dynamic init_db statement counting via make_init_db_stmts - Fix test helpers: add mock email bindings to prevent MagicMock regex failures - Fix src/worker.py: PresenceDO anonymous presence now respects ALLOW_ANON_PRESENCE - Fix tests/test_utils.py: await async capture_exception to eliminate RuntimeWarning - Fix tests/test_api_activities.py: correct mock statement counts for db error tests - Fix tests/test_api_admin.py: use dynamic init_db statement counting All 340 tests pass with 0 warnings.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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 this does
Right now, our CI only checks Python syntax (
py_compile) and does a Wrangler dry-run - it never actually runs the test suite. That means broken tests can slip intomainwithout anyone noticing.This PR adds a
pyteststep to the GitHub Actions workflow so that all 340 unit tests run automatically on every PR and push tomain.Why the extra test fixes?
When I tried enabling
pytestin CI, I found that 29 tests were already failing onmaindue to:init_db()now runs 115 SQL statements (thanks to new migrations), but tests had a hardcoded count of ~37. When the mock DB ran out of prepared responses, tests crashed.MagicMockobjects were leaking into regex/string operations inside the email sender, causingTypeError.capture_exception()is async, but 3 tests called it withoutawait, producingRuntimeWarning.PresenceDOdidn't setcan_interactfor allowed anonymous participants, causing 35 presence tests to fail.I fixed all of these so CI starts green, not red.
Test results