@@ -276,7 +276,7 @@ def test_scheduled_charging_calc_current(plan_data: SelectedPlan,
276276
277277 # execution
278278 ret = ct .scheduled_charging_calc_current (plan_data , soc , used_amount , 3 , 3 , 6 ,
279- 0 , ChargingType .AC .value , EvTemplate (), BidiState .BIDI_CAPABLE )
279+ 0 , ChargingType .AC .value , EvTemplate (), BidiState .BIDI_CAPABLE , True )
280280
281281 # evaluation
282282 assert ret == expected
@@ -288,12 +288,45 @@ def test_scheduled_charging_calc_current_no_plans():
288288
289289 # execution
290290 ret = ct .scheduled_charging_calc_current (
291- None , 63 , 5 , 3 , 3 , 6 , 0 , ChargingType .AC .value , EvTemplate (), BidiState .BIDI_CAPABLE )
291+ None , 63 , 5 , 3 , 3 , 6 , 0 , ChargingType .AC .value , EvTemplate (), BidiState .BIDI_CAPABLE , True )
292292
293293 # evaluation
294294 assert ret == (0 , "stop" , ChargeTemplate .SCHEDULED_CHARGING_NO_PLANS_CONFIGURED , 3 )
295295
296296
297+ @pytest .mark .parametrize (
298+ "selected_limit, charge_state, expected" ,
299+ [
300+ pytest .param ("soc" , False ,
301+ (6 , "pv_charging" , ChargeTemplate .SCHEDULED_CHARGING_USE_PV .format ("um 8:50 Uhr" ), 0 ),
302+ id = "soc request interval not considered, use pv" ),
303+ pytest .param ("soc" , True ,
304+ (14 , "instant_charging" ,
305+ ChargeTemplate .SCHEDULED_CHARGING_IN_TIME .format (14 , 'einen SoC von 80%' , "07:00" ), 3 ),
306+ id = "soc request interval considered" ),
307+ pytest .param ("amount" , True ,
308+ (6 , "pv_charging" , ChargeTemplate .SCHEDULED_CHARGING_USE_PV .format ("um 8:50 Uhr" ), 0 ),
309+ id = "amount, charging, soc request interval not considered, no soc limit configured" ),
310+ pytest .param ("amount" , False ,
311+ (6 , "pv_charging" , ChargeTemplate .SCHEDULED_CHARGING_USE_PV .format ("um 8:50 Uhr" ), 0 ),
312+ id = "amount, not charging, soc request interval not considered, no soc limit configured" ),
313+ ])
314+ def test_scheduled_charging_calc_current_consider_soc_request_interval_offset (
315+ selected_limit : str , charge_state : bool , expected : Tuple [float , str , str , int ]):
316+ # setup
317+ ct = ChargeTemplate ()
318+ plan = ScheduledChargingPlan ()
319+ plan .limit .selected = selected_limit
320+
321+ # execution
322+ ret = ct .scheduled_charging_calc_current (
323+ SelectedPlan (plan = plan , remaining_time = 601 , phases = 3 , duration = 3600 ),
324+ 79 , 0 , 3 , 3 , 6 , 800 , ChargingType .AC .value , EvTemplate (), BidiState .BIDI_CAPABLE , charge_state )
325+
326+ # evaluation
327+ assert ret == expected
328+
329+
297330LOADING_HOURS_TODAY = [datetime .datetime (
298331 year = 2022 , month = 5 , day = 16 , hour = 8 , minute = 0 ).timestamp ()]
299332
@@ -383,7 +416,7 @@ def test_scheduled_charging_calc_current_electricity_tariff(
383416 # execution
384417 ret = ct .scheduled_charging_calc_current (
385418 SelectedPlan (plan = plan , remaining_time = 601 , phases = 3 , duration = 3600 ),
386- current_soc , 0 , 3 , 3 , 6 , 0 , ChargingType .AC .value , EvTemplate (), BidiState .BIDI_CAPABLE )
419+ current_soc , 0 , 3 , 3 , 6 , 0 , ChargingType .AC .value , EvTemplate (), BidiState .BIDI_CAPABLE , True )
387420
388421 # evaluation
389422 assert ret == expected
0 commit comments