def test_Merge_Nodes(self): #Leave node leftNode = node.node() leftNode.populateNode(1,[],"") leftNode.initData([1,2,3]) #Not Leave Node rightNode = node.node() rightNode.populateNode(1,[2,3],"") rightNode.initData([2,3]) #Merging mergeNode = node.node() mergeNode.populateNode(3,[leftNode,rightNode],"") mergeNode.merge() #Test data = np.array([a==b for a,b in zip(mergeNode.data,[1,2,3])]).all() self.assertEquals(data,True,msg="Data from children incorrectly merge.") self.assertEquals(mergeNode.id,3,msg="Id assingment wrong") children = np.array([a==b for a,b in zip(mergeNode.children,[leftNode,rightNode])]).all() self.assertEquals(children,True,msg="Children list not properly built")
def test_Nodes_Botton_Node(self): #Creating a botton node. bottonLeave = node.node() bottonLeave.populateNode(1,[],"") bottonLeave.initData([1]) #Data Stored correctly data =np.array([a==b for a,b in zip(bottonLeave.data,[1])]).all() self.assertEquals(data,True,msg="Data inputed correctly") self.assertEquals(bottonLeave.id,1,msg="Id Assign Correctly") self.assertEquals(len(bottonLeave.children),0,msg="It has no children")