示例#1
0
 def test_subbranch(self):
     tree3 = CommandBranch("Again")
     tree2 = CommandBranch("World")
     tree2.add_child(tree3)
     tree1 = CommandBranch("Hello")
     tree1.add_child(tree2)
     tree = CommandHead()
     tree.add_child(tree1)
     self.assertEqual(tree.get_subbranch("Hello"), ["World", "Again"])
示例#2
0
 def test_subbranch(self):
     tree3 = CommandBranch("Again")
     tree2 = CommandBranch("World")
     tree2.add_child(tree3)
     tree1 = CommandBranch("Hello")
     tree1.add_child(tree2)
     tree = CommandHead()
     tree.add_child(tree1)
     self.assertEqual(tree.get_subbranch("Hello"), ["World", "Again"])
示例#3
0
    def test_in_tree(self):
        # tests in tree
        tree4 = CommandBranch("CB1")
        tree3 = CommandBranch("Again")
        tree2 = CommandBranch("World")
        tree2.add_child(tree3)
        tree2.add_child(tree4)
        tree1 = CommandBranch("Hello")
        tree1.add_child(tree2)
        tree = CommandHead()
        tree.add_child(tree1)
        self.assertTrue(in_tree(tree3, 'Again'))
        self.assertTrue(in_tree(tree2, 'World Again'))
        self.assertTrue(in_tree(tree1, 'Hello World Again'))
        self.assertTrue(in_tree(tree1, 'Hello World CB1'))

        self.assertFalse(in_tree(tree1, 'World Hello CB1'))
        self.assertFalse(in_tree(tree, 'World Hello CB1'))
        self.assertFalse(in_tree(tree, 'Hello World Again CB1'))
示例#4
0
    def test_in_tree(self):
        """ tests in tree """
        tree4 = CommandBranch("CB1")
        tree3 = CommandBranch("Again")
        tree2 = CommandBranch("World")
        tree2.add_child(tree3)
        tree2.add_child(tree4)
        tree1 = CommandBranch("Hello")
        tree1.add_child(tree2)
        tree = CommandHead()
        tree.add_child(tree1)
        self.assertTrue(in_tree(tree3, 'Again'))
        self.assertTrue(in_tree(tree2, 'World Again'))
        self.assertTrue(in_tree(tree1, 'Hello World Again'))
        self.assertTrue(in_tree(tree1, 'Hello World CB1'))

        self.assertFalse(in_tree(tree1, 'World Hello CB1'))
        self.assertFalse(in_tree(tree, 'World Hello CB1'))
        self.assertFalse(in_tree(tree, 'Hello World Again CB1'))