You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# case 0: fill up a int value and get it back later
259
-
print'case 0'
259
+
print('case 0')
260
260
d=json.loads(HCERR1505)
261
261
d['peer_count'] =5
262
262
s=json.dumps(d)
263
263
d=json.loads(s)
264
-
print'peer_count: %d'%d['peer_count']
265
-
print
264
+
print ('peer_count: %d'%d['peer_count'])
266
265
267
266
# case 1, msg is a simple error message, manually construct a json error message, then convert to dict object, should pass test
268
-
print'case 1'
267
+
print('case 1')
269
268
msg="In handler \'savedsearch\': Unable to create a saved search with name \'ExportSearch:test-error-message\'. A saved search with that name already exists."
270
269
json_str=HCERR1506% ('test-error-message', msg)
271
-
printjson_str
272
-
printjson.loads(json_str)
273
-
print
270
+
print (json_str)
271
+
print (json.loads(json_str))
274
272
275
273
# case 2: msg is very complex:
276
274
# 1) manually build dict object 2) convert dict to json error message 3) convert json string back to dict. should pass test
277
-
print'case 2'
275
+
print('case 2')
278
276
msg="[HTTP 409] [{'text': \"In handler 'savedsearch': Unable to create saved search with name 'ExportSearch: test-error-message'. A saved search with that name already exists.\", 'code': None, 'type': 'ERROR'}]"
279
277
# 1) manually build dict object
280
278
d= {}
@@ -284,94 +282,88 @@ def __str__(self):
284
282
d['error'] =msg
285
283
# 2) convert dict to json error message
286
284
json_str=json.dumps(d)
287
-
printjson_str
285
+
print(json_str)
288
286
# 3) convert json string back to dict
289
287
d=json.loads(json_str)
290
-
printd
291
-
printd['id']
292
-
printd['message']
293
-
printd['export']
294
-
printd['error']
295
-
print
288
+
print (d)
289
+
print (d['id'])
290
+
print (d['message'])
291
+
print (d['export'])
292
+
print (d['error'])
296
293
297
294
# case 3: msg is very complex, but HCERR1506 is a simple json string and is sure to be able to convert to dict.
298
295
# 1) convert HCERR1506 to dict
299
296
# 2) fill up the blank (export and error in this case)
300
297
# 3) convert dict to json error message
301
298
# 4) convert json string back to dict
302
299
# should pass test.
303
-
print'case 3'
300
+
print('case 3')
304
301
# 1) convert HCERR1506 to dict
305
302
d=json.loads(HCERR1506)
306
303
# 2) fill up the blank (export and error in this case)
307
304
d['export'] ='test-error-message'
308
305
d['error'] =msg
309
306
# 3) convert dict to json error message
310
307
json_str=json.dumps(d)
311
-
printjson_str
308
+
print(json_str)
312
309
# 4) convert json string back to dict
313
310
d=json.loads(json_str)
314
-
printd
315
-
printd['id']
316
-
printd['message']
317
-
printd['export']
318
-
printd['error']
319
-
print
311
+
print (d)
312
+
print (d['id'])
313
+
print (d['message'])
314
+
print (d['export'])
315
+
print (d['error'])
320
316
321
317
# case 4: msg is very complex.
322
318
# 1) create HcExeption with msg 2) get error dict from the exception
0 commit comments