Skip to content

Commit 1ffd4ef

Browse files
committed
zip_path
1 parent 875590c commit 1ffd4ef

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

tests/test_utils_functions.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import flask
77
import shutil
88
import uuid
9-
import glob
109
import zipfile
1110
import io
1211

@@ -224,11 +223,10 @@ def test_send_file_multiple_returns_zip(client, tmp_path):
224223
response = utils_functions.send_file(app.config["UPLOAD_FOLDER"], file_paths, "bundle")
225224
assert response.status_code == 200
226225
assert response.mimetype == "application/zip"
227-
assert response.headers.get("new-file-name") == "bundle.zip"
228-
229-
response.direct_passthrough = False
230-
zip_bytes = response.get_data()
231-
with zipfile.ZipFile(io.BytesIO(zip_bytes), "r") as zip_file:
226+
new_file_name = response.headers.get("new-file-name")
227+
assert new_file_name == "bundle.zip"
228+
zip_path = os.path.join(app.config["UPLOAD_FOLDER"], new_file_name)
229+
with zipfile.ZipFile(zip_path, "r") as zip_file:
232230
zip_entries = zip_file.namelist()
233231
assert "tmp_send_file_1.txt" in zip_entries
234232
assert "tmp_send_file_2.txt" in zip_entries
@@ -245,9 +243,10 @@ def test_send_file_single_returns_octet_binary(client, tmp_path):
245243
response = utils_functions.send_file(app.config["UPLOAD_FOLDER"], [str(file_path)], "tmp_send_file_1.txt")
246244
assert response.status_code == 200
247245
assert response.mimetype == "application/octet-binary"
248-
assert response.headers.get("new-file-name") == "tmp_send_file_1.txt"
249-
250-
response.direct_passthrough = False
251-
file_bytes = response.get_data()
246+
new_file_name = response.headers.get("new-file-name")
247+
assert new_file_name == "tmp_send_file_1.txt"
248+
zip_path = os.path.join(app.config["UPLOAD_FOLDER"], new_file_name)
249+
with open(zip_path, "rb") as f:
250+
file_bytes = f.read()
252251
assert file_bytes == b"hello 1"
253252
response.close()

0 commit comments

Comments
 (0)