From 8af22a8fe46d8c09eca3c9a843b57365a661555c Mon Sep 17 00:00:00 2001 From: "niehues.mark@gmail.com" <niehues.mark@gmail.com> Date: Wed, 29 Apr 2020 14:54:44 +0200 Subject: [PATCH] test setup --- tests/osm/test_gasstation_osm.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/tests/osm/test_gasstation_osm.py b/tests/osm/test_gasstation_osm.py index bf2f2f4..99dc775 100644 --- a/tests/osm/test_gasstation_osm.py +++ b/tests/osm/test_gasstation_osm.py @@ -1,7 +1,10 @@ +import networkx as nx + from evrouting import gasstation from evrouting.T import Result from evrouting.osm.profiles import car from evrouting.osm.routing import shortest_path +from evrouting.graph_tools import charging_cofficient def test_charge_shortest_route_dimensions(map_graph): @@ -39,21 +42,30 @@ def test_charge_shortest_route_stop(map_graph): _s = map_graph.find_nearest(s) _t = map_graph.find_nearest(t) - consumption = 0.5 # kWh/s - # Traveltime gonna be less than 10 min = 600 sek := 300 kWh. - # => initial soc of 300 000 + consumption = 0.5 * 1000 # Wh/s # Traveltime to first charging station is < 5 min = 300 sek := 150 kWh # => Initial soc of 150 000 is enough to charge but not to reach target. + initial_soc = 150000 result = gasstation.shortest_path(G=map_graph, charging_stations=map_graph.charging_stations, s=_s, t=_t, - initial_soc=150000, + initial_soc=initial_soc, final_soc=0, capacity=300000, - c=consumption * 1000, + c=consumption, extended_graph=None, contracted_graph=None ) - assert type(result) is Result + + charge_nodes = [(n, t) for n, t in result.charge_path if t >0] + assert len(charge_nodes) == 1 + + charge_node, charge_time = charge_nodes[0] + charging_station_c = charging_cofficient(map_graph, charge_node) + # calc travel time to charge_node an + s_to_c = consumption * nx.shortest_path_length(map_graph, _s, charge_node) + c_to_t = consumption * nx.shortest_path_length(map_graph, charge_node, _t) + + assert initial_soc + charge_time * charging_station_c == s_to_c + c_to_t -- GitLab