test: strengthen delete-permission include_deleted test to discriminate from other grants

test_delete_permission_with_include_deleted_for_trash_restore only checked
an owner and a fully-ungranted stranger, so it never proved perm=
actually discriminates delete_document from other permission grants. Add
a view_only user with view_document (but not delete_document) granted on
the same doc and assert they remain excluded, mirroring the pattern in
test_change_document_permission_is_distinct_from_view.
This commit is contained in:
stumpylog
2026-08-03 10:23:29 -07:00
parent 8ead0e2315
commit 9b474807ac
@@ -244,7 +244,9 @@ class TestPermittedDocumentIdsArbitraryPermission:
def test_delete_permission_with_include_deleted_for_trash_restore(self):
owner = User.objects.create_user(username="owner")
stranger = User.objects.create_user(username="mallory")
view_only = User.objects.create_user(username="viewer")
doc = DocumentFactory(owner=owner)
assign_perm("view_document", view_only, doc)
doc.delete()
assert_visible_document_ids(
@@ -261,3 +263,12 @@ class TestPermittedDocumentIdsArbitraryPermission:
expected_visible=[],
expected_hidden=[doc.pk],
)
assert_visible_document_ids(
permitted_document_ids(
view_only,
perm="delete_document",
include_deleted=True,
),
expected_visible=[],
expected_hidden=[doc.pk],
)