def test__on_new_playlist_activate(self): main = qltk.MenuItem('Menu') menu = StubbedPlaylistMenu(self.SONGS, PlaylistLibrary(SongFileLibrary())) main.set_submenu(menu) pl = menu._on_new_playlist_activate(main, self.SONGS) self.failUnless(pl, msg="No playlists added") self.failUnlessEqual(pl.songs, self.SONGS)
def test__on_new_playlist_activate(self): main = qltk.MenuItem('Menu') menu = StubbedPlaylistMenu(self.SONGS, PlaylistLibrary(SongFileLibrary())) main.set_submenu(menu) # Run it (with stubbed dialog) pl = menu._on_new_playlist_activate(main, self.SONGS) assert pl, "No playlists added" assert pl.name == FIXED_NAME, "Wrong name used" assert pl.songs == self.SONGS
def setUp(self): self.pl_lib = PlaylistLibrary(SongFileLibrary())
def playlists(self): return PlaylistLibrary(self)
def setUp(self): self.sfLib = SongFileLibrary() self.plLib = PlaylistLibrary(self.sfLib)
class TPlaylistUtil(TestCase): PLAYLIST_FILE_PATH = get_data_path('test.m3u8') sfLib: SongFileLibrary = None plLib: PlaylistLibrary = None def setUp(self): self.sfLib = SongFileLibrary() self.plLib = PlaylistLibrary(self.sfLib) def tearDown(self): self.plLib.destroy() self.sfLib.destroy() def test_dir_for(self): # uri format of files added via drag and drop or add button # (Gtk.SelectionData.get_uris()): file:///path/to/file.ext url_based_file: addinfourl = urlopen("file:///" + self.PLAYLIST_FILE_PATH) reader_based_file: BufferedReader = open(self.PLAYLIST_FILE_PATH, "rb") try: dir_of_url_based_file: str = _dir_for(url_based_file) self.assertEqual( os.path.realpath(os.path.dirname(self.PLAYLIST_FILE_PATH)), os.path.realpath(dir_of_url_based_file), "determining the directory of url based files" " should result in a correct path") dir_of_reader_based_file: str = _dir_for(reader_based_file) self.assertEqual( os.path.realpath(os.path.dirname(self.PLAYLIST_FILE_PATH)), os.path.realpath(dir_of_reader_based_file, ), "determining the directory of reader based files" " should result in a correct path") finally: url_based_file.close() reader_based_file.close() def test_parse_m3u8(self): fileName = os.path.basename(self.PLAYLIST_FILE_PATH) playlist: Playlist = None with open(self.PLAYLIST_FILE_PATH, "rb") as file: try: playlist = parse_m3u(file, fileName, self.sfLib, self.plLib) except: assert False, ("parsing m3u8 playlists in correct format" " should not cause errors") self.assertIsNotNone(playlist, ("parsing an m3u8 playlist in the correct format" " should result in a playlist")) # the test.m3u8 contains: # - 3 existing and supported audio files from the tests/data folder: # lame.mp3, test.wav, sine-110hz.flac # - 1 non existing file: non_existing_audio_file.mp3 # - 1 not supported file: test.jpg # parsing the file correctly should result in a playlist with 3 entries self.assertEqual( 3, len(playlist), "only existing files should be added to the playlist")
def playlists(self): pl_lib = PlaylistLibrary(self) print_d(f"Created playlist library {pl_lib}") return pl_lib