Exemplo n.º 1
0
def test_on_connection_state_changed_when_disconnected(spotify_mock, caplog):
    session_mock = spotify_mock.Session.return_value
    session_mock.connection.state = spotify_mock.ConnectionState.DISCONNECTED
    logged_in_event = threading.Event()
    logged_out_event = threading.Event()
    actor_mock = mock.Mock(spec=backend.SpotifyBackend)

    backend.on_connection_state_changed(
        session_mock, logged_in_event, logged_out_event, actor_mock)

    assert 'Disconnected from Spotify' in caplog.text()
Exemplo n.º 2
0
def test_on_connection_state_changed_when_offline(spotify_mock, caplog):
    session_mock = spotify_mock.Session.return_value
    session_mock.connection.state = spotify_mock.ConnectionState.OFFLINE
    logged_in_event = threading.Event()
    logged_out_event = threading.Event()
    actor_mock = mock.Mock(spec=backend.SpotifyBackend)

    backend.on_connection_state_changed(
        session_mock, logged_in_event, logged_out_event, actor_mock)

    assert 'Logged in to Spotify in offline mode' in caplog.text()
    assert logged_in_event.is_set()
    assert not logged_out_event.is_set()
Exemplo n.º 3
0
def test_on_connection_state_changed_when_logged_out(spotify_mock, caplog):
    session_mock = spotify_mock.Session.return_value
    session_mock.connection.state = spotify_mock.ConnectionState.LOGGED_OUT
    logged_in_event = threading.Event()
    logged_out_event = threading.Event()
    actor_mock = mock.Mock(spec=backend.SpotifyBackend)

    backend.on_connection_state_changed(
        session_mock, logged_in_event, logged_out_event, actor_mock)

    assert 'Logged out of Spotify' in caplog.text()
    assert not logged_in_event.is_set()
    assert logged_out_event.is_set()
Exemplo n.º 4
0
def test_on_connection_state_changed_when_logged_in(spotify_mock, caplog):
    session_mock = spotify_mock.Session.return_value
    session_mock.connection.state = spotify_mock.ConnectionState.LOGGED_IN
    logged_in_event = threading.Event()
    logged_out_event = threading.Event()
    actor_mock = mock.Mock(spec=backend.SpotifyBackend)

    backend.on_connection_state_changed(session_mock, logged_in_event,
                                        logged_out_event, actor_mock)

    assert "Logged in to Spotify in online mode" in caplog.text
    assert logged_in_event.is_set()
    assert not logged_out_event.is_set()
    actor_mock.on_logged_in.assert_called_once_with()