コード例 #1
0
def test_removing_permissions(collection):
    """Withdraw permission from a user."""
    user = UserFactory()
    user.save()
    permission = Permission(user=user, collection=collection)
    permission.save_as(user)
    permission.delete()

    assert permission not in user.permissions
コード例 #2
0
def test_removing_permissions(superuser, user):
    """Remove the permissions an a collection."""
    collection = CollectionFactory()
    collection.save()
    permission = Permission(user=user, collection=collection)
    permission.save_as(superuser)
    permission.delete()

    assert permission not in collection.permissions
コード例 #3
0
def test_is_cataloging_admin(superuser, user):
    """Test is_cataloging_admin return value."""
    collection1, collection2 = CollectionFactory(), CollectionFactory()
    not_admin_permission = Permission(user=user, collection=collection1,
                                      cataloging_admin=False).save_as(superuser)
    admin_permission = Permission(user=user, collection=collection2,
                                  cataloging_admin=True).save_as(superuser)

    assert not_admin_permission in user.permissions and admin_permission in user.permissions
    assert user.is_cataloging_admin is True

    admin_permission.delete()
    assert admin_permission not in user.permissions
    assert user.is_cataloging_admin is False

    not_admin_permission.delete()
    assert user.permissions == []
    assert user.is_cataloging_admin is False