Newer
Older
from evrouting.osm import read_osm, insert_charging_stations
from evrouting.graph_tools import CHARGING_COEFFICIENT_KEY
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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]