"""Permission definition tests."""
from app.permissions.definitions import ALL_PERMISSIONS, PERMISSION_PREFIXES


def test_all_permissions_use_delivery_prefix():
    assert ALL_PERMISSIONS
    for perm in ALL_PERMISSIONS:
        assert perm.startswith("delivery.")


def test_permission_prefixes_stable():
    assert "delivery." in PERMISSION_PREFIXES
    assert "delivery.organizations." in PERMISSION_PREFIXES
    assert "delivery.drivers." in PERMISSION_PREFIXES
    assert "delivery.dispatch." in PERMISSION_PREFIXES


def test_driver_permissions_present():
    from app.permissions.definitions import (
        DRIVERS_ACTIVATE,
        DRIVERS_CREATE,
        DRIVERS_CREDENTIALS_MANAGE,
        DRIVERS_VIEW,
    )

    assert DRIVERS_VIEW in ALL_PERMISSIONS
    assert DRIVERS_CREATE in ALL_PERMISSIONS
    assert DRIVERS_ACTIVATE in ALL_PERMISSIONS
    assert DRIVERS_CREDENTIALS_MANAGE in ALL_PERMISSIONS
