Skip to content

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
alphaonelabs:mainfrom
Lakshya-2440:ci/cd-auto-pytest
Open

Lakshya-2440 wants to merge 7 commits into
alphaonelabs:mainfrom
Lakshya-2440:ci/cd-auto-pytest

Conversation

@Lakshya-2440

Copy link
Copy Markdown
Contributor

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 into main without anyone noticing.

This PR adds a pytest step to the GitHub Actions workflow so that all 340 unit tests run automatically on every PR and push to main.

Why the extra test fixes?

When I tried enabling pytest in CI, I found that 29 tests were already failing on main due to:

  • Stale mock counts - 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.
  • Missing email bindings - MagicMock objects were leaking into regex/string operations inside the email sender, causing TypeError.
  • Unawaited coroutines - capture_exception() is async, but 3 tests called it without await, producing RuntimeWarning.
  • Anonymous presence handling - PresenceDO didn't set can_interact for allowed anonymous participants, causing 35 presence tests to fail.

I fixed all of these so CI starts green, not red.

Test results

340 passed, 0 warnings in 1.66s

- 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.
Copilot AI balanced review requested due to automatic review settings October 14, 2026 04:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Central YAML; Path: .coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 4f1c4967-17b8-4462-abc2-0f386007c2bd
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Lakshya-2440 Lakshya-2440 changed the title ci(test): Add automated pytest job to CI and fix all 340 tests to pass cleanly ci(test): Add automated pytest job to CI and fix all 357 tests to pass cleanly Oct 15, 2026
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