import pytest

from funkwhale_api.users.oauth import scopes


@pytest.mark.parametrize(
    "user_perms, expected",
    [
        (
            # All permissions, so all scopes
            {"moderation": True, "library": True, "settings": True},
            {
                "read:profile",
                "write:profile",
                "read:libraries",
                "write:libraries",
                "read:playlists",
                "write:playlists",
                "read:favorites",
                "write:favorites",
                "read:notifications",
                "write:notifications",
                "read:radios",
                "write:radios",
                "read:follows",
                "write:follows",
                "read:edits",
                "write:edits",
                "read:filters",
                "write:filters",
                "read:reports",
                "write:reports",
                "read:listenings",
                "write:listenings",
                "read:security",
                "write:security",
                "write:listenings",
                "read:plugins",
                "write:plugins",
                "read:instance:policies",
                "write:instance:policies",
                "read:instance:accounts",
                "write:instance:accounts",
                "read:instance:domains",
                "write:instance:domains",
                "read:instance:settings",
                "write:instance:settings",
                "read:instance:users",
                "write:instance:users",
                "read:instance:invitations",
                "write:instance:invitations",
                "read:instance:edits",
                "write:instance:edits",
                "read:instance:libraries",
                "write:instance:libraries",
                "read:instance:notes",
                "write:instance:notes",
                "read:instance:reports",
                "write:instance:reports",
                "read:instance:requests",
                "write:instance:requests",
            },
        ),
        (
            {"moderation": True, "library": False, "settings": True},
            {
                "read:profile",
                "write:profile",
                "read:libraries",
                "write:libraries",
                "read:playlists",
                "write:playlists",
                "read:favorites",
                "write:favorites",
                "read:notifications",
                "write:notifications",
                "read:radios",
                "write:radios",
                "read:follows",
                "write:follows",
                "read:edits",
                "write:edits",
                "read:filters",
                "write:filters",
                "read:reports",
                "write:reports",
                "read:listenings",
                "write:listenings",
                "read:security",
                "write:security",
                "read:plugins",
                "write:plugins",
                "read:instance:policies",
                "write:instance:policies",
                "read:instance:accounts",
                "write:instance:accounts",
                "read:instance:domains",
                "write:instance:domains",
                "read:instance:settings",
                "write:instance:settings",
                "read:instance:users",
                "write:instance:users",
                "read:instance:invitations",
                "write:instance:invitations",
                "read:instance:notes",
                "write:instance:notes",
                "read:instance:reports",
                "write:instance:reports",
                "read:instance:requests",
                "write:instance:requests",
            },
        ),
        (
            {"moderation": True, "library": False, "settings": False},
            {
                "read:profile",
                "write:profile",
                "read:libraries",
                "write:libraries",
                "read:playlists",
                "write:playlists",
                "read:favorites",
                "write:favorites",
                "read:notifications",
                "write:notifications",
                "read:radios",
                "write:radios",
                "read:follows",
                "write:follows",
                "read:edits",
                "write:edits",
                "read:filters",
                "write:filters",
                "read:reports",
                "write:reports",
                "read:listenings",
                "write:listenings",
                "read:security",
                "write:security",
                "read:plugins",
                "write:plugins",
                "read:instance:policies",
                "write:instance:policies",
                "read:instance:accounts",
                "write:instance:accounts",
                "read:instance:domains",
                "write:instance:domains",
                "read:instance:notes",
                "write:instance:notes",
                "read:instance:reports",
                "write:instance:reports",
                "read:instance:requests",
                "write:instance:requests",
            },
        ),
        (
            {"moderation": False, "library": False, "settings": False},
            {
                "read:profile",
                "write:profile",
                "read:libraries",
                "write:libraries",
                "read:playlists",
                "write:playlists",
                "read:favorites",
                "write:favorites",
                "read:notifications",
                "write:notifications",
                "read:radios",
                "write:radios",
                "read:follows",
                "write:follows",
                "read:edits",
                "write:edits",
                "read:filters",
                "write:filters",
                "read:reports",
                "write:reports",
                "read:listenings",
                "write:listenings",
                "read:security",
                "write:security",
                "read:plugins",
                "write:plugins",
            },
        ),
    ],
)
def test_get_scopes_from_user_permissions(user_perms, expected):
    assert scopes.get_from_permissions(**user_perms) == expected
