Skip to content

Commit

Permalink
tests/rules: add group members to all rule tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzzylogic2000 authored and Rineee committed Nov 25, 2022
1 parent 21e98a8 commit 790c16a
Show file tree
Hide file tree
Showing 35 changed files with 1,976 additions and 310 deletions.
12 changes: 12 additions & 0 deletions tests/documents/rules/test_rules_comment_chapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ def test_pre_phase(phase_factory, chapter_factory, user_factory,
anonymous, moderator, initiator = setup_users(project)
project, group_member_in_org, group_member_in_pro, group_member_out = \
setup_group_members(project, group_factory, user_factory)
creator = item.creator

assert project.is_public
with freeze_pre_phase(phase):
assert not rules.has_perm(perm_name, anonymous, item)
assert not rules.has_perm(perm_name, user, item)
assert not rules.has_perm(perm_name, creator, item)
assert not rules.has_perm(perm_name, group_member_in_org, item)
assert not rules.has_perm(perm_name, group_member_out, item)
assert rules.has_perm(perm_name, group_member_in_pro, item)
Expand All @@ -47,11 +49,13 @@ def test_phase_active(phase_factory, chapter_factory, user_factory,
anonymous, moderator, initiator = setup_users(project)
project, group_member_in_org, group_member_in_pro, group_member_out = \
setup_group_members(project, group_factory, user_factory)
creator = item.creator

assert project.is_public
with freeze_phase(phase):
assert not rules.has_perm(perm_name, anonymous, item)
assert rules.has_perm(perm_name, user, item)
assert rules.has_perm(perm_name, creator, item)
assert rules.has_perm(perm_name, group_member_in_org, item)
assert rules.has_perm(perm_name, group_member_out, item)
assert rules.has_perm(perm_name, group_member_in_pro, item)
Expand All @@ -72,11 +76,13 @@ def test_phase_active_project_private(phase_factory, chapter_factory,
project.participants.add(participant)
project, group_member_in_org, group_member_in_pro, group_member_out = \
setup_group_members(project, group_factory, user_factory)
creator = item.creator

assert project.access == Access.PRIVATE
with freeze_phase(phase):
assert not rules.has_perm(perm_name, anonymous, item)
assert not rules.has_perm(perm_name, user, item)
assert not rules.has_perm(perm_name, creator, item)
assert not rules.has_perm(perm_name, group_member_in_org, item)
assert not rules.has_perm(perm_name, group_member_out, item)
assert rules.has_perm(perm_name, group_member_in_pro, item)
Expand All @@ -98,11 +104,13 @@ def test_phase_active_project_semipublic(phase_factory, chapter_factory,
project.participants.add(participant)
project, group_member_in_org, group_member_in_pro, group_member_out = \
setup_group_members(project, group_factory, user_factory)
creator = item.creator

assert project.access == Access.SEMIPUBLIC
with freeze_phase(phase):
assert not rules.has_perm(perm_name, anonymous, item)
assert not rules.has_perm(perm_name, user, item)
assert not rules.has_perm(perm_name, creator, item)
assert not rules.has_perm(perm_name, group_member_in_org, item)
assert not rules.has_perm(perm_name, group_member_out, item)
assert rules.has_perm(perm_name, group_member_in_pro, item)
Expand All @@ -122,11 +130,13 @@ def test_phase_active_project_draft(phase_factory, chapter_factory,
anonymous, moderator, initiator = setup_users(project)
project, group_member_in_org, group_member_in_pro, group_member_out = \
setup_group_members(project, group_factory, user_factory)
creator = item.creator

assert project.is_draft
with freeze_phase(phase):
assert not rules.has_perm(perm_name, anonymous, item)
assert not rules.has_perm(perm_name, user, item)
assert not rules.has_perm(perm_name, creator, item)
assert not rules.has_perm(perm_name, group_member_in_org, item)
assert not rules.has_perm(perm_name, group_member_out, item)
assert rules.has_perm(perm_name, group_member_in_pro, item)
Expand All @@ -146,11 +156,13 @@ def test_post_phase_project_archived(phase_factory, chapter_factory,
anonymous, moderator, initiator = setup_users(project)
project, group_member_in_org, group_member_in_pro, group_member_out = \
setup_group_members(project, group_factory, user_factory)
creator = item.creator

assert project.is_archived
with freeze_post_phase(phase):
assert not rules.has_perm(perm_name, anonymous, item)
assert not rules.has_perm(perm_name, user, item)
assert not rules.has_perm(perm_name, creator, item)
assert not rules.has_perm(perm_name, group_member_in_org, item)
assert not rules.has_perm(perm_name, group_member_out, item)
assert rules.has_perm(perm_name, group_member_in_pro, item)
Expand Down
12 changes: 12 additions & 0 deletions tests/documents/rules/test_rules_comment_paragraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ def test_pre_phase(phase_factory, chapter_factory, paragraph_factory,
anonymous, moderator, initiator = setup_users(project)
project, group_member_in_org, group_member_in_pro, group_member_out = \
setup_group_members(project, group_factory, user_factory)
creator = item.creator

paragraph = paragraph_factory(chapter=item)

assert project.access == Access.PUBLIC
with freeze_pre_phase(phase):
assert not rules.has_perm(perm_name, anonymous, paragraph)
assert not rules.has_perm(perm_name, user, paragraph)
assert not rules.has_perm(perm_name, creator, paragraph)
assert not rules.has_perm(perm_name, group_member_in_org, paragraph)
assert not rules.has_perm(perm_name, group_member_out, paragraph)
assert rules.has_perm(perm_name, group_member_in_pro, paragraph)
Expand All @@ -49,13 +51,15 @@ def test_phase_active(phase_factory, chapter_factory, paragraph_factory,
anonymous, moderator, initiator = setup_users(project)
project, group_member_in_org, group_member_in_pro, group_member_out = \
setup_group_members(project, group_factory, user_factory)
creator = item.creator

paragraph = paragraph_factory(chapter=item)

assert project.access == Access.PUBLIC
with freeze_phase(phase):
assert not rules.has_perm(perm_name, anonymous, paragraph)
assert rules.has_perm(perm_name, user, paragraph)
assert rules.has_perm(perm_name, creator, paragraph)
assert rules.has_perm(perm_name, group_member_in_org, paragraph)
assert rules.has_perm(perm_name, group_member_out, paragraph)
assert rules.has_perm(perm_name, group_member_in_pro, paragraph)
Expand All @@ -76,13 +80,15 @@ def test_phase_active_project_private(phase_factory, chapter_factory,
project.participants.add(participant)
project, group_member_in_org, group_member_in_pro, group_member_out = \
setup_group_members(project, group_factory, user_factory)
creator = item.creator

paragraph = paragraph_factory(chapter=item)

assert project.access == Access.PRIVATE
with freeze_phase(phase):
assert not rules.has_perm(perm_name, anonymous, paragraph)
assert not rules.has_perm(perm_name, user, paragraph)
assert not rules.has_perm(perm_name, creator, paragraph)
assert not rules.has_perm(perm_name, group_member_in_org, paragraph)
assert not rules.has_perm(perm_name, group_member_out, paragraph)
assert rules.has_perm(perm_name, group_member_in_pro, paragraph)
Expand All @@ -104,13 +110,15 @@ def test_phase_active_project_semipublic(phase_factory, chapter_factory,
project.participants.add(participant)
project, group_member_in_org, group_member_in_pro, group_member_out = \
setup_group_members(project, group_factory, user_factory)
creator = item.creator

paragraph = paragraph_factory(chapter=item)

assert project.access == Access.SEMIPUBLIC
with freeze_phase(phase):
assert not rules.has_perm(perm_name, anonymous, paragraph)
assert not rules.has_perm(perm_name, user, paragraph)
assert not rules.has_perm(perm_name, creator, paragraph)
assert not rules.has_perm(perm_name, group_member_in_org, paragraph)
assert not rules.has_perm(perm_name, group_member_out, paragraph)
assert rules.has_perm(perm_name, group_member_in_pro, paragraph)
Expand All @@ -130,13 +138,15 @@ def test_phase_active_project_draft(phase_factory, chapter_factory,
anonymous, moderator, initiator = setup_users(project)
project, group_member_in_org, group_member_in_pro, group_member_out = \
setup_group_members(project, group_factory, user_factory)
creator = item.creator

paragraph = paragraph_factory(chapter=item)

assert project.is_draft
with freeze_phase(phase):
assert not rules.has_perm(perm_name, anonymous, paragraph)
assert not rules.has_perm(perm_name, user, paragraph)
assert not rules.has_perm(perm_name, creator, paragraph)
assert not rules.has_perm(perm_name, group_member_in_org, paragraph)
assert not rules.has_perm(perm_name, group_member_out, paragraph)
assert rules.has_perm(perm_name, group_member_in_pro, paragraph)
Expand All @@ -155,13 +165,15 @@ def test_post_phase_project_archived(phase_factory, chapter_factory,
anonymous, moderator, initiator = setup_users(project)
project, group_member_in_org, group_member_in_pro, group_member_out = \
setup_group_members(project, group_factory, user_factory)
creator = item.creator

paragraph = paragraph_factory(chapter=item)

assert project.is_archived
with freeze_post_phase(phase):
assert not rules.has_perm(perm_name, anonymous, paragraph)
assert not rules.has_perm(perm_name, user, paragraph)
assert not rules.has_perm(perm_name, creator, paragraph)
assert not rules.has_perm(perm_name, group_member_in_org, paragraph)
assert not rules.has_perm(perm_name, group_member_out, paragraph)
assert rules.has_perm(perm_name, group_member_in_pro, paragraph)
Expand Down
12 changes: 12 additions & 0 deletions tests/documents/rules/test_rules_view_chapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ def test_pre_phase(phase_factory, chapter_factory,
anonymous, moderator, initiator = setup_users(project)
project, group_member_in_org, group_member_in_pro, group_member_out = \
setup_group_members(project, group_factory, user_factory)
creator = item.creator

assert project.access == Access.PUBLIC
with freeze_pre_phase(phase):
assert rules.has_perm(perm_name, anonymous, item)
assert rules.has_perm(perm_name, user, item)
assert rules.has_perm(perm_name, creator, item)
assert rules.has_perm(perm_name, group_member_in_org, item)
assert rules.has_perm(perm_name, group_member_out, item)
assert rules.has_perm(perm_name, group_member_in_pro, item)
Expand All @@ -48,11 +50,13 @@ def test_phase_active(phase_factory, chapter_factory,
anonymous, moderator, initiator = setup_users(project)
project, group_member_in_org, group_member_in_pro, group_member_out = \
setup_group_members(project, group_factory, user_factory)
creator = item.creator

assert project.access == Access.PUBLIC
with freeze_phase(phase):
assert rules.has_perm(perm_name, anonymous, item)
assert rules.has_perm(perm_name, user, item)
assert rules.has_perm(perm_name, creator, item)
assert rules.has_perm(perm_name, group_member_in_org, item)
assert rules.has_perm(perm_name, group_member_out, item)
assert rules.has_perm(perm_name, group_member_in_pro, item)
Expand All @@ -73,11 +77,13 @@ def test_phase_active_project_private(phase_factory, chapter_factory,
project.participants.add(participant)
project, group_member_in_org, group_member_in_pro, group_member_out = \
setup_group_members(project, group_factory, user_factory)
creator = item.creator

assert project.access == Access.PRIVATE
with freeze_phase(phase):
assert not rules.has_perm(perm_name, anonymous, item)
assert not rules.has_perm(perm_name, user, item)
assert not rules.has_perm(perm_name, creator, item)
assert not rules.has_perm(perm_name, group_member_in_org, item)
assert not rules.has_perm(perm_name, group_member_out, item)
assert rules.has_perm(perm_name, group_member_in_pro, item)
Expand All @@ -99,11 +105,13 @@ def test_phase_active_project_semipublic(phase_factory, chapter_factory,
project.participants.add(participant)
project, group_member_in_org, group_member_in_pro, group_member_out = \
setup_group_members(project, group_factory, user_factory)
creator = item.creator

assert project.access == Access.SEMIPUBLIC
with freeze_phase(phase):
assert rules.has_perm(perm_name, anonymous, item)
assert rules.has_perm(perm_name, user, item)
assert rules.has_perm(perm_name, creator, item)
assert rules.has_perm(perm_name, group_member_in_org, item)
assert rules.has_perm(perm_name, group_member_out, item)
assert rules.has_perm(perm_name, group_member_in_pro, item)
Expand All @@ -123,11 +131,13 @@ def test_phase_active_project_draft(phase_factory, chapter_factory,
anonymous, moderator, initiator = setup_users(project)
project, group_member_in_org, group_member_in_pro, group_member_out = \
setup_group_members(project, group_factory, user_factory)
creator = item.creator

assert project.is_draft
with freeze_phase(phase):
assert not rules.has_perm(perm_name, anonymous, item)
assert not rules.has_perm(perm_name, user, item)
assert not rules.has_perm(perm_name, creator, item)
assert not rules.has_perm(perm_name, group_member_in_org, item)
assert not rules.has_perm(perm_name, group_member_out, item)
assert rules.has_perm(perm_name, group_member_in_pro, item)
Expand All @@ -146,11 +156,13 @@ def test_post_phase_project_archived(phase_factory, chapter_factory,
anonymous, moderator, initiator = setup_users(project)
project, group_member_in_org, group_member_in_pro, group_member_out = \
setup_group_members(project, group_factory, user_factory)
creator = item.creator

assert project.is_archived
with freeze_post_phase(phase):
assert rules.has_perm(perm_name, anonymous, item)
assert rules.has_perm(perm_name, user, item)
assert rules.has_perm(perm_name, creator, item)
assert rules.has_perm(perm_name, group_member_in_org, item)
assert rules.has_perm(perm_name, group_member_out, item)
assert rules.has_perm(perm_name, group_member_in_pro, item)
Expand Down
12 changes: 12 additions & 0 deletions tests/documents/rules/test_rules_view_paragraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ def test_pre_phase(phase_factory, chapter_factory, paragraph_factory,
anonymous, moderator, initiator = setup_users(project)
project, group_member_in_org, group_member_in_pro, group_member_out = \
setup_group_members(project, group_factory, user_factory)
creator = item.creator

paragraph = paragraph_factory(chapter=item)

assert project.access == Access.PUBLIC
with freeze_pre_phase(phase):
assert rules.has_perm(perm_name, anonymous, paragraph)
assert rules.has_perm(perm_name, user, paragraph)
assert rules.has_perm(perm_name, creator, paragraph)
assert rules.has_perm(perm_name, group_member_in_org, paragraph)
assert rules.has_perm(perm_name, group_member_out, paragraph)
assert rules.has_perm(perm_name, group_member_in_pro, paragraph)
Expand All @@ -51,13 +53,15 @@ def test_phase_active(phase_factory, chapter_factory, paragraph_factory,
anonymous, moderator, initiator = setup_users(project)
project, group_member_in_org, group_member_in_pro, group_member_out = \
setup_group_members(project, group_factory, user_factory)
creator = item.creator

paragraph = paragraph_factory(chapter=item)

assert project.access == Access.PUBLIC
with freeze_phase(phase):
assert rules.has_perm(perm_name, anonymous, paragraph)
assert rules.has_perm(perm_name, user, paragraph)
assert rules.has_perm(perm_name, creator, paragraph)
assert rules.has_perm(perm_name, group_member_in_org, paragraph)
assert rules.has_perm(perm_name, group_member_out, paragraph)
assert rules.has_perm(perm_name, group_member_in_pro, paragraph)
Expand All @@ -79,13 +83,15 @@ def test_phase_active_project_private(phase_factory, chapter_factory,
project.participants.add(participant)
project, group_member_in_org, group_member_in_pro, group_member_out = \
setup_group_members(project, group_factory, user_factory)
creator = item.creator

paragraph = paragraph_factory(chapter=item)

assert project.access == Access.PRIVATE
with freeze_phase(phase):
assert not rules.has_perm(perm_name, anonymous, paragraph)
assert not rules.has_perm(perm_name, user, paragraph)
assert not rules.has_perm(perm_name, creator, paragraph)
assert not rules.has_perm(perm_name, group_member_in_org, paragraph)
assert not rules.has_perm(perm_name, group_member_out, paragraph)
assert rules.has_perm(perm_name, group_member_in_pro, paragraph)
Expand All @@ -108,13 +114,15 @@ def test_phase_active_project_semipublic(phase_factory, chapter_factory,
project.participants.add(participant)
project, group_member_in_org, group_member_in_pro, group_member_out = \
setup_group_members(project, group_factory, user_factory)
creator = item.creator

paragraph = paragraph_factory(chapter=item)

assert project.access == Access.SEMIPUBLIC
with freeze_phase(phase):
assert rules.has_perm(perm_name, anonymous, paragraph)
assert rules.has_perm(perm_name, user, paragraph)
assert rules.has_perm(perm_name, creator, paragraph)
assert rules.has_perm(perm_name, group_member_in_org, paragraph)
assert rules.has_perm(perm_name, group_member_out, paragraph)
assert rules.has_perm(perm_name, group_member_in_pro, paragraph)
Expand All @@ -135,13 +143,15 @@ def test_phase_active_project_draft(phase_factory, chapter_factory,
anonymous, moderator, initiator = setup_users(project)
project, group_member_in_org, group_member_in_pro, group_member_out = \
setup_group_members(project, group_factory, user_factory)
creator = item.creator

paragraph = paragraph_factory(chapter=item)

assert project.is_draft
with freeze_phase(phase):
assert not rules.has_perm(perm_name, anonymous, paragraph)
assert not rules.has_perm(perm_name, user, paragraph)
assert not rules.has_perm(perm_name, creator, paragraph)
assert not rules.has_perm(perm_name, group_member_in_org, paragraph)
assert not rules.has_perm(perm_name, group_member_out, paragraph)
assert rules.has_perm(perm_name, group_member_in_pro, paragraph)
Expand All @@ -161,13 +171,15 @@ def test_post_phase_project_archived(phase_factory, chapter_factory,
anonymous, moderator, initiator = setup_users(project)
project, group_member_in_org, group_member_in_pro, group_member_out = \
setup_group_members(project, group_factory, user_factory)
creator = item.creator

paragraph = paragraph_factory(chapter=item)

assert project.is_archived
with freeze_post_phase(phase):
assert rules.has_perm(perm_name, anonymous, paragraph)
assert rules.has_perm(perm_name, user, paragraph)
assert rules.has_perm(perm_name, creator, paragraph)
assert rules.has_perm(perm_name, group_member_in_org, paragraph)
assert rules.has_perm(perm_name, group_member_out, paragraph)
assert rules.has_perm(perm_name, group_member_in_pro, paragraph)
Expand Down
Loading

0 comments on commit 790c16a

Please sign in to comment.