Skip to content

Commit 32c1713

Browse files
committed
Run the tests with the defaults, no waste and no import profiles.
1 parent 18ab7af commit 32c1713

File tree

2 files changed

+269
-72
lines changed

2 files changed

+269
-72
lines changed

divert_sim/test_divert.py

Lines changed: 211 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/usr/bin/env python3
2+
"""Test the divert_sim process"""
3+
24
# PYTHON_ARGCOMPLETE_OK
5+
# pylint: disable=line-too-long
36

47
from os import path
58
import os
@@ -29,9 +32,10 @@ def setup():
2932
if not path.exists('output'):
3033
os.mkdir('output')
3134
with open(path.join('output', 'summary.csv'), 'w', encoding="utf-8") as summary_file:
32-
summary_file.write('"Dataset","Total Solar (kWh)","Total EV Charge (kWh)","Charge from solar (kWh)","Charge from grid (kWh)","Number of charges","Min time charging","Max time charging","Total time charging"\n')
35+
summary_file.write('"Dataset","Config","Total Solar (kWh)","Total EV Charge (kWh)","Charge from solar (kWh)","Charge from grid (kWh)","Number of charges","Min time charging","Max time charging","Total time charging"\n')
3336

3437
def run_test_with_dataset(dataset: str,
38+
output: str,
3539
expected_solar_kwh: float,
3640
expected_ev_kwh : float,
3741
expected_kwh_from_solar : float,
@@ -63,7 +67,7 @@ def run_test_with_dataset(dataset: str,
6367

6468
# Read in the dataset and pass to the divert_sim process
6569
with open(path.join('data', dataset+'.csv'), 'r', encoding="utf-8") as input_data:
66-
with open(path.join('output', dataset+'.csv'), 'w', encoding="utf-8") as output_data:
70+
with open(path.join('output', output+'.csv'), 'w', encoding="utf-8") as output_data:
6771
# open the divert_sim process
6872
command = ["./divert_sim"]
6973
if config:
@@ -138,8 +142,11 @@ def run_test_with_dataset(dataset: str,
138142
kwh_from_solar=wh_from_solar / 1000
139143
kwh_from_grid=wh_from_grid / 1000
140144

145+
if config is False:
146+
config = "Default"
147+
141148
with open(path.join('output', 'summary.csv'), 'a', encoding="utf-8") as summary_file:
142-
summary_file.write(f'"{dataset}",{solar_kwh},{ev_kwh},{kwh_from_solar},{kwh_from_grid},{number_of_charges},{min_time_charging},{max_time_charging},{total_time_charging}\n')
149+
summary_file.write(f'"{dataset}","{config}",{solar_kwh},{ev_kwh},{kwh_from_solar},{kwh_from_grid},{number_of_charges},{min_time_charging},{max_time_charging},{total_time_charging}\n')
143150

144151
assert round(solar_kwh, KWH_ROUNDING) == expected_solar_kwh
145152
assert round(ev_kwh, KWH_ROUNDING) == expected_ev_kwh
@@ -150,84 +157,234 @@ def run_test_with_dataset(dataset: str,
150157
assert max_time_charging == expected_max_time_charging
151158
assert total_time_charging == expected_total_time_charging
152159

153-
def test_divert_almostperfect() -> None:
154-
"""Run the divert test with the almostperfect dataset"""
155-
run_test_with_dataset('almostperfect',
160+
# default value tests
161+
162+
def test_divert_almostperfect_default() -> None:
163+
"""Run the divert test with the almostperfect dataset with the default values"""
164+
run_test_with_dataset('almostperfect', 'almostperfect_default',
156165
21.08, 16.67, 16.6, 0.06, 6, 180, 20700, 28620)
157166

158-
def test_divert_cloudymorning() -> None:
159-
"""Run the divert test with the CloudyMorning dataset"""
160-
run_test_with_dataset('CloudyMorning',
167+
def test_divert_cloudymorning_default() -> None:
168+
"""Run the divert test with the CloudyMorning dataset with the default values"""
169+
run_test_with_dataset('CloudyMorning', 'CloudyMorning_default',
161170
16.64, 12.28, 12.07, 0.22, 7, 300, 14520, 20340)
162171

163-
def test_divert_day1() -> None:
164-
"""Run the divert test with the day1 dataset"""
165-
run_test_with_dataset('day1',
172+
def test_divert_day1_default() -> None:
173+
"""Run the divert test with the day1 dataset with the default values"""
174+
run_test_with_dataset('day1', 'day1_default',
166175
10.12, 7.11, 6.51, 0.59, 7, 660, 8400, 12840)
167176

168-
def test_divert_day2() -> None:
169-
"""Run the divert test with the day2 dataset"""
170-
run_test_with_dataset('day2',
177+
def test_divert_day2_default() -> None:
178+
"""Run the divert test with the day2 dataset with the default values"""
179+
run_test_with_dataset('day2', 'day2_default',
171180
12.35, 9.14, 9.14, 0.0, 1, 18060, 18060, 18060)
172181

173-
def test_divert_day3() -> None:
174-
"""Run the divert test with the day3 dataset"""
175-
run_test_with_dataset('day3',
182+
def test_divert_day3_default() -> None:
183+
"""Run the divert test with the day3 dataset with the default values"""
184+
run_test_with_dataset('day3', 'day3_default',
176185
5.09, 1.66, 1.22, 0.44, 7, 60, 840, 3600)
177186

178-
def test_divert_day1_grid_ie() -> None:
179-
"""Run the divert test with the day1_grid_ie dataset"""
180-
run_test_with_dataset('day1_grid_ie',
187+
def test_divert_day1_grid_ie_default() -> None:
188+
"""Run the divert test with the day1_grid_ie dataset with the default values"""
189+
run_test_with_dataset('day1_grid_ie', 'day1_grid_ie_default',
181190
15.13, 7.84, 7.66, 0.18, 10, 660, 6300, 17280,
182191
grid_ie_col=2)
183192

184-
def test_divert_day2_grid_ie() -> None:
185-
"""Run the divert test with the day2_grid_ie dataset"""
186-
run_test_with_dataset('day2_grid_ie',
193+
def test_divert_day2_grid_ie_default() -> None:
194+
"""Run the divert test with the day2_grid_ie dataset with the default values"""
195+
run_test_with_dataset('day2_grid_ie', 'day2_grid_ie_default',
187196
10.85, 7.00, 5.87, 1.13, 21, 60, 2640, 14460,
188197
grid_ie_col=2)
189198

190-
def test_divert_day3_grid_ie() -> None:
191-
"""Run the divert test with the day3_grid_ie dataset"""
192-
run_test_with_dataset('day3_grid_ie',
199+
def test_divert_day3_grid_ie_default() -> None:
200+
"""Run the divert test with the day3_grid_ie dataset with the default values"""
201+
run_test_with_dataset('day3_grid_ie', 'day3_grid_ie_default',
193202
12.13, 5.39, 5.37, 0.02, 7, 60, 4320, 11160,
194203
grid_ie_col=2)
195204

196-
def test_divert_solar_vrms() -> None:
197-
"""Run the divert test with the solar-vrms dataset"""
198-
run_test_with_dataset('solar-vrms',
205+
def test_divert_solar_vrms_default() -> None:
206+
"""Run the divert test with the solar-vrms dataset with the default values"""
207+
run_test_with_dataset('solar-vrms', 'solar-vrms_default',
199208
13.85, 11.18, 11.14, 0.04, 1, 19440, 19440, 19440,
200209
voltage_col=2)
201210

202-
def test_divert_energy_and_power_day_2020_03_22() -> None:
203-
"""Run the divert test with the Energy_and_Power_Day_2020-03-22 dataset"""
204-
run_test_with_dataset('Energy_and_Power_Day_2020-03-22',
211+
def test_divert_energy_and_power_day_2020_03_22_default() -> None:
212+
"""Run the divert test with the Energy_and_Power_Day_2020-03-22 dataset with the default values"""
213+
run_test_with_dataset('Energy_and_Power_Day_2020-03-22', 'Energy_and_Power_Day_2020-03-22_default',
214+
41.87, 38.16, 38.16, 0.0, 1, 27900, 27900, 27900,
215+
separator=';', is_kw=True)
216+
217+
def test_divert_energy_and_power_day_2020_03_31_default() -> None:
218+
"""Run the divert test with the Energy_and_Power_Day_2020-03-31 dataset with the default values"""
219+
run_test_with_dataset('Energy_and_Power_Day_2020-03-31', 'Energy_and_Power_Day_2020-03-31_default',
220+
23.91, 18.42, 18.42, 0.0, 2, 900, 20700, 21600,
221+
separator=';', is_kw=True)
222+
223+
def test_divert_energy_and_power_day_2020_04_01_default() -> None:
224+
"""Run the divert test with the Energy_and_Power_Day_2020-04-01 dataset with the default values"""
225+
run_test_with_dataset('Energy_and_Power_Day_2020-04-01', 'Energy_and_Power_Day_2020-04-01_default',
226+
38.89, 36.42, 36.42, 0.0, 1, 26100, 26100, 26100,
227+
separator=';', is_kw=True)
228+
229+
# noimport profile tests
230+
231+
def test_divert_almostperfect_noimport() -> None:
232+
"""Run the divert test with the almostperfect dataset with the noimport profile values"""
233+
run_test_with_dataset('almostperfect', 'almostperfect_noimport',
234+
21.08, 15.66, 15.57, 0.09, 5, 660, 20400, 26400,
235+
config='data/config-inputfilter-noimport.json')
236+
237+
def test_divert_cloudymorning_noimport() -> None:
238+
"""Run the divert test with the CloudyMorning dataset with the noimport profile values"""
239+
run_test_with_dataset('CloudyMorning', 'CloudyMorning_noimport',
240+
16.64, 10.52, 10.4, 0.12, 6, 660, 9060, 16440,
241+
config='data/config-inputfilter-noimport.json')
242+
243+
def test_divert_day1_noimport() -> None:
244+
"""Run the divert test with the day1 dataset with the noimport profile values"""
245+
run_test_with_dataset('day1', 'day1_noimport',
246+
10.12, 4.96, 4.71, 0.25, 6, 660, 2460, 7800,
247+
config='data/config-inputfilter-noimport.json')
248+
249+
def test_divert_day2_noimport() -> None:
250+
"""Run the divert test with the day2 dataset with the noimport profile values"""
251+
run_test_with_dataset('day2', 'day2_noimport',
252+
12.35, 8.85, 8.85, 0.0, 1, 17400, 17400, 17400,
253+
config='data/config-inputfilter-noimport.json')
254+
255+
def test_divert_day3_noimport() -> None:
256+
"""Run the divert test with the day3 dataset with the noimport profile values"""
257+
run_test_with_dataset('day3', 'day3_noimport',
258+
5.09, 0.04, 0.04, 0, 1, 120, 120, 120,
259+
config='data/config-inputfilter-noimport.json')
260+
261+
def test_divert_day1_grid_ie_noimport() -> None:
262+
"""Run the divert test with the day1_grid_ie dataset with the noimport profile values"""
263+
run_test_with_dataset('day1_grid_ie', 'day1_grid_ie_noimport',
264+
15.13, 4.95, 4.91, 0.04, 9, 60, 2580, 10560,
265+
grid_ie_col=2, config='data/config-inputfilter-noimport.json')
266+
267+
def test_divert_day2_grid_ie_noimport() -> None:
268+
"""Run the divert test with the day2_grid_ie dataset with the noimport profile values"""
269+
run_test_with_dataset('day2_grid_ie', 'day2_grid_ie_noimport',
270+
10.85, 1.74, 1.65, 0.09, 3, 660, 2040, 3360,
271+
grid_ie_col=2, config='data/config-inputfilter-noimport.json')
272+
273+
def test_divert_day3_grid_ie_noimport() -> None:
274+
"""Run the divert test with the day3_grid_ie dataset with the noimport profile values"""
275+
run_test_with_dataset('day3_grid_ie', 'day3_grid_ie_noimport',
276+
12.13, 3.9, 3.86, 0.04, 7, 660, 2700, 7620,
277+
grid_ie_col=2, config='data/config-inputfilter-noimport.json')
278+
279+
def test_divert_solar_vrms_noimport() -> None:
280+
"""Run the divert test with the solar-vrms dataset with the noimport profile values"""
281+
run_test_with_dataset('solar-vrms', 'solar-vrms_noimport',
282+
13.85, 10.94, 10.9, 0.04, 1, 18960, 18960, 18960,
283+
voltage_col=2, config='data/config-inputfilter-noimport.json')
284+
285+
def test_divert_energy_and_power_day_2020_03_22_noimport() -> None:
286+
"""Run the divert test with the Energy_and_Power_Day_2020-03-22 dataset with the noimport profile values"""
287+
run_test_with_dataset('Energy_and_Power_Day_2020-03-22', 'Energy_and_Power_Day_2020-03-22_noimport',
288+
41.87, 38.16, 38.16, 0.0, 1, 27900, 27900, 27900,
289+
separator=';', is_kw=True, config='data/config-inputfilter-noimport.json')
290+
291+
def test_divert_energy_and_power_day_2020_03_31_noimport() -> None:
292+
"""Run the divert test with the Energy_and_Power_Day_2020-03-31 dataset with the noimport profile values"""
293+
run_test_with_dataset('Energy_and_Power_Day_2020-03-31', 'Energy_and_Power_Day_2020-03-31_noimport',
294+
23.91, 18.06, 18.06, 0.0, 1, 20700, 20700, 20700,
295+
separator=';', is_kw=True, config='data/config-inputfilter-noimport.json')
296+
297+
def test_divert_energy_and_power_day_2020_04_01_noimport() -> None:
298+
"""Run the divert test with the Energy_and_Power_Day_2020-04-01 dataset with the noimport profile values"""
299+
run_test_with_dataset('Energy_and_Power_Day_2020-04-01', 'Energy_and_Power_Day_2020-04-01_noimport',
300+
38.89, 36.42, 36.42, 0.0, 1, 26100, 26100, 26100,
301+
separator=';', is_kw=True, config='data/config-inputfilter-noimport.json')
302+
303+
# nowaste profile tests
304+
305+
def test_divert_almostperfect_nowaste() -> None:
306+
"""Run the divert test with the almostperfect dataset with the nowaste profile values"""
307+
run_test_with_dataset('almostperfect', 'almostperfect_nowaste',
308+
21.08, 16.67, 16.6, 0.06, 6, 180, 20700, 28620,
309+
config='data/config-inputfilter-nowaste.json')
310+
311+
def test_divert_cloudymorning_nowaste() -> None:
312+
"""Run the divert test with the CloudyMorning dataset with the nowaste profile values"""
313+
run_test_with_dataset('CloudyMorning', 'CloudyMorning_nowaste',
314+
16.64, 12.28, 12.07, 0.22, 7, 300, 14520, 20340,
315+
config='data/config-inputfilter-nowaste.json')
316+
317+
def test_divert_day1_nowaste() -> None:
318+
"""Run the divert test with the day1 dataset with the nowaste profile values"""
319+
run_test_with_dataset('day1', 'day1_nowaste',
320+
10.12, 7.11, 6.51, 0.59, 7, 660, 8400, 12840,
321+
config='data/config-inputfilter-nowaste.json')
322+
323+
def test_divert_day2_nowaste() -> None:
324+
"""Run the divert test with the day2 dataset with the nowaste profile values"""
325+
run_test_with_dataset('day2', 'day2_nowaste',
326+
12.35, 9.14, 9.14, 0.0, 1, 18060, 18060, 18060,
327+
config='data/config-inputfilter-nowaste.json')
328+
329+
def test_divert_day3_nowaste() -> None:
330+
"""Run the divert test with the day3 dataset with the nowaste profile values"""
331+
run_test_with_dataset('day3', 'day3_nowaste',
332+
5.09, 1.66, 1.22, 0.44, 7, 60, 840, 3600,
333+
config='data/config-inputfilter-nowaste.json')
334+
335+
def test_divert_day1_grid_ie_nowaste() -> None:
336+
"""Run the divert test with the day1_grid_ie dataset with the nowaste profile values"""
337+
run_test_with_dataset('day1_grid_ie', 'day1_grid_ie_nowaste',
338+
15.13, 7.84, 7.66, 0.18, 10, 660, 6300, 17280,
339+
grid_ie_col=2, config='data/config-inputfilter-nowaste.json')
340+
341+
def test_divert_day2_grid_ie_nowaste() -> None:
342+
"""Run the divert test with the day2_grid_ie dataset with the nowaste profile values"""
343+
run_test_with_dataset('day2_grid_ie', 'day2_grid_ie_nowaste',
344+
10.85, 7.00, 5.87, 1.13, 21, 60, 2640, 14460,
345+
grid_ie_col=2, config='data/config-inputfilter-nowaste.json')
346+
347+
def test_divert_day3_grid_ie_nowaste() -> None:
348+
"""Run the divert test with the day3_grid_ie dataset with the nowaste profile values"""
349+
run_test_with_dataset('day3_grid_ie', 'day3_grid_ie_nowaste',
350+
12.13, 5.39, 5.37, 0.02, 7, 60, 4320, 11160,
351+
grid_ie_col=2, config='data/config-inputfilter-nowaste.json')
352+
353+
def test_divert_solar_vrms_nowaste() -> None:
354+
"""Run the divert test with the solar-vrms dataset with the nowaste profile values"""
355+
run_test_with_dataset('solar-vrms', 'solar-vrms_nowaste',
356+
13.85, 11.18, 11.14, 0.04, 1, 19440, 19440, 19440,
357+
voltage_col=2, config='data/config-inputfilter-nowaste.json')
358+
359+
def test_divert_energy_and_power_day_2020_03_22_nowaste() -> None:
360+
"""Run the divert test with the Energy_and_Power_Day_2020-03-22 dataset with the nowaste profile values"""
361+
run_test_with_dataset('Energy_and_Power_Day_2020-03-22', 'Energy_and_Power_Day_2020-03-22_nowaste',
205362
41.87, 38.16, 38.16, 0.0, 1, 27900, 27900, 27900,
206-
separator=';', is_kw=True, config='{"divert_decay_smoothing_time":200}')
363+
separator=';', is_kw=True, config='data/config-inputfilter-nowaste.json')
207364

208-
def test_divert_energy_and_power_day_2020_03_31() -> None:
209-
"""Run the divert test with the Energy_and_Power_Day_2020-03-31 dataset"""
210-
run_test_with_dataset('Energy_and_Power_Day_2020-03-31',
365+
def test_divert_energy_and_power_day_2020_03_31_nowaste() -> None:
366+
"""Run the divert test with the Energy_and_Power_Day_2020-03-31 dataset with the nowaste profile values"""
367+
run_test_with_dataset('Energy_and_Power_Day_2020-03-31', 'Energy_and_Power_Day_2020-03-31_nowaste',
211368
23.91, 18.42, 18.42, 0.0, 2, 900, 20700, 21600,
212-
separator=';', is_kw=True, config='{"divert_decay_smoothing_time":200}')
369+
separator=';', is_kw=True, config='data/config-inputfilter-nowaste.json')
213370

214-
def test_divert_energy_and_power_day_2020_04_01() -> None:
215-
"""Run the divert test with the Energy_and_Power_Day_2020-04-01 dataset"""
216-
run_test_with_dataset('Energy_and_Power_Day_2020-04-01',
371+
def test_divert_energy_and_power_day_2020_04_01_nowaste() -> None:
372+
"""Run the divert test with the Energy_and_Power_Day_2020-04-01 dataset with the nowaste profile values"""
373+
run_test_with_dataset('Energy_and_Power_Day_2020-04-01', 'Energy_and_Power_Day_2020-04-01_nowaste',
217374
38.89, 36.42, 36.42, 0.0, 1, 26100, 26100, 26100,
218-
separator=';', is_kw=True, config='{"divert_decay_smoothing_time":200}')
375+
separator=';', is_kw=True, config='data/config-inputfilter-nowaste.json')
219376

220377
if __name__ == '__main__':
221378
# Run the script
222-
test_divert_almostperfect()
223-
test_divert_cloudymorning()
224-
test_divert_day1()
225-
test_divert_day2()
226-
test_divert_day3()
227-
test_divert_day1_grid_ie()
228-
test_divert_day2_grid_ie()
229-
test_divert_day3_grid_ie()
230-
test_divert_solar_vrms()
231-
test_divert_energy_and_power_day_2020_03_22()
232-
test_divert_energy_and_power_day_2020_03_31()
233-
test_divert_energy_and_power_day_2020_04_01()
379+
test_divert_almostperfect_default()
380+
test_divert_cloudymorning_default()
381+
test_divert_day1_default()
382+
test_divert_day2_default()
383+
test_divert_day3_default()
384+
test_divert_day1_grid_ie_default()
385+
test_divert_day2_grid_ie_default()
386+
test_divert_day3_grid_ie_default()
387+
test_divert_solar_vrms_default()
388+
test_divert_energy_and_power_day_2020_03_22_default()
389+
test_divert_energy_and_power_day_2020_03_31_default()
390+
test_divert_energy_and_power_day_2020_04_01_default()

0 commit comments

Comments
 (0)