-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtest_Graph.py
46 lines (34 loc) · 1.25 KB
/
test_Graph.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import unittest
from Graph import Graph, Vertex, Edge
class GraphTest(unittest.TestCase):
def setUp(self):
self.v = Vertex('v')
self.w = Vertex('w')
self.x = Vertex('x')
self.y = Vertex('y')
self.z = Vertex('z')
self.e = Edge(self.v, self.w)
self.e2 = Edge(self.v, self.x)
self.g = Graph([self.v, self.w ,self.x, self.y],[self.e, self.e2])
def test_get_edge_not_exist(self):
edge = self.g.get_edge(self.v, self.y)
self.assertIsNone(edge)
def test_get_edge_exist(self):
edge = self.g.get_edge(self.v, self.w)
self.assertEqual(edge, self.e)
def test_remove_edge_is_removed( self ):
'''
La prueba checa si el Edge esta por ahi.
Depende de la funcion de get_edge
'''
edge = self.g.remove_edge( self.e )
self.assertIsNone( self.g.get_edge( self.v, self.w ) )
def test_vertex_repr(self):
self.assertEqual( repr(self.v), "Vertex('v')" )
def test_edge_one_vertex(self):
self.assertRaises( ValueError, Edge, self.v )
def test_edge_repr(self):
self.assertEqual( repr(self.e),
"Edge(Vertex('v'), Vertex('w'))" )
if __name__ == '__main__':
unittest.main()