def test_scope_remove_does_not_exist(): scope = oauth2.Scope(oauth2.Read(), oauth2.Write(1), oauth2.Delegate(2, oauth2.Write(3))) scope.remove(oauth2.Write(5)) assert str(scope) == 'delegate[2]:write[3] read write[1]'
def test_scope_remove(): scope = oauth2.Scope(oauth2.Read(), oauth2.Write(1), oauth2.Delegate(2, oauth2.Write(3))) scope.remove(oauth2.Write(1)) assert str(scope) == 'delegate[2]:write[3] read'
def test_scope_add(): scope = oauth2.Scope(oauth2.Read(), oauth2.Write(1), oauth2.Delegate(2, oauth2.Write(3))) scope.add(oauth2.Write(4)) assert str(scope) == 'delegate[2]:write[3] read write[1] write[4]'
def test_delegate_noone(): with pytest.raises(TypeError): oauth2.Delegate()
def test_delegate_nothing(): with pytest.raises(TypeError): oauth2.Delegate('x')
def test_delegate_write_something(): obj = oauth2.Delegate('other', oauth2.Write('something')) assert str(obj) == 'delegate[other]:write[something]' assert obj.resource_id == 'other' assert obj.access == oauth2.Write('something')