Example #1
0
def test_on_start_logs_in(spotify_mock, web_mock, config):
    backend = get_backend(config)
    backend.on_start()

    spotify_mock.Session.return_value.login.assert_called_once_with(
        "alice", "password")
    web_mock.SpotifyOAuthClient.return_value.login.assert_called_once()
Example #2
0
def test_on_start_refreshes_playlists(spotify_mock, web_mock, config, caplog):
    backend = get_backend(config)
    backend.on_start()

    client_mock = web_mock.SpotifyOAuthClient.return_value
    client_mock.get_user_playlists.assert_called_once()
    assert "Refreshed 0 Spotify playlists" in caplog.text
    assert backend.playlists._loaded
Example #3
0
def test_on_start_configures_web_client(spotify_mock, config):
    config['spotify']['client_id'] = '1234567'
    config['spotify']['client_secret'] = 'AbCdEfG'

    backend = get_backend(config)
    backend.on_start()

    assert backend._web_client._auth == ('1234567', 'AbCdEfG')
    assert (backend._web_client._refresh_url ==
            'https://auth.mopidy.com/spotify/token')
Example #4
0
def test_on_start_configures_web_client(spotify_mock, web_mock, config):
    config["spotify"]["client_id"] = "1234567"
    config["spotify"]["client_secret"] = "AbCdEfG"

    backend = get_backend(config)
    backend.on_start()

    web_mock.SpotifyOAuthClient.assert_called_once_with(
        client_id="1234567",
        client_secret="AbCdEfG",
        proxy_config=mock.ANY,
    )
Example #5
0
def test_on_start_configures_proxy(spotify_mock, config):
    config['proxy'] = {
        'scheme': 'https',
        'hostname': 'my-proxy.example.com',
        'port': 8080,
        'username': '******',
        'password': '******',
    }
    spotify_config = spotify_mock.Config.return_value

    backend = get_backend(config)
    backend.on_start()

    assert spotify_config.proxy == 'https://my-proxy.example.com:8080'
    assert spotify_config.proxy_username == 'alice'
    assert spotify_config.proxy_password == 's3cret'

    assert (backend._web_client._session.proxies['https'] ==
            'https://*****:*****@my-proxy.example.com:8080')
Example #6
0
def test_on_start_logs_in(spotify_mock, config):
    backend = get_backend(config)
    backend.on_start()

    spotify_mock.Session.return_value.login.assert_called_once_with(
        'alice', 'password')
Example #7
0
def test_on_start_starts_the_pyspotify_event_loop(spotify_mock, config):
    backend = get_backend(config)
    backend.on_start()

    spotify_mock.EventLoop.assert_called_once_with(backend._session)
    spotify_mock.EventLoop.return_value.start.assert_called_once_with()