From 2d2624efd9ea0c83c1b4a952f9ab8e6d28195927 Mon Sep 17 00:00:00 2001 From: Robin Koumis Date: Mon, 4 Mar 2024 15:07:02 -0500 Subject: [PATCH] Enhance tests. --- agent/test_agent.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/agent/test_agent.py b/agent/test_agent.py index 701d955eb26..4ecac95d5f8 100644 --- a/agent/test_agent.py +++ b/agent/test_agent.py @@ -214,12 +214,14 @@ def test_mkdtemp_invalid(self): def test_store(self): sep = os.linesep upload_file = {"file": ("test_data.txt", f"test data{sep}test data{sep}")} - form = {"filepath": os.path.join(DIRPATH, self.make_temp_name() + ".tmp")} + path_to_create = os.path.join(DIRPATH, self.make_temp_name() + ".tmp") + form = {"filepath": path_to_create} r = requests.post(f"{BASE_URL}/store", files=upload_file, data=form) assert r.status_code == 200 js = r.json() assert js["message"] == "Successfully stored file" + assert os.path.isfile(path_to_create) def test_store_invalid(self): # missing file @@ -389,7 +391,9 @@ def test_execute_py(self): upload_file = {"file": ("test.py", f"print('{sample_string}')")} filepath = os.path.join(DIRPATH, self.make_temp_name() + ".py") form = {"filepath": filepath} - _ = requests.post(f"{BASE_URL}/store", files=upload_file, data=form) + r = requests.post(f"{BASE_URL}/store", files=upload_file, data=form) + assert r.status_code == 200 + assert os.path.isfile(filepath) r = requests.post(f"{BASE_URL}/execpy", data=form) assert r.status_code == 200