Beispiel #1
0
 def test_matching_pats(self) : 
     tree = fromstring("<Team><ACRush></ACRush><Jelly></Jelly><Cooly></Cooly></Team>")
     query = fromstring("<Team><Cooly></Cooly></Team>")
     root_query = fromstring("<Team><Cooly></Cooly></Team>")
     all_tree = []
     count_tree(tree, all_tree)
     count_query(root_query)
     traverse_tree(tree, query, root_query)
     final = matching_pats(XML.count_pat, all_tree)
     self.assertTrue (type(final) == list)
     self.assertTrue (type(XML.count_pat) == list)
     self.assertTrue (type(i) == Element for i in XML.count_pat)
     self.assertTrue (type(all_tree) == list)
     self.assertTrue (type(i) == Element for i in all_tree)  
Beispiel #2
0
 def test_matching_pats3(self) : # testing case where there is new lines
     tree = fromstring("<red>\n<green>\n</green>\n</red>\n")
     query = fromstring("<yellow>\n</yellow>\n\n")
     root_query = fromstring("<yellow>\n</yellow>\n\n")
     all_tree = []
     count_tree(tree, all_tree)
     count_query(root_query)
     traverse_tree(tree, query, root_query)
     final = matching_pats(XML.count_pat, all_tree)
     self.assertTrue (type(final) == list)
     self.assertTrue (len(final) == 0)
     self.assertTrue (type(XML.count_pat) == list)
     self.assertTrue (type(i) == Element for i in XML.count_pat)
     self.assertTrue (type(all_tree) == list)
     self.assertTrue (type(i) == Element for i in all_tree)                
Beispiel #3
0
 def test_count_query1 (self) :
     input1 = "<Team><ACRush></ACRush><Jelly></Jelly><Cooly></Cooly></Team>"
     tree = fromstring(input1) 
     XML.query_lst = []
     lengthQuery = count_query(tree)  
     self.assertTrue (lengthQuery == 4)
     self.assertTrue(lengthQuery == 4)    
Beispiel #4
0
 def test_count_query3 (self):
     input1 = "<Team></Team>"
     tree = fromstring(input1)
     XML.query_lst = []
     lengthQuery = count_query(tree)
     self.assertTrue(lengthQuery == 1)
Beispiel #5
0
 def test_count_query2 (self):
     input1 = "<THU><Team><ACRush></ACRush><Jelly></Jelly><Cooly></Cooly></Team><JiaJia><Team><Ahyangyi></Ahyangyi><Dragon></Dragon><Cooly><Amber></Amber></Cooly></Team></JiaJia></THU>"
     tree = fromstring(input1)
     XML.query_lst = []
     lengthQuery = count_query(tree)
     self.assertTrue (lengthQuery == 11)