Esempio n. 1
0
def test_can_restore_radio_from_previous_session(factories):
    user = factories["users.User"]()
    radio = radios.RandomRadio()
    session = radio.start_session(user)

    restarted_radio = radios.RandomRadio(session)
    assert radio.session == restarted_radio.session
Esempio n. 2
0
def test_session_radio_get_queryset_ignore_filtered_track_album_artist(
        factories, queryset_equal_list):
    cf = factories["moderation.UserFilter"](for_artist=True)
    factories["music.Track"](album__artist=cf.target_artist)
    valid_track = factories["music.Track"]()
    radio = radios.RandomRadio()
    radio.start_session(user=cf.user)

    assert radio.get_queryset() == [valid_track]
Esempio n. 3
0
def test_can_use_radio_session_to_filter_choices(factories):
    factories["music.Upload"].create_batch(10)
    user = factories["users.User"]()
    radio = radios.RandomRadio()
    session = radio.start_session(user)

    for i in range(10):
        radio.pick(filter_playable=False)

    # ensure 10 differents tracks have been suggested
    tracks_id = [
        session_track.track.pk
        for session_track in session.session_tracks.all()
    ]
    assert len(set(tracks_id)) == 10