Skip to content

Commit c4732a6

Browse files
author
Diego C Bolsoni
committed
add Connection class to tests
1 parent 1b0c1e4 commit c4732a6

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

Diff for: ShortestPath_test.py

+19-19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from unittest import TestCase, main
2-
from ShortestPath import ShortestPath
2+
from ShortestPath import ShortestPath, Connection
33

44
from main import NODES, CONNECTIONS
55

@@ -11,14 +11,14 @@ def setUp(self):
1111

1212
def test_available_connections_in_a_node(self):
1313
node = 'a'
14-
expected = [{'dist': 0, 'nodes': ['a', 'a']},
15-
{'dist': 2, 'nodes': ['a', 'b']},
16-
{'dist': 8, 'nodes': ['a', 'd']}]
14+
expected = [Connection(['a', 'a'], 0),
15+
Connection(['a', 'b'], 2),
16+
Connection(['a', 'd'], 8)]
1717
self.assertEqual(expected, self.sp.available_connections(node))
1818
node = 'b'
19-
expected = [{'dist': 2, 'nodes': ['a', 'b']},
20-
{'dist': 5, 'nodes': ['b', 'd']},
21-
{'dist': 6, 'nodes': ['b', 'e']}]
19+
expected = [Connection(['a', 'b'], 2),
20+
Connection(['b', 'd'], 5),
21+
Connection(['b', 'e'], 6)]
2222
self.assertEqual(expected, self.sp.available_connections(node))
2323

2424
def test_distance_from_x_to_y(self):
@@ -32,22 +32,22 @@ def test_distance_from_x_to_y_that_dont_connects(self):
3232
self.assertEqual(self.sp.distance('a', 'c'), None)
3333

3434
def test_a_way_to_a_node(self):
35-
expected = [[{'dist': 2, 'nodes': ['a', 'b']},
36-
{'dist': 6, 'nodes': ['b', 'e']}],
37-
[{'dist': 8, 'nodes': ['a', 'd']},
38-
{'dist': 3, 'nodes': ['d', 'e']}]]
35+
expected = [[Connection(['a', 'b'], 2),
36+
Connection(['b', 'e'], 6)],
37+
[Connection(['a', 'd'], 8),
38+
Connection(['d', 'e'], 3)]]
3939
self.assertEqual(expected, self.sp.ways('a', 'e'))
40-
expected = [[{'dist': 6, 'nodes': ['b', 'e']},
41-
{'dist': 9, 'nodes': ['c', 'e']}]]
40+
expected = [[Connection(['b', 'e'], 6),
41+
Connection(['c', 'e'], 9)]]
4242
self.assertEqual(expected, self.sp.ways('b', 'c'))
4343

4444
def test_a_shortest_distance_in_ways(self):
45-
ways = [[{'dist': 2, 'nodes': ['a', 'b']},
46-
{'dist': 6, 'nodes': ['b', 'e']}],
47-
[{'dist': 8, 'nodes': ['a', 'd']},
48-
{'dist': 3, 'nodes': ['d', 'e']}]]
49-
expected = [{'dist': 2, 'nodes': ['a', 'b']},
50-
{'dist': 6, 'nodes': ['b', 'e']}]
45+
ways = [[Connection(['a', 'b'], 2),
46+
Connection(['b', 'e'], 6)],
47+
[Connection(['a', 'd'], 8),
48+
Connection(['d', 'e'], 3)]]
49+
expected = [Connection(['a', 'b'], 2),
50+
Connection(['b', 'e'], 6)]
5151
self.assertEqual(expected, self.sp.shortest_way(ways))
5252

5353

0 commit comments

Comments
 (0)