How to use the tekore.Scope function in tekore

To help you get started, we’ve selected a few tekore examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github felix-hilden / spotipy / tests / auth / scope.py View on Github external
def test_sub_Scope_Scope_same(self):
        s = Scope('a') - Scope('a')
        assert str(s) == ''
github felix-hilden / spotipy / tests / auth / scope.py View on Github external
def test_add_Scope_str(self):
        s = Scope('a') + 'b'
        assert str(s) == 'a b'
github felix-hilden / spotipy / tests / auth / scope.py View on Github external
def test_scope_unpackable(self):
        s1 = Scope('b', 'a')
        s2 = Scope(*s1)
        assert s1 == s2
github felix-hilden / spotipy / tests / auth / scope.py View on Github external
def test_repr_like_instantiation(self):
        s = Scope('a', 'b')
        assert repr(s) == "Scope('a', 'b')"
github felix-hilden / spotipy / tests / auth / scope.py View on Github external
def test_subtracting_scopes_preservers_originals(self):
        s1 = Scope('b', 'a')
        s2 = Scope('c', 'b')

        assert isinstance(s1 - s2, Scope)
        assert s1 - s2 == {'a'}
        assert str(s1) == 'a b'
        assert str(s2) == 'b c'
github felix-hilden / spotipy / tests / auth / scope.py View on Github external
def test_scope_initialisable_with_enum(self):
        s = Scope(scope.user_read_private)
        assert str(s) == 'user-read-private'
github felix-hilden / spotipy / tests / auth / scope.py View on Github external
def test_adding_scopes_preserves_originals(self):
        s1 = Scope('b', 'a')
        s2 = Scope('c', 'b')

        assert isinstance(s1 + s2, Scope)
        assert s1 + s2 == {'a', 'b', 'c'}
        assert str(s1) == 'a b'
        assert str(s2) == 'b c'
github felix-hilden / spotipy / tests / auth / scope.py View on Github external
def test_adding_scopes_preserves_originals(self):
        s1 = Scope('b', 'a')
        s2 = Scope('c', 'b')

        assert isinstance(s1 + s2, Scope)
        assert s1 + s2 == {'a', 'b', 'c'}
        assert str(s1) == 'a b'
        assert str(s2) == 'b c'
github felix-hilden / spotipy / tests / auth / scope.py View on Github external
def test_add_Scope_Scope(self):
        s = Scope('a') + Scope('b')
        assert str(s) == 'a b'
github felix-hilden / spotipy / tekore / _client / decor / __init__.py View on Github external
Provides ``required_scopes``, ``optional_scopes``
    and their combination ``scopes``.
    Also modifies the docstring to include scope information.

    Parameters
    ----------
    required
        required scopes
    optional
        optional scopes
    """
    required = required or []
    optional = optional or []
    required_scope = Scope(*required)
    optional_scope = Scope(*optional)
    doc_msg = '\n'.join([
        '| Required :class:`scope`: ' + (str(required_scope) or 'none'),
        '| Optional :class:`scope`: ' + (str(optional_scope) or 'none')
    ])

    def decorator(function: Callable) -> Callable:
        function.required_scope = required_scope
        function.optional_scope = optional_scope
        function.scope = required_scope + optional_scope
        function.__doc__ = _add_doc_section(function.__doc__, doc_msg)
        return function
    return decorator