Skip to content

Commit

Permalink
add test for sts values
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinBelthle committed Dec 13, 2024
1 parent 03170ec commit e393e25
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
area,cluster,timeId,levels,P.injection,P.withdrawal,CashFlow
area_1,storage_1,1,0.000000,0.000000,0.000000,0.000000
de,storage_1,1,0.000000,0.000000,0.000000,0.000000
34 changes: 34 additions & 0 deletions tests/integration/raw_studies_blueprint/test_aggregate_raw_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,3 +804,37 @@ def test_empty_columns(self, client: TestClient, user_access_token: str, interna
)
assert res.status_code == 200, res.json()
assert res.content.strip() == b""


@pytest.mark.integration_test
class TestRawDataAggregationColumnsFormatting:
def test_columns_formatting(
self, client: TestClient, user_access_token: str, internal_study_id: str, tmp_path: Path
):
"""
Check returned columns names are post-processed
"""
client.headers = {"Authorization": f"Bearer {user_access_token}"}

# Prepare output
output_id = "20201014-1422eco-hello"
output_path = (
tmp_path / "ext_workspace" / "STA-mini" / "output" / output_id / "economy" / "mc-all" / "areas" / "de"
)
matrix_path = ASSETS_DIR / "aggregate_areas_raw_data" / "details-STstorage-annual.txt"
shutil.copy(matrix_path, output_path)

# asserts STS column names are post-processed by the back-end
res = client.get(
f"/v1/studies/{internal_study_id}/areas/aggregate/mc-all/{output_id}",
params={
"query_file": "details-STstorage",
"frequency": "annual",
},
)
assert res.status_code == 200
content = io.BytesIO(res.content)
actual_df = pd.read_csv(content, sep=",")
expected_df_path = ASSETS_DIR / "aggregate_areas_raw_data" / "expected_result_sts.csv"
expected_df = pd.read_csv(expected_df_path, sep=",")
assert actual_df.equals(expected_df)

0 comments on commit e393e25

Please sign in to comment.