test(pull_request_service): cover create-with-webhooks sync config (item 8, ontokit-web#5)#175
test(pull_request_service): cover create-with-webhooks sync config (item 8, ontokit-web#5)#175JohnRDOrazio wants to merge 1 commit into
Conversation
…tem 8, #5) The create_github_integration webhook branch auto-creates a RemoteSyncConfig via _sync_remote_config_for_webhooks, but no test exercised the create route with webhooks_enabled=True — test_create_integration_success runs with it False, and only the helper was tested directly. This closes item 8 of the ontokit-web#5 verification checklist. Asserts the auto-created config has frequency="webhook", enabled=True, the correct repo/branch/file fields, and that the git remote is set up. Validated locally: ruff check + mypy + pytest all pass on the file (pre-commit hooks skipped to avoid a redundant multi-hundred-MB mypy env rebuild; CI runs the same checks). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughA new async unit test ChangesWebhook sync config creation test
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/unit/test_pull_request_service_extended.py (1)
1562-1562: ⚡ Quick winAssert
setup_remotearguments, not just call count.Line 1562 only verifies invocation count; it should also validate
project_idand the full remote URL contract.Suggested tightening
- mock_git_service.setup_remote.assert_called_once() + mock_git_service.setup_remote.assert_called_once_with( + PROJECT_ID, "https://github.com/myorg/myrepo.git" + )🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/unit/test_pull_request_service_extended.py` at line 1562, The assertion on mock_git_service.setup_remote only verifies that the method was called once without validating the actual arguments passed. Replace assert_called_once() with assert_called_once_with() and pass the expected arguments, specifically the project_id and the full remote URL that should have been passed to setup_remote. This ensures the test validates the complete contract of how the remote is being set up, not just that it was invoked.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/unit/test_pull_request_service_extended.py`:
- Line 1562: The assertion on mock_git_service.setup_remote only verifies that
the method was called once without validating the actual arguments passed.
Replace assert_called_once() with assert_called_once_with() and pass the
expected arguments, specifically the project_id and the full remote URL that
should have been passed to setup_remote. This ensures the test validates the
complete contract of how the remote is being set up, not just that it was
invoked.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ab16f716-5732-46f6-9f40-94e0039c9a06
📒 Files selected for processing (1)
tests/unit/test_pull_request_service_extended.py
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
What
Adds
test_create_integration_with_webhooks_creates_sync_configtoTestCreateGitHubIntegration, exercisingcreate_github_integrationwithwebhooks_enabled=Trueand asserting it auto-creates aRemoteSyncConfigwithfrequency="webhook",enabled=True, and the correct repo/branch/file fields (plus that the git remote is set up).Why
While verifying the 8-item checklist on ontokit-web#5 (read-only remote-sync fields when webhook-driven), every item traced cleanly except one test gap: the create route's webhook branch calls the (already-tested)
_sync_remote_config_for_webhookshelper, but no test covered the route itself with webhooks enabled —test_create_integration_successruns withwebhooks_enabled=False. This closes item 8.Verification
Run locally against the project venv:
pytest -k "CreateGitHubIntegration or SyncRemoteConfigForWebhooks"→ 7 passedruff check→ cleanmypy tests/unit/test_pull_request_service_extended.py→ no issuesRefs CatholicOS/ontokit-web#5
Summary by CodeRabbit