Skip to content

Commit

Permalink
fix typing
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinBelthle committed Sep 26, 2024
1 parent 82e1798 commit 29c481e
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions tests/integration/studies_blueprint/test_study_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
# This file is part of the Antares project.

import io
import os
import zipfile
from pathlib import Path

from starlette.testclient import TestClient

from tests.integration.assets import ASSETS_DIR

import zipfile
import os


class TestStudyVersions:
"""
Expand All @@ -43,17 +42,17 @@ def test_nominal_case(self, client: TestClient, user_access_token: str, tmp_path
zip_path = ASSETS_DIR / "STA-mini.zip"
# Extract zip inside tmp_dir
new_zip_path = tmp_dir / "test_version_90"
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
with zipfile.ZipFile(zip_path, "r") as zip_ref:
zip_ref.extractall(new_zip_path)

# Change file content
target_path = os.path.join(new_zip_path, "STA-mini", "study.antares")
with open(target_path, 'w') as file:
with open(target_path, "w") as file:
file.write(data)

final_path = tmp_dir / "test_version_90.zip"
# Rezip it
with zipfile.ZipFile(final_path, 'w', zipfile.ZIP_DEFLATED) as zipf:
with zipfile.ZipFile(final_path, "w", zipfile.ZIP_DEFLATED) as zipf:
for root, dirs, files in os.walk(new_zip_path):
for file in files:
file_path = os.path.join(root, file)
Expand All @@ -64,7 +63,6 @@ def test_nominal_case(self, client: TestClient, user_access_token: str, tmp_path
# =============================

for f in [zip_path, final_path]:

# Imports a study
res = client.post("/v1/studies/_import", files={"study": io.BytesIO(f.read_bytes())})
res.raise_for_status()
Expand All @@ -78,7 +76,7 @@ def test_nominal_case(self, client: TestClient, user_access_token: str, tmp_path
# Reads `study.version` file
res = client.get(f"v1/studies/{study_id}/raw?path=study")
res.raise_for_status()
version = str(res.json()['antares']['version'])
version = str(res.json()["antares"]["version"])
assert version == "9.0" if f == final_path else "700"

# Delete the study
Expand Down

0 comments on commit 29c481e

Please sign in to comment.