From 63ed790af65f7501f0f7d179759fbbd5b32d3beb Mon Sep 17 00:00:00 2001 From: Jon Hagg Date: Fri, 15 Apr 2022 16:56:21 -0700 Subject: [PATCH] test: add test for parsing new profile version --- .../input/electrified_demand_input.py | 2 +- .../input/tests/test_profile_input.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/powersimdata/input/electrified_demand_input.py b/powersimdata/input/electrified_demand_input.py index 3a66596d7..d3444107b 100644 --- a/powersimdata/input/electrified_demand_input.py +++ b/powersimdata/input/electrified_demand_input.py @@ -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): diff --git a/powersimdata/input/tests/test_profile_input.py b/powersimdata/input/tests/test_profile_input.py index 87d11a302..e38f1bd7e 100644 --- a/powersimdata/input/tests/test_profile_input.py +++ b/powersimdata/input/tests/test_profile_input.py @@ -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 @@ -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