-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraph_test.py
More file actions
39 lines (28 loc) · 1.06 KB
/
graph_test.py
File metadata and controls
39 lines (28 loc) · 1.06 KB
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
import unittest
import dictionary
import graph
class GraphTests(unittest.TestCase):
def setUp(self):
self.dictionary = dictionary.Dictionary()
self.dictionary.insert('marek')
self.dictionary.insert('darek')
self.dictionary.insert('cat')
self.dictionary.insert('cot')
self.dictionary.insert('cog')
self.dictionary.insert('dog')
self.graph = graph.Graph(self.dictionary)
def test_one_distance_away_path(self):
path = self.graph.bfs('marek', 'darek')
self.assertListEqual(['marek', 'darek'], path)
def test_two_distance_away_path(self):
self.dictionary.insert('darem')
path = self.graph.bfs('marek', 'darem')
exp = ['marek', 'darek', 'darem']
self.assertListEqual(exp, path)
def test_path_symmetry(self):
path = self.graph.bfs('cat', 'dog')
rpath = self.graph.bfs('dog', 'cat')
self.assertListEqual(path, rpath[::-1])
def test_empty_path(self):
path = self.graph.bfs('marek', 'dog')
self.assertIsNone(path)