Ejemplo n.º 1
0
def user_creds_from_env():
    user = UserCreds()
    user.load_from_env()
    if not user.access_token:
        raise AttributeError(
            "User must have an access token for some tests to run")
    yield user
Ejemplo n.º 2
0
def test_client_instantiates_with_user_creds():
    u = UserCreds()
    u.load_from_env()
    spt = Spotify(user_creds=u,
                  ensure_user_auth=False,
                  populate_user_creds=False)
    assert spt.user_creds.access_token is not None

    assert spt._caller == spt.user_creds
Ejemplo n.º 3
0
def async_spotify_user_auth():
    spotify = AsyncSpotify()
    user_creds = UserCreds()
    client_creds = ClientCreds()
    client_creds.load_from_env()
    user_creds.load_from_env()
    spotify.client_creds = client_creds
    spotify.user_creds = user_creds
    spotify._caller = spotify.user_creds
    yield spotify
Ejemplo n.º 4
0
def test_client_instantiates_with_access_token():
    u = UserCreds()
    u.load_from_env()
    access_token = u.access_token
    spt = Spotify(access_token=access_token,
                  ensure_user_auth=False,
                  populate_user_creds=False)
    assert spt.user_creds.access_token is not None
    assert spt.user_creds.refresh_token is None

    assert spt._caller == spt.user_creds

    assert not hasattr(spt, "access_token")
Ejemplo n.º 5
0
def user_creds_from_env_session():
    user = UserCreds()
    user.load_from_env()
    yield user
Ejemplo n.º 6
0
def test_client_raises_error_if_both_access_token_and_model():
    u = UserCreds()
    u.load_from_env()
    with pytest.raises(ValueError):
        Spotify(user_creds=u, access_token=u.access_token)