2021-10-07 20:48:26 -04:00
|
|
|
# Copyright 2021 (c) Anna Schumaker.
|
|
|
|
import db
|
|
|
|
import unittest
|
|
|
|
from gi.repository import GObject
|
|
|
|
from . import playlist
|
|
|
|
|
2021-10-14 13:34:33 -04:00
|
|
|
class TestRow:
|
|
|
|
def __init__(self): pass
|
|
|
|
def keys(self): return [ "testid", "plstateid" ]
|
|
|
|
def __getitem__(self, key):
|
|
|
|
if key == "testid" or key == 0: return 1
|
|
|
|
return 10
|
|
|
|
|
2021-10-07 20:48:26 -04:00
|
|
|
class TestPlaylist(unittest.TestCase):
|
|
|
|
def test_init(self):
|
|
|
|
db.reset()
|
2021-10-14 13:34:33 -04:00
|
|
|
plist = playlist.Playlist(TestRow(), "missing-icon")
|
2021-10-07 20:48:26 -04:00
|
|
|
|
|
|
|
self.assertIsInstance(plist, GObject.GObject)
|
|
|
|
self.assertFalse(plist.has_children())
|
|
|
|
|
|
|
|
self.assertEqual(plist._rowid, 1)
|
2021-10-14 13:34:33 -04:00
|
|
|
self.assertEqual(plist._rowkey, "testid")
|
2021-10-13 17:04:26 -04:00
|
|
|
self.assertEqual(plist._icon_name, "missing-icon")
|
2021-10-14 13:34:33 -04:00
|
|
|
|
|
|
|
self.assertEqual(plist.get_property("rowid"), 1)
|
|
|
|
self.assertEqual(plist.get_property("rowkey"), "testid")
|
2021-10-13 17:04:26 -04:00
|
|
|
self.assertEqual(plist.get_property("icon-name"), "missing-icon")
|
|
|
|
|
2021-10-07 20:48:26 -04:00
|
|
|
self.assertIsNone(plist._plstate)
|
|
|
|
self.assertIsNone(plist.get_property("plist_state"))
|
|
|
|
|
|
|
|
with self.assertRaises(NotImplementedError):
|
|
|
|
plist.get_property("name")
|
2021-10-16 17:37:23 -04:00
|
|
|
with self.assertRaises(NotImplementedError):
|
|
|
|
plist.delete()
|
2021-10-07 20:48:26 -04:00
|
|
|
|
|
|
|
|
|
|
|
class TestParentPlaylist(unittest.TestCase):
|
|
|
|
def test_init(self):
|
2021-10-14 13:34:33 -04:00
|
|
|
parent = playlist.ParentPlaylist(TestRow(), "missing-icon")
|
2021-10-07 20:48:26 -04:00
|
|
|
|
|
|
|
self.assertIsInstance(parent, playlist.Playlist)
|
|
|
|
self.assertTrue(parent.has_children())
|
|
|
|
|
|
|
|
with self.assertRaises(NotImplementedError):
|
|
|
|
parent.get_child_table()
|
|
|
|
with self.assertRaises(NotImplementedError):
|
|
|
|
parent.get_n_children()
|
|
|
|
with self.assertRaises(NotImplementedError):
|
|
|
|
parent.get_child(0)
|
|
|
|
with self.assertRaises(NotImplementedError):
|
|
|
|
parent.get_child_index(0)
|