Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • cde5674
  • /
  • services
  • /
  • authz
  • /
  • test_deassign_all_roles_from_user.py
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge
swh:1:cnt:c5bb2dffa87d222e037cb60473f6411b0358df04
directory badge
swh:1:dir:d4041e3fdd1bc8fe3cd7cf24edac94321f1d07a2

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
test_deassign_all_roles_from_user.py
"""
:Copyright: 2014-2025 Jochen Kupperschmidt
:License: Revised BSD (see `LICENSE` file for details)
"""

import pytest

from byceps.services.authz import authz_service


def test_deassign_all_roles_from_user(
    admin_app, user1, user2, role1, role2, role3
):
    assert authz_service.find_role_ids_for_user(user1.id) == {
        role1.id,
        role2.id,
    }
    assert authz_service.find_role_ids_for_user(user2.id) == {
        role1.id,
        role3.id,
    }

    authz_service.deassign_all_roles_from_user(user1)

    # Targeted user's roles should have been deassigned.
    assert authz_service.find_role_ids_for_user(user1.id) == set()
    # All other users' roles should still be assigned.
    assert authz_service.find_role_ids_for_user(user2.id) == {
        role1.id,
        role3.id,
    }


@pytest.fixture()
def user1(make_user):
    return make_user()


@pytest.fixture()
def user2(make_user):
    return make_user()


@pytest.fixture()
def role1(make_role, user1, user2, admin_user):
    role = make_role()

    authz_service.assign_role_to_user(role.id, user1, initiator=admin_user)
    authz_service.assign_role_to_user(role.id, user2, initiator=admin_user)

    return role


@pytest.fixture()
def role2(make_role, user1, admin_user):
    role = make_role()

    authz_service.assign_role_to_user(role.id, user1, initiator=admin_user)

    return role


@pytest.fixture()
def role3(make_role, user2, admin_user):
    role = make_role()

    authz_service.assign_role_to_user(role.id, user2, initiator=admin_user)

    return role

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API