Add missing test coverage for permissions, deposits, editor access, and spam user edge cases#3197
Draft
cursor[bot] wants to merge 1 commit intomainfrom
Draft
Add missing test coverage for permissions, deposits, editor access, and spam user edge cases#3197cursor[bot] wants to merge 1 commit intomainfrom
cursor[bot] wants to merge 1 commit intomainfrom
Conversation
…nd spam user edge cases Co-authored-by: Kobe Attias <kobeattias@gmail.com>
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3197 +/- ##
==========================================
+ Coverage 78.49% 78.51% +0.01%
==========================================
Files 612 612
Lines 34250 34250
==========================================
+ Hits 26885 26890 +5
+ Misses 7365 7360 -5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.



Risky behavior now covered
HasDocumentEditingPermission(document editing permission class): Direct unit tests for author/moderator/org-member/stranger access paths, including thenote_idbranch that gates organization membership checks and theupsertaction path. Previously only covered indirectly through API integration tests.Deposit.upsert_pending(Circle deposit status ordering): Direct tests for the status-advance-only logic (INITIATED→CONFIRMEDadvances,CONFIRMED→INITIATEDdoes not regress,COMPLETED/FAILEDat same level, unknown status handling). Previously only tested indirectly via webhook integration tests.Research AI editor access (
UserIsEditor | IsModeratorcomposition): Verifies that hub editors (non-moderators) can access expert-finder endpoints after the recent permission change. Previously only moderator access was tested.handle_spam_user_taskwith nonexistent user: Tests the early-return guard for invalid user IDs, covering the recently addedif not user: returnpath.Test files added/updated
src/researchhub_document/tests/test_permissions.py(new, 10 tests)src/reputation/tests/test_deposit.py(new, 10 tests)src/research_ai/tests/test_editor_access.py(new, 6 tests)src/user/tests/test_tasks.py(updated, 2 new tests)Why these tests materially reduce regression risk
These tests target security-critical permission logic, financial deposit state machines, and recently changed access control composition — all areas where regressions could cause unauthorized access, data corruption, or financial errors. Each test is deterministic and independent.