@@ -425,77 +425,59 @@ class Test_BaseAuthSession:
425425 provided by BaseAuthSession.
426426 """
427427
428- def test_update_args_kwargs_error (self , mock_fetch , mock_refresh ):
429- auth = authenticate .ClientSession ("my_client_id" , "my_client_secret" )
430-
431- args = ()
432- kwargs = {"something" : 1 }
433-
434- with pytest .raises (KeyError ):
435- auth ._update_args_kwargs (args , kwargs )
436-
437- def test_update_args_kwargs_args_none (self , mock_fetch , mock_refresh ):
428+ @patch ("fourinsight.api.authenticate.OAuth2Session.request" )
429+ def test_request_check_default (self , mock_request , mock_fetch , mock_refresh ):
438430 auth = authenticate .ClientSession ("my_client_id" , "my_client_secret" )
431+ args = ("https://api.4insight.io/v1.0/Campaigns" ,)
432+ kwargs = {
433+ "other" : "thing" ,
434+ }
439435
440- args = ()
441- kwargs = {"method" : "GET" , "url" : "/v1.0/ding/dong" , "other" : "thing" }
442-
443- args_out , kwargs_out = auth ._update_args_kwargs (args , kwargs )
436+ auth .get (* args , ** kwargs )
444437
445- assert (
446- args
447- + (
448- "GET" ,
449- auth ._api_base_url + "/v1.0/ding/dong" ,
450- )
451- == args_out
438+ mock_request .assert_called_with (
439+ "GET" ,
440+ "https://api.4insight.io/v1.0/Campaigns" ,
441+ other = "thing" ,
442+ allow_redirects = True ,
443+ timeout = auth ._defaults ["timeout" ],
452444 )
453- assert {"timeout" : auth ._defaults ["timeout" ], "other" : "thing" } == kwargs_out
454-
455- def test_update_args_kwargs_args_len_1 (self , mock_fetch , mock_refresh ):
456- auth = authenticate .ClientSession ("my_client_id" , "my_client_secret" )
457-
458- args = ("get" ,)
459- kwargs = {"url" : "/v1.0/ding/dong" , "other" : "thing" }
460445
461- args_out , kwargs_out = auth ._update_args_kwargs (args , kwargs )
462-
463- assert args + (auth ._api_base_url + "/v1.0/ding/dong" ,) == args_out
464- assert {"timeout" : auth ._defaults ["timeout" ], "other" : "thing" } == kwargs_out
465-
466- def test_update_args_kwargs_args (self , mock_fetch , mock_refresh ):
467- auth = authenticate .ClientSession ("my_client_id" , "my_client_secret" )
468-
469- args = ("get" , "/v1.0/ding/dong" )
470- kwargs = {"other" : "thing" }
471-
472- args_out , kwargs_out = auth ._update_args_kwargs (args , kwargs )
473-
474- assert args [:1 ] + (auth ._api_base_url + "/v1.0/ding/dong" ,) == args_out
475- assert {"timeout" : auth ._defaults ["timeout" ], "other" : "thing" } == kwargs_out
476-
477- def test_update_args_kwargs_args_long (self , mock_fetch , mock_refresh ):
446+ @patch ("fourinsight.api.authenticate.OAuth2Session.request" )
447+ def test_request_args (self , mock_request , mock_fetch , mock_refresh ):
478448 auth = authenticate .ClientSession ("my_client_id" , "my_client_secret" )
479-
480- args = ("get" , "/v1.0/ding/dong" , "something" )
449+ args = ("https://api.4insight.io/v1.0/Campaigns" ,)
481450 kwargs = {"other" : "thing" }
482451
483- args_out , kwargs_out = auth ._update_args_kwargs ( args , kwargs )
452+ auth .get ( * args , ** kwargs )
484453
485- assert (
486- args [:1 ] + (auth ._api_base_url + "/v1.0/ding/dong" ,) + args [2 :] == args_out
454+ mock_request .assert_called_with (
455+ "GET" ,
456+ "https://api.4insight.io/v1.0/Campaigns" ,
457+ other = "thing" ,
458+ allow_redirects = True ,
459+ ** auth ._defaults ,
487460 )
488- assert {"timeout" : auth ._defaults ["timeout" ], "other" : "thing" } == kwargs_out
489461
490462 @patch ("fourinsight.api.authenticate.OAuth2Session.request" )
491- def test_request_relative_path (self , mock_request , mock_fetch , mock_refresh ):
463+ def test_request_args_none (self , mock_request , mock_fetch , mock_refresh ):
492464 auth = authenticate .ClientSession ("my_client_id" , "my_client_secret" )
493- args = ("/v1.0/ding/dong" ,)
465+ args = ()
466+ kwargs = {
467+ "url" : "https://api.4insight.io/v1.0/Campaigns" ,
468+ "other" : "thing" ,
469+ "another" : "one" ,
470+ }
494471
495- auth .get (* args )
472+ auth .get (* args , ** kwargs )
496473
497474 mock_request .assert_called_with (
498- "GET" , auth ._api_base_url + args [0 ], allow_redirects = True , ** auth ._defaults
475+ "GET" ,
476+ "https://api.4insight.io/v1.0/Campaigns" ,
477+ other = "thing" ,
478+ another = "one" ,
479+ allow_redirects = True ,
480+ ** auth ._defaults ,
499481 )
500482
501483 @patch ("fourinsight.api.authenticate.OAuth2Session.request" )
0 commit comments