Back to index

python-biopython  1.60
Public Member Functions
test_Pathway.GraphTestCase Class Reference

List of all members.

Public Member Functions

def testEquals
def testNodes
def testEdges
def testRemoveNode

Detailed Description

Definition at line 16 of file test_Pathway.py.


Member Function Documentation

Definition at line 50 of file test_Pathway.py.

00050 
00051     def testEdges(self):
00052         a = Graph(['a','b','c','d'])
00053         a.add_edge('a','b','label1')
00054         self.assertEqual(a.child_edges('a'), [('b','label1')]) #, "incorrect child edges")
00055         a.add_edge('b','a','label2')
00056         self.assertEqual(a.parent_edges('a'), [('b','label2')]) #, "incorrect parent edges")
00057         a.add_edge('b','c','label3')
00058         self.assertEqual(a.parent_edges('c'), [('b','label3')]) #, "incorrect parent edges")
00059         l = a.children('b')
00060         l.sort()
00061         self.assertEqual(l, ['a', 'c'], "incorrect children")
00062         self.assertEqual(a.children('d'), [], "incorrect children for singleton")
00063         self.assertEqual(a.parents('a'), ['b'], "incorrect parents")

Definition at line 18 of file test_Pathway.py.

00018 
00019     def testEquals(self):
00020         a = Graph(['a','b','c'])
00021         a.add_edge('a','b','label1')
00022         a.add_edge('b','c','label1')
00023         a.add_edge('b','a','label2')
00024         b = Graph(['a','b','c'])
00025         self.assertNotEqual(a, b, "equal to similar nodes, no edges")
00026         b.add_edge('a','b','label1')
00027         self.assertNotEqual(a, b, "equal to similar nodes, edge subset")
00028         b.add_edge('b','c','label1')
00029         b.add_edge('b','a','label2')
00030         self.assertEqual(a, b, "not equal to similar")
00031         c = Graph(['a','b','c'])
00032         c.add_edge('a','b','label2')
00033         c.add_edge('b','c','label2')
00034         c.add_edge('b','a','label1')
00035         self.assertNotEqual(a, c, "equal to similar with different labels")
00036         self.assertNotEqual(c, Graph(), "equal to empty graph")
00037         self.assertEqual(Graph(), Graph(), "empty graph not equal to self")

Definition at line 38 of file test_Pathway.py.

00038 
00039     def testNodes(self):
00040         a = Graph()
00041         self.assertEqual(a.nodes(), [], "default graph not empty")
00042         a.add_node('a')
00043         self.assertEqual(a.nodes(), ['a'], "one node not added")
00044         a.add_node('a')
00045         self.assertEqual(a.nodes(), ['a'], "duplicate node added")
00046         a.add_node('b')
00047         l = a.nodes()
00048         l.sort()
00049         self.assertEqual(l, ['a', 'b'], "second node not added")

Definition at line 64 of file test_Pathway.py.

00064 
00065     def testRemoveNode(self):
00066         a = Graph(['a','b','c','d','e'])
00067         a.add_edge('a','e','label1')
00068         a.add_edge('b','e','label1')
00069         a.add_edge('c','e','label2')
00070         a.add_edge('d','e','label3')
00071         a.add_edge('e','d','label4')
00072         a.add_edge('a','b','label5')
00073         a.remove_node('e')
00074         b = Graph(['a','b','c','d'])
00075         b.add_edge('a','b','label5')
00076         self.assertEqual(a, b)#, "incorrect node removal")
00077 


The documentation for this class was generated from the following file: