def test_save_new_mixtapes(self): copy_of_db = os.path.join(self.temp_dir, 'copy.db') shutil.copy(self.non_empty_db, copy_of_db) song_list = SongList(copy_of_db) new_mixtapes = song_list.get_new_mixtapes() for song in song_list: self.assertEqual(song.mixtape_vol, 0) self.assertEqual(song.mixtape_item, 0) song_list.save_new_mixtapes(new_mixtapes) for song in song_list: self.assertNotEqual(song.mixtape_vol, 0) self.assertNotEqual(song.mixtape_item, 0) for song in new_mixtapes[1]: self.assertEqual(song.mixtape_vol, 2)
def test_get_new_mixtapes_when_no_new_songs_should_fail(self): copy_of_db = os.path.join(self.temp_dir, 'copy.db') shutil.copy(self.non_empty_db, copy_of_db) song_list = SongList(copy_of_db) new_mixtapes = song_list.get_new_mixtapes() song_list.save_new_mixtapes(new_mixtapes) with self.assertRaises(NoSongsFoxMixtape): song_list.get_new_mixtapes()
def test_add_song(self): song_list = SongList(self.empty_db) song = Song(artist='Artist', title='Title', album='Album') self.assertEqual(len(song_list), 0) self.assertFalse(song in song_list) song_list.add_song(song) self.assertEqual(len(song_list), 1) self.assertTrue(song in song_list) self.assertTrue( Song(artist='Artist', title='Title', album='Album') in song_list) with self.assertRaises(ValueError): song_list.add_song(song)
def test_add_song_from_filename(self): song_list = SongList(self.empty_db) file_path = os.path.join(self.mp3_files, 'Kinematic - Peyote.mp3') song = Song.from_filename(file_path, music_dir=self.mp3_files) self.assertEqual(len(song_list), 0) self.assertFalse(song in song_list) song_list.add_song(song) self.assertEqual(len(song_list), 1) self.assertTrue(song in song_list) self.assertTrue( Song(artist='Kinematic', title='Peyote', album='Kites') in song_list) with self.assertRaises(ValueError): song_list.add_song(song) print(song.as_dict())
def setUp(self): super().setUp() test_db = os.path.join(self.test_files, 'test.db') song_list = SongList(test_db) self.list_of_songs = list(song_list)
def test_get_new_mixtapes_on_empty_list_should_fail(self): song_list = SongList(self.empty_db) with self.assertRaises(NoSongsFoxMixtape): song_list.get_new_mixtapes()
def test_get_new_mixtapes(self): song_list = SongList(self.non_empty_db) new_mixtapes = song_list.get_new_mixtapes() self.assertEqual(len(new_mixtapes[0] + new_mixtapes[1]), len(song_list))
def test_mixtape_fullness(self): song_list = SongList(self.non_empty_db) self.assertEqual(song_list.get_mixtape_fullness(), (2, 0.9729090347144487))
#!/usr/bin/env python # coding: utf-8 import os from songmgr.database.song_list import SongList from songmgr.gui.favourite_song_init import FavSongInit from songmgr.gui.favourite_song_main import FavouriteSong from songmgr.util.util import get_config_file_path from songmgr.util.config import DictConfig config_file = get_config_file_path('favourite_song.cfg') if not os.path.isfile(config_file): fsi = FavSongInit() fsi.mainloop() config = DictConfig(config_file) song_list = SongList(db_file=config['db_file']) FavouriteSong(song_list, config).mainloop()