Mercurial > hg > orthanc-tests
comparison PerfsDb/Tests/UploadFile.py @ 161:27b3b0df5f90
2 upload tests
author | am@osimis.io |
---|---|
date | Fri, 17 Aug 2018 17:24:11 +0200 |
parents | df1f9946571c |
children | dbc42a03ee75 |
comparison
equal
deleted
inserted
replaced
160:6995d5d12d88 | 161:27b3b0df5f90 |
---|---|
1 from Test import Test | 1 from Test import Test |
2 | 2 |
3 class TestUploadFile(Test): | 3 class TestUploadFirstPatientFile(Test): |
4 | 4 |
5 def __init__(self, name:str = "UploadFile", filePath:str = "../Database/DummyCT.dcm"): | 5 def __init__(self, name:str = "UploadFirstPatientFile", filePath:str = "../Database/DummyCT.dcm"): |
6 super().__init__(name) | 6 super().__init__(name) |
7 self._instanceId = None | 7 self._instanceId = None |
8 self._filePath = filePath | 8 self._filePath = filePath |
9 self._dicomFileContent = None | 9 self._dicomFileContent = None |
10 | 10 |
18 # make sure the file is not in Orthanc before the upload | 18 # make sure the file is not in Orthanc before the upload |
19 self._orthanc.instances.delete(self._instanceId) | 19 self._orthanc.instances.delete(self._instanceId) |
20 | 20 |
21 def test(self): | 21 def test(self): |
22 self._orthanc.uploadDicom(self._dicomFileContent) | 22 self._orthanc.uploadDicom(self._dicomFileContent) |
23 | |
24 | |
25 class TestUploadNextPatientFile(Test): | |
26 | |
27 def __init__(self, name:str = "UploadNextPatientFile", filePath:str = "../Database/DummyCT.dcm"): | |
28 super().__init__(name) | |
29 self._instanceId = None | |
30 self._filePath = filePath | |
31 self._dicomFileContent = None | |
32 self._instanceIndex = 0 | |
33 | |
34 def beforeAll(self): | |
35 self._clear() | |
36 | |
37 # upload a source file that we will modify | |
38 self._sourceInstanceId = self._orthanc.uploadDicomFile(self._filePath) | |
39 | |
40 # upload the first instance of this patient | |
41 self._dicomFileContent = self._modifyFile() | |
42 self._orthanc.uploadDicom(self._dicomFileContent) | |
43 | |
44 | |
45 | |
46 def beforeEach(self): | |
47 self._dicomFileContent = self._modifyFile() | |
48 | |
49 def test(self): | |
50 self._orthanc.uploadDicom(self._dicomFileContent) | |
51 | |
52 def afterAll(self): | |
53 self._clear() | |
54 | |
55 def _clear(self): | |
56 patient = self._orthanc.patients.find("UploadNextPatientFile") | |
57 if patient is not None: | |
58 self._orthanc.patients.delete(patient.id) | |
59 | |
60 def _modifyFile(self): | |
61 self._instanceIndex += 1 | |
62 return self._orthanc.instances.modify( | |
63 instanceId=self._sourceInstanceId, | |
64 replaceTags={ | |
65 "PatientName": "UploadNextPatientFile", | |
66 "PatientID": "UploadNextPatientFile", | |
67 "StudyDescription": "UploadNextPatientFile", | |
68 "SeriesDescription": "UploadNextPatientFile", | |
69 "SOPInstanceUID": "999999.888888.777777.666666.555555.44444", | |
70 "StudyInstanceUID": "999999.888888.777777.666666", | |
71 "SeriesInstanceUID": "999999.888888.777777.666666.555555", | |
72 "SeriesNumber": "1", | |
73 "InstanceNumber": str(self._instanceIndex) | |
74 }, | |
75 deleteOriginal=False | |
76 ) |