Пример #1
0
    def test_multi_get_all(self):
        storage = self.make_storage()
        songs = []
        for i in range(10):
            song = jukebox.song.Song(
                title='song %s' % i,
                album='album %s' % i,
                artist='artist %s' % i,
                uri='path %s' % i,
            )
            song.pk = yield self.storages[i %
                                          len(self.storages)].add_song(song)
            songs.append(song)

        all_songs = yield storage.get_all_songs()
        all_songs = list(all_songs)

        songs.sort(key=operator.attrgetter('title'))
        all_songs.sort(key=operator.attrgetter('title'))

        for song1, song2 in zip(songs, all_songs):
            song1.pk = None
            song2.pk = None
            print song1, song2
            util.song_assert(song1, song2)
Пример #2
0
def test_add_song():
    playlist = jukebox.song.Playlist()
    song = jukebox.song.Song(
        title='song 1',
        album='album 1',
        artist='artist 1',
        uri='path 1',
    )
    playlist.add_song(song)
    util.song_assert(song, playlist.cur)
Пример #3
0
def test_add_song():
    playlist = jukebox.song.Playlist()
    song = jukebox.song.Song(
        title='song 1',
        album='album 1',
        artist='artist 1',
        uri='path 1',
    )
    playlist.add_song(song)
    util.song_assert(song, playlist.cur)
Пример #4
0
    def test_add_get_song(self):
        storage = self.make_storage()
        song = jukebox.song.Song(
            title='song 1',
            album='album 1',
            artist='artist 1',
            uri='path 1',
        )
        pk = yield storage.add_song(song)
        song_back = yield storage.get_song(pk)

        util.song_assert(song, song_back)
Пример #5
0
    def test_multi_add_get(self):
        storage = self.make_storage()
        for i in range(10):
            song = jukebox.song.Song(
                title='song %s' % i,
                album='album %s' % i,
                artist='artist %s' % i,
                uri='path %s' % i,
            )
            song.pk = yield storage.add_song(song)

        song_back = yield storage.get_song(song.pk)

        util.song_assert(song, song_back)
Пример #6
0
def test_add_two_songs():
    playlist = jukebox.song.Playlist()
    song1 = jukebox.song.Song(
        title='song 1',
        album='album 1',
        artist='artist 1',
        uri='path 1',
    )
    playlist.add_song(song1)
    util.song_assert(song1, playlist.cur)
    song2 = jukebox.song.Song(
        title='song 2',
        album='album 2',
        artist='artist 2',
        uri='path 2',
    )
    playlist.add_song(song2)
    util.song_assert(song1, playlist.cur)
Пример #7
0
def test_add_two_songs():
    playlist = jukebox.song.Playlist()
    song1 = jukebox.song.Song(
        title='song 1',
        album='album 1',
        artist='artist 1',
        uri='path 1',
    )
    playlist.add_song(song1)
    util.song_assert(song1, playlist.cur)
    song2 = jukebox.song.Song(
        title='song 2',
        album='album 2',
        artist='artist 2',
        uri='path 2',
    )
    playlist.add_song(song2)
    util.song_assert(song1, playlist.cur)
Пример #8
0
def test_iter():
    playlist = jukebox.song.Playlist()
    song1 = jukebox.song.Song(
        title='song 1',
        album='album 1',
        artist='artist 1',
        uri='path 1',
    )
    playlist.add_song(song1)
    song2 = jukebox.song.Song(
        title='song 2',
        album='album 2',
        artist='artist 2',
        uri='path 2',
    )
    playlist.add_song(song2)

    song_list = list(playlist)

    assert len(song_list) == 1
    util.song_assert(song_list[0], song2)
Пример #9
0
def test_iter():
    playlist = jukebox.song.Playlist()
    song1 = jukebox.song.Song(
        title='song 1',
        album='album 1',
        artist='artist 1',
        uri='path 1',
    )
    playlist.add_song(song1)
    song2 = jukebox.song.Song(
        title='song 2',
        album='album 2',
        artist='artist 2',
        uri='path 2',
    )
    playlist.add_song(song2)

    song_list = list(playlist)

    assert len(song_list) == 1
    util.song_assert(song_list[0], song2)
Пример #10
0
def test_advance():
    playlist = jukebox.song.Playlist()
    song1 = jukebox.song.Song(
        title='song 1',
        album='album 1',
        artist='artist 1',
        uri='path 1',
    )
    playlist.add_song(song1)
    song2 = jukebox.song.Song(
        title='song 2',
        album='album 2',
        artist='artist 2',
        uri='path 2',
    )
    playlist.add_song(song2)

    util.song_assert(playlist.cur, song1)
    playlist.advance()
    util.song_assert(playlist.cur, song2)
    playlist.advance()
    assert playlist.cur is None
Пример #11
0
def test_advance():
    playlist = jukebox.song.Playlist()
    song1 = jukebox.song.Song(
        title='song 1',
        album='album 1',
        artist='artist 1',
        uri='path 1',
    )
    playlist.add_song(song1)
    song2 = jukebox.song.Song(
        title='song 2',
        album='album 2',
        artist='artist 2',
        uri='path 2',
    )
    playlist.add_song(song2)

    util.song_assert(playlist.cur, song1)
    playlist.advance()
    util.song_assert(playlist.cur, song2)
    playlist.advance()
    assert playlist.cur is None