Browse Source

Add more comment permissions tests

Just a couple more tests for comment permissions that are more essential
to be working correctly - replying in locked threads, and viewing
removed comments. Also changes the "deleted comments lose all
permissions" test slightly to actually check all permissions instead of
a hard-coded (and obsolete) set of them.
merge-requests/25/head
Deimos 6 years ago
parent
commit
99f1912d94
  1. 17
      tildes/tests/test_comment.py

17
tildes/tests/test_comment.py

@ -72,13 +72,28 @@ def test_comment_replying_permission(comment):
assert Authenticated in principals_allowed_by_permission(comment, 'reply')
def test_comment_reply_locked_thread_permission(comment):
"""Ensure that only admins can reply in locked threads."""
comment.topic.is_locked = True
assert principals_allowed_by_permission(comment, 'reply') == {'admin'}
def test_deleted_comment_permissions_removed(comment):
"""Ensure that deleted comments lose all of the permissions."""
comment.is_deleted = True
for permission in ('view', 'edit', 'delete', 'reply'):
all_permissions = [perm for (_, _, perm) in comment.__acl__()]
for permission in all_permissions:
assert not principals_allowed_by_permission(comment, permission)
def test_removed_comment_view_permission(comment):
"""Ensure a removed comment can only be viewed by its author and admins."""
comment.is_removed = True
principals = principals_allowed_by_permission(comment, 'view')
assert principals == {'admin', comment.user_id}
def test_edit_grace_period(comment):
"""Ensure last_edited_time isn't set if the edit is inside grace period."""
one_sec = timedelta(seconds=1)

Loading…
Cancel
Save