def test_CheckSizeLinkAfterAddingLinkNodeRepeating(self): expectedSize = 1 node0 = Node({0, 1, 2}) addingNode = Node({3, 4}) node0.addLinkNode(addingNode) node0.addLinkNode(addingNode) self.assertEqual(expectedSize, node0.linkSize)
def test_Closure(self): m = Matrix(4, 4) m.addString([1, 1, 1, 1]) m.addString([0, 0, 1, 1]) m.addString([1, 1, 0, 1]) m.addString([1, 0, 1, 1]) graph = Hasse(m) node = Node({0, 3}) expectedNode = Node({0, 2, 3}) newNode = graph.closure(node, 2) self.assertSetEqual(expectedNode.getElements(), newNode.getElements())
def test_ConstructorNameNotSet(self): checkElements = {0, 1, 2} strName = '{0, 1, 2}' node0 = Node({0, 0, 0, 1, 1, 2, 2}) self.assertEqual(checkElements, node0.elements) self.assertEqual(strName, node0.name) self.assertEqual(3, node0.size) self.assertEqual(set(), node0.link) self.assertEqual(0, node0.linkSize)
def test_Constructor(self): elements = {0, 1, 2} strName = '{0, 1, 2}' node0 = Node(elements) self.assertEqual(elements, node0.elements) self.assertEqual(strName, node0.name) self.assertEqual(3, node0.size) self.assertEqual(set(), node0.link) self.assertEqual(0, node0.linkSize)
def test_ComputingNextLevelNodes(self): m = Matrix(4, 4) m.addString([1, 1, 0, 1]) m.addString([0, 1, 1, 1]) m.addString([1, 1, 1, 0]) m.addString([1, 0, 1, 1]) # tetrahedra graph = Hasse(m) workNode = Node({0}) newSet = graph.computingNextLevelNodes(workNode) self.assertEqual(3, len(newSet))
def test_ConstructorWithDoublingInSet(self): elements = {0, 0, 0, 1, 1, 2, 2} checkElements = {0, 1, 2} strName = '{0, 1, 2}' node0 = Node(elements) self.assertEqual(checkElements, node0.elements) self.assertEqual(strName, node0.name) self.assertEqual(3, node0.size) self.assertEqual(set(), node0.link) self.assertEqual(0, node0.linkSize)
def test_GetLink(self): node0 = Node({0, 1, 2}) addingNode1 = Node({3, 4}) addingNode2 = Node({5, 6}) newSet = set() node0.addLinkNode(addingNode1) node0.addLinkNode(addingNode2) newSet.add(addingNode1) newSet.add(addingNode2) self.assertSetEqual(newSet, node0.getLink())
def test_CheckSizeLinkAfterAddingLinkNode(self): expectedSize = 2 node0 = Node({0, 1, 2}) addingNode1 = Node({3, 4}) addingNode2 = Node({5, 6}) node0.addLinkNode(addingNode1) node0.addLinkNode(addingNode2) self.assertEqual(expectedSize, node0.linkSize)
def test_CheckAddingLinkNodeWithError(self): node0 = Node({0, 1, 2}) node0.addLinkNode("NotNode") self.assertRaises(TypeError, node0.link)
def test_CheckAddingLinkNode(self): node0 = Node({0, 1, 2}) addingNode = Node({3, 4}) node0.addLinkNode(addingNode) self.assertEqual({Node({3, 4})}, node0.link)
def test_GetSize(self): node0 = Node({0, 1, 2}) self.assertEqual(3, node0.getSize())
def test_GetElements(self): elements = {0, 1, 2} node0 = Node({0, 1, 2}) self.assertEqual(elements, node0.getElements())
def test_GetName(self): strName = '{0, 1, 2}' node0 = Node({0, 1, 2}) self.assertEqual(strName, node0.getName())
def test_EqualityNotNode(self): node0 = Node({0, 1, 2}) node1 = str('{0, 1, 2}') self.assertEqual(False, node0 == node1)
def test_FalseEquality(self): node0 = Node({0, 1, 2}) node1 = Node({0, 0, 0, 1, 1, 3, 3}) self.assertEqual(False, node0 == node1)
def test_Equality(self): node0 = Node({0, 1, 2}) node1 = Node({0, 0, 0, 1, 1, 2, 2}) self.assertEqual(True, node0 == node1)