Beispiel #1
0
def test_graph_schema_verification_throws_error_when_routes_missing():
    g = DiGraph()
    g.add_node('1', x=1, y=2, id='1', epsg='epsg:27700')

    with pytest.raises(ScheduleElementGraphSchemaError) as e:
        verify_graph_schema(g)
    assert 'Graph is missing `routes` attribute' in str(e.value)
Beispiel #2
0
def test_graph_schema_verification_throws_error_when_given_wrong_type_object():
    g = {}

    with pytest.raises(ScheduleElementGraphSchemaError) as e:
        verify_graph_schema(g)
    assert 'The graph for a schedule element needs to be a networkx.DiGraph' in str(
        e.value)
Beispiel #3
0
def test_graph_schema_verification_throws_error_when_attributes_missing_from_stops():
    g = DiGraph()
    g.add_node('1', x=1, y=2)

    with pytest.raises(ScheduleElementGraphSchemaError) as e:
        verify_graph_schema(g)
    assert 'missing the following attributes' in str(e.value)
Beispiel #4
0
def test_graph_schema_verification_throws_error_when_missing_route_attributes():
    g = DiGraph()
    g.add_node('1', x=1, y=2, id='1', epsg='epsg:27700')
    g.graph['routes'] = {'1': {}}

    with pytest.raises(ScheduleElementGraphSchemaError) as e:
        verify_graph_schema(g)
    assert 'missing the following attributes:' in str(e.value)
Beispiel #5
0
def test_graph_schema_verification_throws_error_when_services_missing():
    g = DiGraph()
    g.add_node('1', x=1, y=2, id='1', epsg='epsg:27700')
    g.graph['routes'] = {'1': {'arrival_offsets': [], 'ordered_stops': [], 'route_short_name': '', 'mode': '',
                               'departure_offsets': [], 'trips': {}}}

    with pytest.raises(ScheduleElementGraphSchemaError) as e:
        verify_graph_schema(g)
    assert 'Graph is missing `services` attribute' in str(e.value)