lib: Give Tags a get_header() function

The sidebar will want this for giving header widgets to some rows

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2021-07-02 08:50:03 -04:00
parent 7190feddb2
commit 322dc04dd5
2 changed files with 8 additions and 0 deletions

View File

@ -46,6 +46,9 @@ class Tag:
self.tracks.append(track)
self.TrackAdded.publish(self, track)
def get_header(self):
return self.sort[0].upper() if len(self.sort) > 0 else ""
def init_track(self, track):
with self.lock:
try:

View File

@ -48,6 +48,11 @@ class TestTag(unittest.TestCase):
self.assertTrue(b < a2)
self.assertTrue(a2 < c)
def test_tag_header(self):
self.assertEqual(tag.Tag("Test").get_header(), "T")
self.assertEqual(tag.Tag("Test", "sort").get_header(), "S")
self.assertEqual(tag.Tag("").get_header(), "")
def test_tag_state(self):
t = tag.Tag("test")
tracks = [ FakeTrack(i) for i in range(5) ]