@@ -281,15 +281,15 @@ def test_score(self):
281
281
self .assertEqual ("INVALID_INPUT" , score .warnings [0 ].code )
282
282
self .assertEqual (99 , score .ip_address .risk )
283
283
284
- self .assertEqual (response , self . _remove_empty_values ( score .to_dict () ))
284
+ self .assertEqual (response , score .to_dict ())
285
285
286
286
def test_insights (self ):
287
287
response = self .factors_response ()
288
288
del response ["risk_score_reasons" ]
289
289
del response ["subscores" ]
290
290
insights = Insights (None , ** response )
291
291
self .check_insights_data (insights , response ["id" ])
292
- self .assertEqual (response , self . _remove_empty_values ( insights .to_dict () ))
292
+ self .assertEqual (response , insights .to_dict ())
293
293
294
294
def test_factors (self ):
295
295
response = self .factors_response ()
@@ -321,7 +321,7 @@ def test_factors(self):
321
321
)
322
322
self .assertEqual (0.17 , factors .subscores .time_of_day )
323
323
324
- self .assertEqual (response , self . _remove_empty_values ( factors .to_dict () ))
324
+ self .assertEqual (response , factors .to_dict ())
325
325
326
326
def factors_response (self ):
327
327
return {
@@ -409,31 +409,3 @@ def check_risk_score_reasons_data(self, reasons):
409
409
self .assertEqual (
410
410
"Risk due to IP being an Anonymous IP" , reasons [0 ].reasons [0 ].reason
411
411
)
412
-
413
- def _remove_empty_values (self , data ):
414
- if isinstance (data , dict ):
415
- m = {}
416
- for k , v in data .items ():
417
- v = self ._remove_empty_values (v )
418
- if self ._is_not_empty (v ):
419
- m [k ] = v
420
- return m
421
-
422
- if isinstance (data , list ):
423
- ls = []
424
- for e in data :
425
- e = self ._remove_empty_values (e )
426
- if self ._is_not_empty (e ):
427
- ls .append (e )
428
- return ls
429
-
430
- return data
431
-
432
- def _is_not_empty (self , v ):
433
- if v is None :
434
- return False
435
- if isinstance (v , dict ) and not v :
436
- return False
437
- if isinstance (v , list ) and not v :
438
- return False
439
- return True
0 commit comments