Example #1
0
def test_group_get_membership_for_non_member(group):

    another_group = GroupFactory()

    membership = MembershipFactory(group=another_group)

    assert not group.get_membership(user=membership.member)
Example #2
0
def test_group_contains_non_member(group):

    another_group = GroupFactory()

    membership = MembershipFactory(group=another_group)

    assert membership.member not in group
Example #3
0
def test_admin_user_permission(user, group, request_mock, view,
                               membership_type):
    """ Verifies that no users should have admin permissions based on their type. """
    permission = IsAdminUser()
    MembershipFactory(member=user, type=membership_type)

    assert not permission.has_object_permission(request_mock, view, group)
Example #4
0
def test_board_member_permission(user, group, request_mock, view,
                                 membership_type, expected):
    """ Verifies that all board members have the board member permission in their group """
    permission = IsBoardMember()
    MembershipFactory(member=user, group=group, type=membership_type)

    assert permission.has_object_permission(request_mock, view,
                                            group) == expected
Example #5
0
def test_group_leader_permission(user, group, request_mock, view,
                                 membership_type, expected):
    """ Verifies that only leaders have the leader permission in their group """
    permission = IsGroupLeader()
    MembershipFactory(member=user, group=group, type=membership_type)

    assert permission.has_object_permission(request_mock, view,
                                            group) == expected
Example #6
0
def test_group_member_permission(user, group, request_mock, view,
                                 membership_type):
    """ Verifies that all group members have the group member permission in their group """

    permission = IsGroupMember()
    MembershipFactory(member=user, group=group, type=membership_type)

    assert permission.has_object_permission(request_mock, view, group)
def test_membership_factory():
    """Test that a membership object exist """

    membership = MembershipFactory()

    assert membership.type == MembershipType.member
    assert membership.group.name in [
        "Aikido", "American Football", "Volleyball"
    ]
Example #8
0
def test_no_permissions_in_other_groups(user, group, view, request_mock,
                                        membership_type, permission):
    """ Verifies that a permission is only granted inside the given group """
    MembershipFactory(member=user, group=group, type=membership_type)
    other_group = GroupFactory()

    assert group != other_group
    assert not permission.has_object_permission(request_mock, view,
                                                other_group)
Example #9
0
def test_group_contains_for_actual_member(group):

    membership = MembershipFactory(group=group)

    assert membership.member in group
Example #10
0
def test_group_get_membership_for_actual_member(group):

    membership = MembershipFactory(group=group)

    assert group.get_membership(user=membership.member) == membership
Example #11
0
def other_membership(user, other_group):
    return MembershipFactory(member=user, group=other_group)
Example #12
0
def koie_membership(user, koie_group):
    return MembershipFactory(member=user, group=koie_group)
Example #13
0
def sit_membership(user, sit_group):
    return MembershipFactory(member=user, group=sit_group)