Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
uw0s committed Apr 16, 2024
1 parent 9ee5485 commit 722910c
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions python/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import os
import re
import secrets
import socket
import subprocess
import sys
import time
Expand Down Expand Up @@ -146,13 +147,16 @@ def dcm2dictmetadata(ds: pydicom.dataset.Dataset) -> dict[str, dict[str, str]]:


class TestEndpoints(unittest.TestCase):
def app_url(self: TestEndpoints) -> str:
return "http://0.0.0.0:8000"

def test_upload_files(self: TestEndpoints) -> None:
def setUp(self: TestEndpoints) -> None:
with Path("./prm/1-1.dcm").open("rb") as file:
files = {"files": ("./prm/1-1.dcm", file, "application/dicom")}
response = client.post(self.app_url() + "/upload_files", files=files)
response = client.post(
"http://"
+ socket.gethostbyname(socket.gethostname())
+ ":8000"
+ "/upload_files",
files=files,
)
if response.status_code != status.HTTP_200_OK:
raise AssertionError
UploadFilesResponse.model_validate(response.json())
Expand All @@ -170,7 +174,13 @@ def test_submit_button(self: TestEndpoints) -> None:
"retain_descriptors": False,
"patient_pseudo_id_prefix": "OrgX - ",
}
response = client.post(self.app_url() + "/submit_button", json=test_options)
response = client.post(
"http://"
+ socket.gethostbyname(socket.gethostname())
+ ":8000"
+ "/submit_button",
json=test_options,
)
if response.status_code != status.HTTP_200_OK:
raise AssertionError
json_response = response.json()
Expand Down

0 comments on commit 722910c

Please sign in to comment.