curds: Add a less than operator for playlists

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2019-03-17 10:57:35 -04:00
parent e6cc3716eb
commit 0873f0458c
2 changed files with 10 additions and 0 deletions

View File

@ -22,6 +22,9 @@ class Playlist():
def __len__(self):
return len(self.list)
def __lt__(self, other):
return self.name < other.name
def __str__(self):
l = len(self.list)
return f"{self.name}\n{l} Track{'s' if l != 1 else ''}"

View File

@ -204,3 +204,10 @@ class TestPlaylist(unittest.TestCase):
for i in range(len(plist)):
self.assertEqual(plist[i], tracks[i])
def test_playlist_less_than(self):
a = playlist.Playlist("A")
b = playlist.Playlist("B")
self.assertTrue( a < b)
self.assertFalse(b < a)
self.assertFalse(a < a)