def test_no_initial_channel(self): actual_graph = nx.Graph() yt_script.build_graph(actual_graph, None, max_depth=7, initial_channel=None) self.assertEqual(actual_graph.number_of_nodes(), 0)
def test_create_graph(self): expected_graph = nx.Graph() expected_graph.add_node('Bob', degree=0) expected_graph.add_node('Jim', degree=1) expected_graph.add_node('Carey', degree=1) expected_graph.add_node('Hurshel', degree=1) expected_graph.add_node('Errol', degree=2) expected_graph.add_node('Morgan', degree=2) expected_graph.add_node('Carol', degree=2) expected_graph.add_node('Monty', degree=3) expected_graph.add_node('Zara', degree=4) expected_graph.add_path(['Bob', 'Jim', 'Errol']) expected_graph.add_path(['Bob', 'Hurshel', 'Carol', 'Monty', 'Zara']) expected_graph.add_path(['Bob', 'Carey', 'Zara']) expected_graph.add_path(['Monty', 'Hurshel', 'Carey']) expected_graph.add_edge('Bob', 'Errol') expected_graph.add_edge('Hurshel', 'Morgan') actual_graph = nx.Graph() yt_script.build_graph(actual_graph, None, max_depth=7, initial_channel='A') for node in expected_graph.nodes(): self.assertIn(node, actual_graph.nodes()) for edge in expected_graph.edges(): try: self.assertIn(edge, actual_graph.edges()) except AssertionError: edge = (edge[1], edge[0]) self.assertIn(edge, actual_graph.edges()) continue