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_service.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:f9b41a4a38d95e8be82a4e4370a122f0c0729252
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_service.py
"""
:Copyright: 2014-2025 Jochen Kupperschmidt
:License: Revised BSD (see `LICENSE` file for details)
"""

import pytest

from byceps.services.authz import authz_service
from byceps.services.authz.models import PermissionID, RoleID

from tests.helpers import create_role_with_permissions_assigned, generate_token


def test_get_permission_ids_for_user_with_user_permissions(
    database, user, permissions
):
    actual = authz_service.get_permission_ids_for_user(user.id)
    assert actual == {
        'see_everything',
        'tickle_demigods',
        'tickle_mere_mortals',
    }


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


@pytest.fixture()
def permissions(user, admin_user):
    role_id_god = RoleID('god_' + generate_token())
    role_id_demigod = RoleID('demigod_' + generate_token())

    create_role_with_permissions_assigned(
        role_id_god,
        {
            PermissionID('see_everything'),
            PermissionID('tickle_demigods'),
        },
    )

    create_role_with_permissions_assigned(
        role_id_demigod,
        {
            PermissionID('tickle_mere_mortals'),
        },
    )

    authz_service.assign_role_to_user(role_id_god, user, initiator=admin_user)
    authz_service.assign_role_to_user(
        role_id_demigod, user, initiator=admin_user
    )

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