예제 #1
0
    def test_node_remove_child(self):
        par = Parameter(3, name='par')
        child_1 = Parameter(1, name='child_1')
        child_2 = Parameter(2, name='child_2')

        par.set_children([child_1, child_2])
        par.remove_child(child_1)

        self.assertEqual(par.get_children(), [child_2])
예제 #2
0
    def test_node_remove_child(self):
        par = Parameter(3, name='par')
        child_1 = Parameter(1, name='child_1')
        child_2 = Parameter(2, name='child_2')

        par.set_children([child_1, child_2])
        par.remove_child(child_1)

        self.assertEqual(par.get_children(), [child_2])

        with self.assertRaises(TypeError):
            par.remove_child("notanode")
예제 #3
0
    def test_node_remove_parent(self):
        par = Parameter(3, name='par')
        parent_1 = Parameter(1, name='parent_1')
        parent_2 = Parameter(2, name='parent_2')

        parent_1.add_child(par)
        parent_2.add_child(par)
        with self.assertRaises(NodeException):
            par.remove_parent(parent_1)
        self.assertEqual(par.get_parents(), [parent_1, parent_2])
        parent_1.remove_child(par)
        self.assertEqual(par.get_parents(), [parent_2])

        with self.assertRaises(TypeError):
            par.remove_parent("notanode")