def test_bfs_character(self): graph_connectivity = Graph_connectivity() visited, _ = graph_connectivity.bfs(self.graph2, self.startnodes2[0]) self.assertEqual(visited[self.finalnodes2[0][0][0]], self.finalnodes2[0][0][1]) self.assertEqual(visited[self.finalnodes2[1][0][0]], self.finalnodes2[1][0][1])
def test_argparse(self): graph_connectivity = Graph_connectivity() args = graph_connectivity.prepare_args([self.filegraph1]) self.assertEqual(args.graph_file, self.filegraph1) args = graph_connectivity.prepare_args([self.filegraph2]) self.assertEqual(args.graph_file, self.filegraph2) args = graph_connectivity.prepare_args([self.filegraph3]) self.assertEqual(args.graph_file, self.filegraph3)
def test_bfs_integer(self): graph_connectivity = Graph_connectivity() visited, _ = graph_connectivity.bfs(self.graph1, self.startnodes1[0]) self.assertEqual(visited[self.finalnodes1[0][0][0]], self.finalnodes1[0][0][1]) self.assertEqual(visited[self.finalnodes1[0][1][0]], self.finalnodes1[0][1][1]) self.assertEqual(visited[self.finalnodes1[0][2][0]], self.finalnodes1[0][2][1]) self.assertEqual(visited[self.finalnodes1[0][3][0]], self.finalnodes1[0][3][1]) visited, _ = graph_connectivity.bfs(self.graph1, self.startnodes1[1]) self.assertEqual(visited[self.finalnodes1[1][0][0]], self.finalnodes1[1][0][1])
def test_load_graph_empty(self): graph_connectivity = Graph_connectivity() loaded_graph = graph_connectivity.load_graph(self.filegraph3) self.assertEqual(loaded_graph, self.graph3)
def test_load_graph_nonexistant(self): graph_connectivity = Graph_connectivity() with self.assertRaises(IOError): loaded_graph = graph_connectivity.load_graph('filedoesntexist.txt')
def test_load_graph_character(self): graph_connectivity = Graph_connectivity() loaded_graph = graph_connectivity.load_graph(self.filegraph2) self.assertEqual(loaded_graph, self.graph2)