예제 #1
0
 def test_search_finds_only_nodes_with_exact_match_if_exact_param_set_to_true(self):
     root = Tree('root')
     a1 = Tree('abc')
     root.add_child(a1)
     b = Tree('b')
     a1.add_child(b)
     a2 = Tree('xyzabc')
     b.add_child(a2)
     results = root.search('abc', exact=True)
     self.assertEqual(results, [a1])
예제 #2
0
 def test_search_finds_all_nodes_whose_value_contains_seach_string(self):
     root = Tree('root')
     a1 = Tree('abc')
     root.add_child(a1)
     b = Tree('b')
     a1.add_child(b)
     a2 = Tree('xyzabc')
     b.add_child(a2)
     results = root.search('abc')
     self.assertEqual(results, [a1, a2])
예제 #3
0
 def test_search_returns_multiple_nodes_even_if_at_different_parts_of_the_tree(self):
     root = Tree('root')
     a1 = Tree('a')
     root.add_child(a1)
     b = Tree('b')
     a1.add_child(b)
     a2 = Tree('a')
     b.add_child(a2)
     results = root.search('a')
     self.assertEqual(results, [a1, a2])
예제 #4
0
 def test_search_returns_empty_list_if_no_finds(self):
     root = Tree('root')
     a = Tree('a')
     root.add_child(a)
     results = root.search('nope')
     self.assertEqual(results, [])
예제 #5
0
 def test_search(self):
     root = Tree('root')
     a = Tree('a')
     root.add_child(a)
     results = root.search('a')
     self.assertEqual(results, [a])