trackdb: Give TrackAllocators a function to list tracks in a library
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
b3b39d2fc4
commit
c5e317b737
|
@ -40,6 +40,12 @@ class TrackAllocator:
|
|||
except Exception as e:
|
||||
pass
|
||||
|
||||
def list_tracks(self, lib):
|
||||
with self.lock:
|
||||
for (id, track) in self.tracks.items():
|
||||
if track.library ==lib:
|
||||
yield track
|
||||
|
||||
def remove(self, track):
|
||||
with self.lock:
|
||||
del self.tracks[track.trackid]
|
||||
|
|
|
@ -46,6 +46,9 @@ class TestTrackAllocator(unittest.TestCase):
|
|||
|
||||
self.assertIsNone(alloc.allocate(lib, test_tracks / "No Such File"))
|
||||
self.assertEqual(self.added, track2)
|
||||
self.assertEqual([ t for t in alloc.list_tracks(lib) ], [ track, track2 ])
|
||||
track.library = None
|
||||
self.assertEqual([ t for t in alloc.list_tracks(lib) ], [ track2 ])
|
||||
|
||||
alloc.remove(track)
|
||||
self.assertEqual(alloc[0], None)
|
||||
|
|
Loading…
Reference in New Issue