From 94994c8dafa188d84354e7ef378988e7b7f8d082 Mon Sep 17 00:00:00 2001 From: belthlemar Date: Wed, 18 Sep 2024 17:45:03 +0200 Subject: [PATCH] add test --- tests/integration/test_integration.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/tests/integration/test_integration.py b/tests/integration/test_integration.py index e808a7930a..eeace56032 100644 --- a/tests/integration/test_integration.py +++ b/tests/integration/test_integration.py @@ -1919,12 +1919,28 @@ def test_delete_raw(client: TestClient, user_access_token: str, internal_study_i client.headers = {"Authorization": f"Bearer {user_access_token}"} # ============================= - # SET UP + # SET UP + NOMINAL CASES # ============================= - # ============================= - # NOMINAL CASES - # ============================= + content = io.BytesIO(b"This is the end!") + file_1_path = "user/file_1.txt" + file_2_path = "user/folder/file_2.txt" + for f in [file_1_path, file_2_path]: + # Creates a file / folder inside user folder. + res = client.put( + f"/v1/studies/{internal_study_id}/raw", + params={"path": f, "create_missing": True}, + files={"file": content} + ) + assert res.status_code == 204, res.json() + + # Deletes the file / folder + res = client.delete(f"/v1/studies/{internal_study_id}/raw?path={f}") + assert res.status_code == 200 + # Asserts it doesn't exist anymore + res = client.get(f"/v1/studies/{internal_study_id}/raw?path={f}") + assert res.status_code == 404 + assert "not a child of User" in res.json()["description"] # ============================= # ERRORS