test(BA-4921): expand check_permission_with_scope_chain() test coverage#9742
Open
test(BA-4921): expand check_permission_with_scope_chain() test coverage#9742
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Expands unit test coverage for PermissionDBSource.check_permission_with_scope_chain() by adding edge-case scenarios and extending fixtures to support additional scope/entity variations.
Changes:
- Added 15 new test cases covering operation/entity mismatches, role assignment edge cases, multi-role behavior, mixed AUTO/REF chains, and deeper AUTO chains.
- Extended
permission_setupfixture to supportuser_scopeand optional(scope_key, operation, entity_type)entries. - Added multiple new fixtures to model deleted/unassigned roles, multi-role users, mixed edge relations, and user isolation.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/unit/manager/repositories/permission_controller/test_check_permission_with_scope_chain.py | Adds new fixtures and parametrized tests; extends permission_setup to support user scope and entity type overrides. |
| changes/9742.test.md | Adds a changelog entry documenting the test coverage expansion. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tests/unit/manager/repositories/permission_controller/test_check_permission_with_scope_chain.py
Show resolved
Hide resolved
tests/unit/manager/repositories/permission_controller/test_check_permission_with_scope_chain.py
Outdated
Show resolved
Hide resolved
tests/unit/manager/repositories/permission_controller/test_check_permission_with_scope_chain.py
Show resolved
Hide resolved
Add 15 new test cases covering edge cases: operation mismatch, deleted/unassigned roles, multiple roles, mixed AUTO/REF chains, deep 3-level chains, self-scope combinations, user isolation, multiple permissions, and entity type mismatch. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…etrization Replace raw tuples in permission_setup fixture with typed PermissionEntry dataclass. Adds runtime type validation in the fixture. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
69d1043 to
46e1c03
Compare
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.
Summary
check_permission_with_scope_chain()covering edge cases: operation mismatch, deleted/unassigned roles, multiple roles, mixed AUTO/REF edge chains, deep 3-level AUTO chains, self-scope combinations, user isolation, multiple permissions on same role, and entity type mismatchpermission_setupfixture to supportuser_scopekey and optionalentity_typeparameteruser_with_deleted_role,user_with_unassigned_role,user_with_two_roles,multi_role_permission_setup,project_in_domain_ref,domain_in_user_scope_auto,other_user_with_permissionTest plan
pants lintpassespants checkpasses (mypy)pants test tests/unit/manager/repositories/permission_controller/test_check_permission_with_scope_chain.py— all 24 test cases passResolves BA-4921
🤖 Generated with Claude Code