Skip to content

Commit

Permalink
Enhance tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
rkoumis committed Mar 4, 2024
1 parent 91fe765 commit 2d2624e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions agent/test_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2d2624e

Please sign in to comment.