curds: Add a node.has_sibling() function
The UI can use this to determine if this is the first node added to the parent. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
4fc44832ec
commit
c29313dde8
|
@ -51,6 +51,9 @@ class PlaylistNode:
|
|||
return [ ]
|
||||
return self.parent.get_path() + [ self.node_index() ]
|
||||
|
||||
def has_sibling(self):
|
||||
return (self.next_child != None) or (self.prev_child != None)
|
||||
|
||||
def lookup(self, name):
|
||||
name = self.__normalize__(name)
|
||||
for node in self.children:
|
||||
|
|
|
@ -159,6 +159,18 @@ class TestPlaylistNode(unittest.TestCase):
|
|||
self.assertEqual(a.parent, root)
|
||||
self.assertIsNone(root.parent)
|
||||
|
||||
def test_node_has_sibling(self):
|
||||
root = node.PlaylistNode()
|
||||
a = node.PlaylistNode("a")
|
||||
b = node.PlaylistNode("b")
|
||||
|
||||
root.append_child(a)
|
||||
root.append_child(b)
|
||||
|
||||
self.assertFalse(root.has_sibling())
|
||||
self.assertTrue( a.has_sibling())
|
||||
self.assertTrue( b.has_sibling())
|
||||
|
||||
def test_node_get_path(self):
|
||||
root = node.PlaylistNode()
|
||||
a = node.PlaylistNode("a")
|
||||
|
|
Loading…
Reference in New Issue