curds: Add helpful library functions
This adds some convenience around controlling the library thread. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
f715945536
commit
5c267c8a9d
|
@ -22,3 +22,15 @@ class LibraryPlaylist(playlist.Playlist):
|
|||
for dirname, subdirs, files in os.walk(self.name):
|
||||
for f in files:
|
||||
library_thread.push(self.thread_add, os.path.join(dirname, f))
|
||||
|
||||
|
||||
def join():
|
||||
library_thread.join()
|
||||
|
||||
def reset():
|
||||
global library_thread
|
||||
if not library_thread.is_alive():
|
||||
library_thread = threadqueue.ThreadQueue()
|
||||
|
||||
def stop():
|
||||
library_thread.stop()
|
||||
|
|
|
@ -15,12 +15,11 @@ class TestLibraryPlaylist(unittest.TestCase):
|
|||
notify.Notify.clear()
|
||||
|
||||
def setUp(self):
|
||||
library.library_thread.stop()
|
||||
library.library_thread = threadqueue.ThreadQueue()
|
||||
library.reset()
|
||||
tags.clear()
|
||||
|
||||
def tearDownClass():
|
||||
library.library_thread.stop()
|
||||
library.stop()
|
||||
|
||||
def test_playlist_library_init(self):
|
||||
self.assertIsInstance(library.library_thread, threadqueue.ThreadQueue)
|
||||
|
@ -33,10 +32,10 @@ class TestLibraryPlaylist(unittest.TestCase):
|
|||
def test_playlist_library_scan(self):
|
||||
plist = library.LibraryPlaylist(test_library)
|
||||
self.assertGreater(library.library_thread.qsize(), 0)
|
||||
library.library_thread.join()
|
||||
library.join()
|
||||
self.assertEqual(len(plist), 1250)
|
||||
self.assertEqual(plist.runtime(), "1 hour, 54 minutes, 35 seconds")
|
||||
|
||||
plist.scan()
|
||||
library.library_thread.join()
|
||||
library.join()
|
||||
self.assertEqual(len(plist), 1250)
|
||||
|
|
|
@ -17,12 +17,11 @@ class TestPlaylistManager(unittest.TestCase):
|
|||
def setUp(self):
|
||||
notify.Notify.clear()
|
||||
tags.clear()
|
||||
if not library.library_thread.is_alive():
|
||||
library.library_thread = threadqueue.ThreadQueue()
|
||||
library.reset()
|
||||
self.cb_plist = None
|
||||
|
||||
def tearDown(self):
|
||||
library.library_thread.stop()
|
||||
library.stop()
|
||||
|
||||
def test_manager_init(self):
|
||||
playman = manager.PlaylistManager()
|
||||
|
@ -74,7 +73,7 @@ class TestPlaylistManager(unittest.TestCase):
|
|||
self.assertEqual(playman["Library"][0], alist)
|
||||
self.assertEqual(playman["Library"][1], plist)
|
||||
|
||||
library.library_thread.join()
|
||||
library.join()
|
||||
self.assertEqual(len(plist), 1250)
|
||||
self.assertEqual(len(alist), 12)
|
||||
self.assertEqual(len(playman["Collection"]), len(alist) + len(plist))
|
||||
|
@ -87,7 +86,7 @@ class TestPlaylistManager(unittest.TestCase):
|
|||
clist = playman["Collection"]
|
||||
prev = playman["Previous"]
|
||||
plist = playman["Library"].add(test_library)
|
||||
library.library_thread.join()
|
||||
library.join()
|
||||
|
||||
track1 = playman.next()
|
||||
self.assertEqual(playman.track, track1)
|
||||
|
|
|
@ -21,8 +21,7 @@ class TestGst(unittest.TestCase):
|
|||
|
||||
def setUpClass():
|
||||
gst.Audio.disconnect()
|
||||
if not curds.playlist.library.library_thread.is_alive():
|
||||
curds.playlist.library.library_thread = curds.ThreadQueue()
|
||||
curds.playlist.library.reset()
|
||||
|
||||
def tearDown(self):
|
||||
self.audio.playbin.set_state(Gst.State.READY)
|
||||
|
@ -32,7 +31,7 @@ class TestGst(unittest.TestCase):
|
|||
self.audio.disconnect()
|
||||
|
||||
def tearDownClass():
|
||||
curds.playlist.library.library_thread.stop()
|
||||
curds.playlist.library.stop()
|
||||
|
||||
def main_loop(self, delay=0.0):
|
||||
time.sleep(delay)
|
||||
|
@ -118,7 +117,7 @@ class TestGst(unittest.TestCase):
|
|||
self.assertIsNone(curds.PlaylistManager.track)
|
||||
|
||||
curds.PlaylistManager["Library"].add(test_album)
|
||||
curds.playlist.library.library_thread.join()
|
||||
curds.playlist.library.join()
|
||||
|
||||
gst.NextButton.clicked()
|
||||
track1 = curds.PlaylistManager.track
|
||||
|
|
|
@ -22,11 +22,10 @@ class TestManager(unittest.TestCase):
|
|||
curds.Notify.notify_me("new-track", curds.PlaylistManager["Collection"].add)
|
||||
curds.Notify.notify_me("add-track", manager.MgrModel.on_add_track)
|
||||
curds.Notify.notify_me("new-library-playlist", manager.MgrModel.on_new_library)
|
||||
if not curds.playlist.library.library_thread.is_alive():
|
||||
curds.playlist.library.library_thread = curds.ThreadQueue()
|
||||
curds.playlist.library.reset()
|
||||
|
||||
def tearDown(self):
|
||||
curds.playlist.library.library_thread.stop()
|
||||
curds.playlist.library.stop()
|
||||
|
||||
def test_init(self):
|
||||
self.assertIsInstance(gtk.Builder.get_object("manager_treeview"), Gtk.TreeView)
|
||||
|
@ -121,7 +120,7 @@ class TestManager(unittest.TestCase):
|
|||
self.assertEqual(iter.user_data2, 0)
|
||||
self.assertEqual(iter.user_data3, 0)
|
||||
|
||||
curds.playlist.library.library_thread.join()
|
||||
curds.playlist.library.join()
|
||||
self.assertEqual(model.get_value(child, 0), "folder-music")
|
||||
self.assertEqual(model.get_value(child, 1), f"{test_album}\n10 Tracks")
|
||||
|
||||
|
@ -132,7 +131,7 @@ class TestManager(unittest.TestCase):
|
|||
path = model.get_path(iter)
|
||||
|
||||
plist = plist_mgr["Library"].add(test_album)
|
||||
curds.playlist.library.library_thread.join()
|
||||
curds.playlist.library.join()
|
||||
|
||||
self.assertIsInstance(selection, Gtk.TreeSelection)
|
||||
selection.select_path(path)
|
||||
|
|
Loading…
Reference in New Issue