curds: Remove append_child() from the PlaylistNode

And work it into the PlaylistRoot's __init__() function

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2019-12-16 13:25:34 -05:00
parent 8f9657ce8b
commit 88b45a3fee
3 changed files with 9 additions and 33 deletions

View File

@ -8,7 +8,3 @@ import unicodedata
class PlaylistNode(tree.ETree):
def __init__(self, name="", icon=""):
tree.ETree.__init__(self, name, icon)
def append_child(self, child):
with self.tree_lock:
return self.__insert__(len(self.children), child)

View File

@ -15,14 +15,15 @@ class PlaylistRoot(node.PlaylistNode):
def __init__(self):
node.PlaylistNode.__init__(self, "root")
self.append_child(collection.CollectionPlaylist())
self.append_child(up_next.UpNextPlaylist())
self.append_child(prev.PreviousPlaylist())
self.append_child(user.UserNode())
self.append_child(artist.ArtistNode())
self.append_child(genre.GenreNode())
self.append_child(decade.DecadeNode())
self.append_child(library.LibraryNode())
with self.tree_lock:
self.__insert__(0, collection.CollectionPlaylist())
self.__insert__(1, up_next.UpNextPlaylist())
self.__insert__(2, prev.PreviousPlaylist())
self.__insert__(3, user.UserNode())
self.__insert__(4, artist.ArtistNode())
self.__insert__(5, genre.GenreNode())
self.__insert__(6, decade.DecadeNode())
self.__insert__(7, library.LibraryNode())
def lookup(self, name):
with self.tree_lock:

View File

@ -15,24 +15,3 @@ class TestPlaylistNode(unittest.TestCase):
n = node.PlaylistNode("Test Node", "test-icon")
self.assertEqual(n.icon, "test-icon")
self.assertEqual(n.name, "Test Node")
def test_node_append_child(self):
root = node.PlaylistNode()
a = node.PlaylistNode("a")
b = node.PlaylistNode("b")
c = node.PlaylistNode("c")
self.assertEqual(root.n_children(), 0)
self.assertEqual(root.append_child(b), b)
self.assertEqual(root.n_children(), 1)
self.assertEqual(root.children, [ b ])
self.assertEqual(root.append_child(a), a)
self.assertEqual(root.n_children(), 2)
self.assertEqual(root.children, [ b, a ])
self.assertEqual(b.sibling, a)
self.assertEqual(root.append_child(c), c)
self.assertEqual(root.n_children(), 3)
self.assertEqual(root.children, [ b, a, c ])
self.assertEqual(a.sibling, c)