def test_displacement(self): n = Node(10, 10) self.assertEqual(n.displacement(), 0) n.currentPos = 20 self.assertEqual(n.displacement(), -10) n.currentPos = 0 self.assertEqual(n.displacement(), 10)
def test_displacement(self): n = Node(10, 10) self.assertEqual(n.displacement(), 0) n.currentPos = 20 self.assertEqual(n.displacement(), -10) n.currentPos = 0 self.assertEqual(n.displacement(), 10)
def test_clone(self): n1 = Node(10, 11, "a") n1.currentPos = 20 n1.layerIndex = 3 n2 = n1.clone() self.assertEqual(n2.idealPos, 10) self.assertEqual(n2.width, 11) self.assertEqual(n2.data, "a") self.assertEqual(n2.currentPos, 20) self.assertEqual(n2.layerIndex, 3)
def test_clone(self): n1 = Node(10, 11, 'a') n1.currentPos = 20 n1.layerIndex = 3 n2 = n1.clone() self.assertEqual(n2.idealPos, 10) self.assertEqual(n2.width, 11) self.assertEqual(n2.data, 'a') self.assertEqual(n2.currentPos, 20) self.assertEqual(n2.layerIndex, 3)
def test_pathLength(self): n1 = Node(1, 50) n1.currentPos = 20 n2 = Node(2, 50) n3 = Node(804, 50) stub = n3.createStub() n3.currentPos = 810 n4 = Node(854, 50) n4.currentPos = 800 stub4 = n4.createStub() stub4.currentPos = 700 stub4_2 = stub4.createStub() # should return 0 if the input is empty self.assertEqual(metrics.pathLength([]), 0) # should return sum of the displacements from leaves to stubs up to # root self.assertEqual(metrics.pathLength([n1]), 19) self.assertEqual(metrics.pathLength([n2]), 0) self.assertEqual(metrics.pathLength([n3]), 6) self.assertEqual(metrics.pathLength([n4, stub4, stub4_2]), 254) self.assertEqual( metrics.pathLength([[n1, n2, n3, stub4_2], [stub4], [n4]]), 279 / 4)
def test_currentLeft(self): n1 = Node(10, 10) n1.currentPos = 20 self.assertEqual(n1.currentLeft(), 15)
def test_currentRight(self): n1 = Node(10, 10) n1.currentPos = 20 self.assertEqual(n1.currentRight(), 25)
def test_moveToIdealPosition(self): n = Node(10, 10) n.currentPos = 20 self.assertNotEqual(n.currentPos, n.idealPos) n.moveToIdealPosition() self.assertEqual(n.currentPos, n.idealPos)
def test_getPathToRootLength(self): n4 = Node(854, 50) n4.currentPos = 800 stub4 = n4.createStub() stub4.currentPos = 700 self.assertEqual(n4.getPathToRootLength(), 254)
def test_currentLeft(self): n1 = Node(10, 10) n1.currentPos = 20 self.assertEqual(n1.currentLeft(), 15)
def test_currentRight(self): n1 = Node(10, 10) n1.currentPos = 20 self.assertEqual(n1.currentRight(), 25)
def test_moveToIdealPosition(self): n = Node(10, 10) n.currentPos = 20 self.assertNotEqual(n.currentPos, n.idealPos) n.moveToIdealPosition() self.assertEqual(n.currentPos, n.idealPos)
def test_getPathToRootLength(self): n4 = Node(854, 50) n4.currentPos = 800 stub4 = n4.createStub() stub4.currentPos = 700 self.assertEqual(n4.getPathToRootLength(), 254)