Skip to content

Commit fc963bc

Browse files
committed
Add tests for check_utilization_not_all_zero
1 parent 454c86d commit fc963bc

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

tests/test_readers.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,3 +410,52 @@ def test_read_trade_technodata(tmp_path):
410410
"max_capacity_growth",
411411
"total_capacity_limit",
412412
}
413+
414+
415+
def test_check_utilization_not_all_zero_success():
416+
import pandas as pd
417+
from muse.readers.csv import check_utilization_not_all_zero
418+
419+
df = pd.DataFrame(
420+
{
421+
"utilization_factor": (0, 1, 1),
422+
"technology": ("gas", "gas", "solar"),
423+
"region": ("GB", "GB", "FR"),
424+
"year": (2010, 2010, 2011),
425+
}
426+
)
427+
check_utilization_not_all_zero(df, "file.csv")
428+
429+
430+
def test_check_utilization_not_all_zero_fail_all_zero():
431+
import pandas as pd
432+
from muse.readers.csv import check_utilization_not_all_zero
433+
434+
df = pd.DataFrame(
435+
{
436+
"utilization_factor": (0, 0, 1),
437+
"technology": ("gas", "gas", "solar"),
438+
"region": ("GB", "GB", "FR"),
439+
"year": (2010, 2010, 2011),
440+
}
441+
)
442+
443+
with raises(ValueError):
444+
check_utilization_not_all_zero(df, "file.csv")
445+
446+
447+
def test_check_utilization_not_all_zero_fail_missing_column():
448+
import pandas as pd
449+
from muse.readers.csv import check_utilization_not_all_zero
450+
451+
# NB: Required utilization_factor column is missing
452+
df = pd.DataFrame(
453+
{
454+
"technology": ("gas", "gas", "solar"),
455+
"region": ("GB", "GB", "FR"),
456+
"year": (2010, 2010, 2011),
457+
}
458+
)
459+
460+
with raises(ValueError):
461+
check_utilization_not_all_zero(df, "file.csv")

0 commit comments

Comments
 (0)