Exemplo n.º 1
0
def test_properties():
    """Check methods get_prop_value and set_prop_value."""
    v = Vertex(1, {})

    with pytest.raises(Exception):
        assert v.get_prop_value("something") is None

    v.set_prop_value("name", "value")
    assert v.get_prop_value("name") == "value"

    with pytest.raises(Exception):
        # this statement still should raise an exception
        assert v.get_prop_value("something") is None
Exemplo n.º 2
0
def test_string_representation_4():
    """Check special method __str__ for vertices with properies."""
    v = Vertex(1, {})
    v.set_prop_value("name", "value")
    s = str(v)
    assert s == """
            Vertex: 1
            Neighbours: []
            Properties: {'name': 'value'}
            """

    v = Vertex(2, {})
    v.set_prop_value("other", "XXX")
    s = str(v)
    assert s == """