def test_sg_adjace_error_two(): """Ensure adjacent raises an error if either node doesn't exist.""" from simple_graph import SimpleGraph test_sg = SimpleGraph() test_sg.add_node("a") with pytest.raises(IndexError) as message: test_sg.adjacent("a", "b") assert "Second argument is not in the graph." in str(message)
def test_sg_adjacent_false(): """Ensure adjacent returns false if a and b don't share an edge.""" from simple_graph import SimpleGraph test_sg = SimpleGraph() test_sg.add_node("a") test_sg.add_node("b") assert test_sg.adjacent("a", "b") is False
def test_adjacent(): from simple_graph import SimpleGraph new_graph = SimpleGraph() new_graph.graph = {'A': {'A': 10, 'B': 25}, 'B': {}, 'C': {}} assert new_graph.adjacent('A', 'B') is True assert new_graph.adjacent('A', 'C') is False
def test_adjacent_error(): from simple_graph import SimpleGraph new_graph = SimpleGraph() new_graph.graph = {'A': {'A': 10, 'B': 25}, 'B': {}} with pytest.raises(KeyError): new_graph.adjacent('A', 'E')
def test_adjacent_empty(): from simple_graph import SimpleGraph instance = SimpleGraph() assert instance.adjacent('waffles', 'waffles2') is False
def test_adjacent(): from simple_graph import SimpleGraph instance = SimpleGraph() instance.add_edge('waffles', 'waffles2') assert instance.adjacent('waffles', 'waffles2')
def test_sg_adjacent_true(): """Ensure adjacent returns true if a and b share an edge.""" from simple_graph import SimpleGraph test_sg = SimpleGraph() test_sg.add_edge("a", "b") assert test_sg.adjacent("a", "b") is True