Skip to content

Commit

Permalink
test: add test for parsing new profile version
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Hagg committed Apr 20, 2022
1 parent 59511d5 commit 63ed790
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion powersimdata/input/electrified_demand_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def get_profile(self, grid_model, kind, profile):
:param str profile: the filename
:return: (*pandas.DataFrame*) -- profile data frame
"""
path = f"raw/{grid_model}/electrification/{kind}/{profile}.csv"
path = f"raw/{grid_model}/{kind}/{profile}.csv"
return self._get_data_internal(path)

def get_profile_version(self, grid_model, kind, end_use, tech):
Expand Down
19 changes: 19 additions & 0 deletions powersimdata/input/tests/test_profile_input.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from fs.tempfs import TempFS

from powersimdata.input.electrified_demand_input import (
get_profile_version as get_profile_version_elec,
)
from powersimdata.input.profile_input import ProfileInput, get_profile_version


Expand All @@ -21,3 +24,19 @@ def test_get_file_path():
s_info = {"base_wind": "v8", "grid_model": "europe"}
path = ProfileInput()._get_file_path(s_info, "wind")
assert "raw/europe/wind_v8.csv" == path


def test_get_profile_version_electrification():
with TempFS() as tmp_fs:
grid_model = "usa_tamu"
kind = "building"
end_use = "res_cooking"
tech = "standard_heat_pump"
sub_fs = tmp_fs.makedirs(f"raw/{grid_model}/{kind}", recreate=True)
sub_fs.touch(f"{end_use}_{tech}_v1.csv")
version = get_profile_version_elec(tmp_fs, grid_model, kind, end_use, tech)
v_missing = get_profile_version_elec(
tmp_fs, grid_model, kind, end_use, "fake_tech"
)
assert "v1" == version[0]
assert [] == v_missing

0 comments on commit 63ed790

Please sign in to comment.