Exemplo n.º 1
0
    def test_can_create_song_creation(self, db):
        song = Song(title='Ziggy Stardust', path=self.mp3_file_path_with_year)
        db.session.add(song)
        db.session.commit()

        song = Song.query.filter_by(title='Ziggy Stardust').all()
        assert len(song) == 1
        assert song[0].title == 'Ziggy Stardust'
Exemplo n.º 2
0
def test_can_create_album_song(db):
    album = Album(
        title="The Rise And Fall Of Ziggy Stardust And The Spiders From Mars")
    artist = Artist(name="David Bowie")
    album.album_artists.append(artist)
    song = Song(title="Ziggy Stardust", path="/ziggy_stardust.mp3")
    song.artists.append(artist)
    album_song = AlbumSong()
    album_song.song = song
    album_song.album = album
    album_song.track_no = 9
    db.session.add(album)
    db.session.add(artist)
    db.session.add(song)
    db.session.add(album_song)
    db.session.commit()

    album_song = AlbumSong.query.first()
    print(album_song.album.__dict__)
    assert album_song.song.title == "Ziggy Stardust"
    assert album_song.album.title == "The Rise And Fall Of Ziggy Stardust And The Spiders From " +\
                                     "Mars"
    assert album_song.track_no == 9