44import unittest
55import warnings
66from decimal import Decimal
7+ from requests .auth import HTTPBasicAuth
78
89import mock
910import requests .exceptions
@@ -342,9 +343,10 @@ def test_score_ok(self):
342343 response = self .sift_client .score ('12345' )
343344 mock_get .assert_called_with (
344345 'https://api.siftscience.com/v205/score/12345' ,
345- params = {'api_key' : self . test_key },
346+ params = {},
346347 headers = mock .ANY ,
347- timeout = mock .ANY )
348+ timeout = mock .ANY ,
349+ auth = HTTPBasicAuth (self .test_key , '' ))
348350 self .assertIsInstance (response , sift .client .Response )
349351 assert (response .is_ok ())
350352 assert (response .api_error_message == "OK" )
@@ -364,9 +366,10 @@ def test_score_with_timeout_param_ok(self):
364366 response = self .sift_client .score ('12345' , test_timeout )
365367 mock_get .assert_called_with (
366368 'https://api.siftscience.com/v205/score/12345' ,
367- params = {'api_key' : self . test_key },
369+ params = {},
368370 headers = mock .ANY ,
369- timeout = test_timeout )
371+ timeout = test_timeout ,
372+ auth = HTTPBasicAuth (self .test_key , '' ))
370373 self .assertIsInstance (response , sift .client .Response )
371374 assert (response .is_ok ())
372375 assert (response .api_error_message == "OK" )
@@ -388,9 +391,10 @@ def test_get_user_score_ok(self):
388391 response = self .sift_client .get_user_score ('12345' , test_timeout )
389392 mock_get .assert_called_with (
390393 'https://api.siftscience.com/v205/users/12345/score' ,
391- params = {'api_key' : self . test_key },
394+ params = {},
392395 headers = mock .ANY ,
393- timeout = test_timeout )
396+ timeout = test_timeout ,
397+ auth = HTTPBasicAuth (self .test_key , '' ))
394398 self .assertIsInstance (response , sift .client .Response )
395399 assert (response .is_ok ())
396400 assert (response .api_error_message == "OK" )
@@ -415,9 +419,10 @@ def test_get_user_score_with_abuse_types_ok(self):
415419 timeout = test_timeout )
416420 mock_get .assert_called_with (
417421 'https://api.siftscience.com/v205/users/12345/score' ,
418- params = {'api_key' : self . test_key , ' abuse_types' : 'payment_abuse,content_abuse' },
422+ params = {'abuse_types' : 'payment_abuse,content_abuse' },
419423 headers = mock .ANY ,
420- timeout = test_timeout )
424+ timeout = test_timeout ,
425+ auth = HTTPBasicAuth (self .test_key , '' ))
421426 self .assertIsInstance (response , sift .client .Response )
422427 assert (response .is_ok ())
423428 assert (response .api_error_message == "OK" )
@@ -440,9 +445,10 @@ def test_rescore_user_ok(self):
440445 response = self .sift_client .rescore_user ('12345' , test_timeout )
441446 mock_post .assert_called_with (
442447 'https://api.siftscience.com/v205/users/12345/score' ,
443- params = {'api_key' : self . test_key },
448+ params = {},
444449 headers = mock .ANY ,
445- timeout = test_timeout )
450+ timeout = test_timeout ,
451+ auth = HTTPBasicAuth (self .test_key , '' ))
446452 self .assertIsInstance (response , sift .client .Response )
447453 assert (response .is_ok ())
448454 assert (response .api_error_message == "OK" )
@@ -467,9 +473,10 @@ def test_rescore_user_with_abuse_types_ok(self):
467473 timeout = test_timeout )
468474 mock_post .assert_called_with (
469475 'https://api.siftscience.com/v205/users/12345/score' ,
470- params = {'api_key' : self . test_key , ' abuse_types' : 'payment_abuse,content_abuse' },
476+ params = {'abuse_types' : 'payment_abuse,content_abuse' },
471477 headers = mock .ANY ,
472- timeout = test_timeout )
478+ timeout = test_timeout ,
479+ auth = HTTPBasicAuth (self .test_key , '' ))
473480 self .assertIsInstance (response , sift .client .Response )
474481 assert (response .is_ok ())
475482 assert (response .api_error_message == "OK" )
@@ -968,7 +975,8 @@ def test_unlabel_user_ok(self):
968975 'https://api.siftscience.com/v205/users/%s/labels' % user_id ,
969976 headers = mock .ANY ,
970977 timeout = mock .ANY ,
971- params = {'api_key' : self .test_key , 'abuse_type' : 'account_abuse' })
978+ params = {'abuse_type' : 'account_abuse' },
979+ auth = HTTPBasicAuth (self .test_key , '' ))
972980 self .assertIsInstance (response , sift .client .Response )
973981 assert (response .is_ok ())
974982
@@ -1008,7 +1016,8 @@ def test_unlabel_user_with_special_chars_ok(self):
10081016 'https://api.siftscience.com/v205/users/%s/labels' % urllib .parse .quote (user_id ),
10091017 headers = mock .ANY ,
10101018 timeout = mock .ANY ,
1011- params = {'api_key' : self .test_key })
1019+ params = {},
1020+ auth = HTTPBasicAuth (self .test_key , '' ))
10121021 self .assertIsInstance (response , sift .client .Response )
10131022 assert (response .is_ok ())
10141023
@@ -1055,9 +1064,10 @@ def test_score__with_special_user_id_chars_ok(self):
10551064 response = self .sift_client .score (user_id , abuse_types = ['legacy' ])
10561065 mock_get .assert_called_with (
10571066 'https://api.siftscience.com/v205/score/%s' % urllib .parse .quote (user_id ),
1058- params = {'api_key' : self . test_key , ' abuse_types' : 'legacy' },
1067+ params = {'abuse_types' : 'legacy' },
10591068 headers = mock .ANY ,
1060- timeout = mock .ANY )
1069+ timeout = mock .ANY ,
1070+ auth = HTTPBasicAuth (self .test_key , '' ))
10611071 self .assertIsInstance (response , sift .client .Response )
10621072 assert (response .is_ok ())
10631073 assert (response .api_error_message == "OK" )
@@ -1464,9 +1474,10 @@ def test_score_api_include_score_percentiles_ok(self):
14641474 response = self .sift_client .score (user_id = '12345' , include_score_percentiles = True )
14651475 mock_get .assert_called_with (
14661476 'https://api.siftscience.com/v205/score/12345' ,
1467- params = {'api_key' : self . test_key , ' fields' : 'SCORE_PERCENTILES' },
1477+ params = {'fields' : 'SCORE_PERCENTILES' },
14681478 headers = mock .ANY ,
1469- timeout = mock .ANY )
1479+ timeout = mock .ANY ,
1480+ auth = HTTPBasicAuth (self .test_key , '' ))
14701481 self .assertIsInstance (response , sift .client .Response )
14711482 assert (response .is_ok ())
14721483 assert (response .api_error_message == "OK" )
@@ -1488,9 +1499,10 @@ def test_get_user_score_include_score_percentiles_ok(self):
14881499 response = self .sift_client .get_user_score (user_id = '12345' , timeout = test_timeout , include_score_percentiles = True )
14891500 mock_get .assert_called_with (
14901501 'https://api.siftscience.com/v205/users/12345/score' ,
1491- params = {'api_key' : self . test_key , ' fields' : 'SCORE_PERCENTILES' },
1502+ params = {'fields' : 'SCORE_PERCENTILES' },
14921503 headers = mock .ANY ,
1493- timeout = test_timeout )
1504+ timeout = test_timeout ,
1505+ auth = HTTPBasicAuth (self .test_key , '' ))
14941506 self .assertIsInstance (response , sift .client .Response )
14951507 assert (response .is_ok ())
14961508 assert (response .api_error_message == "OK" )
0 commit comments