|
1
|
|
|
from pydicom.data import get_testdata_files |
|
|
|
|
|
|
2
|
|
|
|
|
3
|
|
|
from orthanc.query import getOrthanc, postOrthanc, deleteOrthanc |
|
|
|
|
|
|
4
|
|
|
|
|
5
|
|
|
from LORIS.helper import is_response_success, check_json |
|
|
|
|
|
|
6
|
|
|
|
|
7
|
|
|
|
|
8
|
|
|
def uploadExamplesToOrthanc(): |
|
|
|
|
|
|
9
|
|
|
|
|
10
|
|
|
file_list = get_testdata_files("[Mm][Rr][Ii]") |
|
11
|
|
|
for file in file_list: |
|
12
|
|
|
upload = {'upload_file': open(file, 'rb')} |
|
13
|
|
|
status, r = postOrthanc("instances/", upload) |
|
|
|
|
|
|
14
|
|
|
assert(is_response_success(status, 200)) |
|
|
|
|
|
|
15
|
|
|
assert(check_json(r.json())) |
|
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
# Note that this will create several subjects. |
|
18
|
|
|
|
|
19
|
|
|
def test_getSubjects(): |
|
|
|
|
|
|
20
|
|
|
uploadExamplesToOrthanc() |
|
21
|
|
|
reseponse_code, list_subjects = getOrthanc("patients/") |
|
22
|
|
|
assert (is_response_success(reseponse_code, 200)) |
|
|
|
|
|
|
23
|
|
|
|
|
24
|
|
|
print(len(list_subjects)) |
|
25
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
def test_deleteSubjects(): |
|
|
|
|
|
|
28
|
|
|
uploadExamplesToOrthanc() |
|
29
|
|
|
reseponse_code, list_subjects = getOrthanc("patients/") |
|
30
|
|
|
assert (is_response_success(reseponse_code, 200)) |
|
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
print(len(list_subjects)) |
|
33
|
|
|
|
|
34
|
|
|
for subject in list_subjects: |
|
35
|
|
|
reseponse_code, r = deleteOrthanc("patients/"+subject) |
|
|
|
|
|
|
36
|
|
|
assert (is_response_success(reseponse_code, 200)) |
|
|
|
|
|
|
37
|
|
|
|
|
38
|
|
|
|
|
39
|
|
|
if __name__ is "__main__": |
|
|
|
|
|
|
40
|
|
|
test_deleteSubjects() |
|
|
|
|
|
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.