import os import networkx as nx from evrouting.osm import read_osm, insert_charging_stations from evrouting.graph_tools import CHARGING_COEFFICIENT_KEY def _test_read_osm(): """Just check if it runs. Todo: Delete.""" assert read_osm(os.path.join(os.path.dirname(__file__), 'static/map.osm')) def test_insert_charging_stations_close(): G = nx.DiGraph() # Add two nodes, that exist in osm test map G.add_node(0, lat=51.7705832, lon=7.0002595) G.add_node(1, lat=51.7696529, lon=6.9568520) # Close two node 1 S = [{"lon": 7.0002593, "lat": 51.7705832, "power": 22.0}] G = insert_charging_stations(G, S) assert G.nodes[0][CHARGING_COEFFICIENT_KEY] == 22.0 assert CHARGING_COEFFICIENT_KEY not in G.nodes[1] def test_insert_charging_stations_eq(): G = nx.DiGraph() # Add two nodes, that exist in osm test map G.add_node(0, lat=51.7705832, lon=7.0002595) G.add_node(1, lat=51.7696529, lon=6.9568520) # Close exactly at node 1 S = [{"lon": 7.0002595, "lat": 51.7705832, "power": 22.0}] G = insert_charging_stations(G, S) assert G.nodes[0][CHARGING_COEFFICIENT_KEY] == 22.0 assert CHARGING_COEFFICIENT_KEY not in G.nodes[1]