Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_sub_Scope_Scope_same(self):
s = Scope('a') - Scope('a')
assert str(s) == ''
def test_add_Scope_str(self):
s = Scope('a') + 'b'
assert str(s) == 'a b'
def test_scope_unpackable(self):
s1 = Scope('b', 'a')
s2 = Scope(*s1)
assert s1 == s2
def test_repr_like_instantiation(self):
s = Scope('a', 'b')
assert repr(s) == "Scope('a', 'b')"
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'
def test_scope_initialisable_with_enum(self):
s = Scope(scope.user_read_private)
assert str(s) == 'user-read-private'
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'
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'
def test_add_Scope_Scope(self):
s = Scope('a') + Scope('b')
assert str(s) == 'a b'
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