def test_find_vertex():
    g = DirectedGraph()
    v0 = g.add_vertex(vertex_props={'license': 'L0', 'type': 'P'})
    v1 = g.add_vertex(vertex_props={'license': 'L1', 'type': 'WP'})

    v = g.find_vertex(prop_name='license', prop_value='L1')
    assert v != v0
    assert v == v1

    v = g.find_vertex(prop_name='license', prop_value='L2')
    assert v is None
def test_find_vertex():
    """Test if method DirectedGraph.find_vertex() works correctly."""
    g = DirectedGraph()
    v0 = g.add_vertex(vertex_props={'license': 'L0', 'type': 'P'})
    v1 = g.add_vertex(vertex_props={'license': 'L1', 'type': 'WP'})

    v = g.find_vertex(prop_name='license', prop_value='L1')
    assert v != v0
    assert v == v1

    v = g.find_vertex(prop_name='license', prop_value='L2')
    assert v is None
Пример #3
0
def test_find_vertex_graph_with_one_vertex():
    """Test if method DirectedGraph.find_vertex() works correctly."""
    g = DirectedGraph()
    v0 = g.add_vertex(vertex_props={'license': 'L0', 'type': 'P'})

    v = g.find_vertex(prop_name='license', prop_value='L0')
    assert v is not None
    assert v == v0

    v = g.find_vertex(prop_name='license', prop_value='something_else')
    assert v is None

    with pytest.raises(Exception):
        v = g.find_vertex(prop_name='unknown_property', prop_value='L0')
Пример #4
0
def test_find_vertex_empty_graph():
    """Test if method DirectedGraph.find_vertex() works correctly for empty graph."""
    g = DirectedGraph()
    v = g.find_vertex(prop_name='license', prop_value='L1')
    assert v is None