Exemplo n.º 1
0
    def test_track_number(self):
        song = Song(self.mp3_file_path)
        self.assertEqual(8, song.get_track_number())

        song = Song(self.flac_file_path)
        self.assertEqual(3, song.get_track_number())

        song = Song(self.m4a_file_path)
        self.assertEqual(1, song.get_track_number())

        song = Song(self.no_meta_file)
        self.assertEqual(4, song.get_track_number())

        song = Song(self.no_meta_file)
        self.assertEqual(99, song.get_track_number(99))
Exemplo n.º 2
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.º 3
0
    def test_track_title(self):
        song = Song(self.mp3_file_path)
        self.assertEqual("LadyKilla Feat. Cocc Pistol Cree", song.get_track_title())

        song = Song(self.flac_file_path)
        self.assertEqual(
            "Genocide (Feat. Kendrick Lamar, Marsha Ambrosius &" " Candice Pillay)", song.get_track_title()
        )

        song = Song(self.m4a_file_path)
        self.assertEqual("Dark Jovian", song.get_track_title())

        song = Song(self.no_meta_file)
        self.assertEqual("Lipstick", song.get_track_title())
Exemplo n.º 4
0
    def test_get_artists(self):
        song = Song(self.mp3_file_path)
        self.assertEqual("DJ Mustard", song.artists[0].name)

        song = Song(self.flac_file_path)
        self.assertEqual("Dr. Dre", song.artists[0].name)

        song = Song(self.m4a_file_path)
        self.assertEqual("Amon Tobin", song.artists[0].name)

        song = Song(self.no_meta_file)
        self.assertEqual("Imperial Teen", song.artists[0].name)

        song = Song(self.no_meta_file)
        song.artists = [Artist("Mystery Artist")]
        self.assertEqual("Mystery Artist", song.artists[0].name)

        song = Song(self.no_meta_file, artists="Mystery Artist")
        self.assertEqual("Mystery Artist", song.artists[0].name)

        song = Song(self.no_meta_file, artists=Artist("Mystery Artist"))
        self.assertEqual("Mystery Artist", song.artists[0].name)
Exemplo n.º 5
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
Exemplo n.º 6
0
 def test_get_file_type_m3a(self):
     """Test `get_file_type` method."""
     song = Song(self.flac_file_path)
     file_type = song.get_file_type()
     self.assertEqual("flac", file_type)
Exemplo n.º 7
0
 def test_get_file_type_mp3(self):
     """Test `get_file_type` method."""
     song = Song(self.mp3_file_path)
     file_type = song.get_file_type()
     self.assertEqual("mp3", file_type)
Exemplo n.º 8
0
 def test_get_file_type_flac(self):
     """Test `get_file_type` method."""
     song = Song(self.m4a_file_path)
     file_type = song.get_file_type()
     self.assertEqual("m4a", file_type)
Exemplo n.º 9
0
    def test_track_year(self):
        song = Song(self.mp3_file_path)
        self.assertIsNone(song.get_track_year())

        song = Song(self.mp3_file_path_with_year)
        self.assertEqual(1972, song.get_track_year())

        song = Song(self.flac_file_path)
        self.assertIsNone(song.get_track_year())

        song = Song(self.m4a_file_path)
        self.assertIsNone(song.get_track_year())

        song = Song(self.no_meta_file)
        self.assertIsNone(song.get_track_year())

        song = Song(self.no_meta_file)
        self.assertEqual(1999, song.get_track_year(1999))