comparison Tests/Tests.py @ 113:3e5934363e76

test_rest_find_limitĀµ
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 11 Jul 2017 17:24:06 +0200
parents 9d09f6f21b60
children 45ebfab035b7
comparison
equal deleted inserted replaced
112:9d09f6f21b60 113:3e5934363e76
3191 modified = DoPost(_REMOTE, 3191 modified = DoPost(_REMOTE,
3192 '/patients/da128605-e040d0c4-310615d2-3475da63-df2d1ef4/modify', 3192 '/patients/da128605-e040d0c4-310615d2-3475da63-df2d1ef4/modify',
3193 '{"Replace":{"PatientID":"Hello","PatientName":"Sample patient name"}}', 3193 '{"Replace":{"PatientID":"Hello","PatientName":"Sample patient name"}}',
3194 'application/json') 3194 'application/json')
3195 self.assertTrue('PatientID' in modified) 3195 self.assertTrue('PatientID' in modified)
3196 3196
3197
3198 def test_rest_find_limit(self):
3199 # Check the "Since" and "Limit" parameters in URI "/tools/find"
3200 # Related to issue 53: https://bitbucket.org/sjodogne/orthanc/issues/53
3201
3202 # Upload 6 instances
3203 brainix = []
3204 knee = []
3205 for i in range(2):
3206 brainix.append(UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) ['ID'])
3207 brainix.append(UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) ['ID'])
3208 knee.append(UploadInstance(_REMOTE, 'Knee/T1/IM-0001-000%d.dcm' % (i + 1)) ['ID'])
3209
3210 # Check using BRAINIX
3211 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance',
3212 'Query' : { 'PatientName' : 'B*' },
3213 'Limit' : 10 })
3214 self.assertEqual(4, len(a))
3215
3216 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance',
3217 'Query' : { 'PatientName' : 'B*' },
3218 'Limit' : 4 })
3219 self.assertEqual(4, len(a))
3220
3221 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance',
3222 'Query' : { 'PatientName' : 'B*' },
3223 'Since' : 2,
3224 'Limit' : 4 })
3225 self.assertEqual(2, len(a))
3226
3227 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance',
3228 'Query' : { 'PatientName' : 'B*' },
3229 'Limit' : 3 })
3230 self.assertEqual(3, len(a))
3231
3232 b = []
3233 for i in range(4):
3234 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance',
3235 'Query' : { 'PatientName' : 'B*' },
3236 'Limit' : 1,
3237 'Since' : i })
3238 self.assertEqual(1, len(a))
3239 b.append(a[0])
3240
3241 # Check whether the two sets are equal through symmetric difference
3242 self.assertEqual(0, len(set(b) ^ set(brainix)))
3243
3244 # Check using KNEE
3245 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance',
3246 'Query' : { 'PatientName' : 'K*' },
3247 'Limit' : 10 })
3248 self.assertEqual(2, len(a))
3249
3250 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance',
3251 'Query' : { 'PatientName' : 'K*' },
3252 'Limit' : 2 })
3253 self.assertEqual(2, len(a))
3254
3255 b = []
3256 for i in range(2):
3257 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance',
3258 'Query' : { 'PatientName' : 'K*' },
3259 'Limit' : 1,
3260 'Since' : i })
3261 self.assertEqual(1, len(a))
3262 b.append(a[0])
3263
3264 self.assertEqual(0, len(set(b) ^ set(knee)))