Skip to content

Commit

Permalink
test(aggregation-api): delete index from the response file
Browse files Browse the repository at this point in the history
  • Loading branch information
mabw-rte committed Sep 20, 2024
1 parent ee634ad commit 268e51c
Showing 1 changed file with 16 additions and 24 deletions.
40 changes: 16 additions & 24 deletions tests/integration/raw_studies_blueprint/test_aggregate_raw_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ def test_area_aggregation(
res = client.get(f"/v1/studies/{internal_study_id}/areas/aggregate/mc-ind/{output_id}", params=params)
assert res.status_code == 200, res.json()
content = io.BytesIO(res.content)
df = pd.read_csv(content, index_col=0, sep=",")
df = pd.read_csv(content, sep=",")
resource_file = ASSETS_DIR.joinpath(f"aggregate_areas_raw_data/{expected_result_filename}")
resource_file.parent.mkdir(exist_ok=True, parents=True)
if not resource_file.exists():
Expand Down Expand Up @@ -483,7 +483,7 @@ def test_links_aggregation(
res = client.get(f"/v1/studies/{internal_study_id}/links/aggregate/mc-ind/{output_id}", params=params)
assert res.status_code == 200, res.json()
content = io.BytesIO(res.content)
df = pd.read_csv(content, index_col=0, sep=",")
df = pd.read_csv(content, sep=",")
resource_file = ASSETS_DIR.joinpath(f"aggregate_links_raw_data/{expected_result_filename}")
resource_file.parent.mkdir(exist_ok=True, parents=True)
if not resource_file.exists():
Expand Down Expand Up @@ -514,11 +514,11 @@ def test_different_formats(
content = io.BytesIO(res.content)
export_format = params["format"]
if export_format == TableExportFormat.CSV.value:
df = pd.read_csv(content, index_col=0, sep=",")
df = pd.read_csv(content, sep=",")
elif export_format == TableExportFormat.TSV.value:
df = pd.read_csv(content, index_col=0, sep="\t")
df = pd.read_csv(content, sep="\t")
else:
df = pd.read_excel(content, index_col=0) # type: ignore
df = pd.read_excel(content) # type: ignore
resource_file = ASSETS_DIR.joinpath(f"aggregate_links_raw_data/{expected_result_filename}")
resource_file.parent.mkdir(exist_ok=True, parents=True)
if not resource_file.exists():
Expand All @@ -542,9 +542,7 @@ def test_aggregation_with_incoherent_bodies(
output_id = params.pop("output_id")
res = client.get(f"/v1/studies/{internal_study_id}/links/aggregate/mc-ind/{output_id}", params=params)
assert res.status_code == 200, res.json()
content = io.BytesIO(res.content)
df = pd.read_csv(content, index_col=0, sep=",")
assert df.empty
assert res.content == b"\n"

def test_wrongly_typed_request(self, client: TestClient, user_access_token: str, internal_study_id: str):
"""
Expand Down Expand Up @@ -603,8 +601,7 @@ def test_empty_columns(self, client: TestClient, user_access_token: str, interna
},
)
assert res.status_code == 200, res.json()
df = pd.read_csv(io.BytesIO(res.content), index_col=0, sep=",")
assert df.empty
assert res.content == b"\n"

# test for links
res = client.get(
Expand All @@ -616,8 +613,7 @@ def test_empty_columns(self, client: TestClient, user_access_token: str, interna
},
)
assert res.status_code == 200, res.json()
df = pd.read_csv(io.BytesIO(res.content), index_col=0, sep=",")
assert df.empty
assert res.content == b"\n"

def test_non_existing_folder(
self, tmp_path: Path, client: TestClient, user_access_token: str, internal_study_id: str
Expand Down Expand Up @@ -662,7 +658,7 @@ def test_area_aggregation(
res = client.get(f"/v1/studies/{internal_study_id}/areas/aggregate/mc-all/{output_id}", params=params)
assert res.status_code == 200, res.json()
content = io.BytesIO(res.content)
df = pd.read_csv(content, index_col=0, sep=",")
df = pd.read_csv(content, sep=",")
resource_file = ASSETS_DIR.joinpath(f"aggregate_areas_raw_data/{expected_result_filename}")
resource_file.parent.mkdir(exist_ok=True, parents=True)
if not resource_file.exists():
Expand Down Expand Up @@ -691,7 +687,7 @@ def test_links_aggregation(
res = client.get(f"/v1/studies/{internal_study_id}/links/aggregate/mc-all/{output_id}", params=params)
assert res.status_code == 200, res.json()
content = io.BytesIO(res.content)
df = pd.read_csv(content, index_col=0, sep=",")
df = pd.read_csv(content, sep=",")
resource_file = ASSETS_DIR.joinpath(f"aggregate_links_raw_data/{expected_result_filename}")
resource_file.parent.mkdir(exist_ok=True, parents=True)
if not resource_file.exists():
Expand Down Expand Up @@ -722,11 +718,11 @@ def test_different_formats(
content = io.BytesIO(res.content)
export_format = params["format"]
if export_format == TableExportFormat.CSV.value:
df = pd.read_csv(content, index_col=0, sep=",")
df = pd.read_csv(content, sep=",")
elif export_format == TableExportFormat.TSV.value:
df = pd.read_csv(content, index_col=0, sep="\t")
df = pd.read_csv(content, sep="\t")
else:
df = pd.read_excel(content, index_col=0) # type: ignore
df = pd.read_excel(content) # type: ignore
resource_file = ASSETS_DIR.joinpath(f"aggregate_links_raw_data/{expected_result_filename}")
resource_file.parent.mkdir(exist_ok=True, parents=True)
if not resource_file.exists():
Expand All @@ -750,9 +746,7 @@ def test_aggregation_with_incoherent_bodies(
output_id = params.pop("output_id")
res = client.get(f"/v1/studies/{internal_study_id}/links/aggregate/mc-all/{output_id}", params=params)
assert res.status_code == 200, res.json()
content = io.BytesIO(res.content)
df = pd.read_csv(content, index_col=0, sep=",")
assert df.empty
assert res.content == b"\n"

def test_wrongly_typed_request(self, client: TestClient, user_access_token: str, internal_study_id: str):
"""
Expand Down Expand Up @@ -812,8 +806,7 @@ def test_empty_columns(self, client: TestClient, user_access_token: str, interna
},
)
assert res.status_code == 200, res.json()
df = pd.read_csv(io.BytesIO(res.content), index_col=0, sep=",")
assert df.empty
assert res.content == b"\n"

# test for links
res = client.get(
Expand All @@ -825,8 +818,7 @@ def test_empty_columns(self, client: TestClient, user_access_token: str, interna
},
)
assert res.status_code == 200, res.json()
df = pd.read_csv(io.BytesIO(res.content), index_col=0, sep=",")
assert df.empty
assert res.content == b"\n"

def test_non_existing_folder(
self, tmp_path: Path, client: TestClient, user_access_token: str, internal_study_id: str
Expand Down

0 comments on commit 268e51c

Please sign in to comment.