@@ -218,7 +218,7 @@ def test_get_config_blocks(self):
218218 self .assertEqual (1 , round (end_time - start_time ))
219219
220220
221- @mock .patch ('requests.get' )
221+ @mock .patch ('requests.Session. get' )
222222class PollingConfigManagerTest (base .BaseTest ):
223223 def test_init__no_sdk_key_no_datafile__fails (self , _ ):
224224 """ Test that initialization fails if there is no sdk_key or datafile provided. """
@@ -379,7 +379,7 @@ def test_fetch_datafile(self, _):
379379 test_response .status_code = 200
380380 test_response .headers = test_headers
381381 test_response ._content = test_datafile
382- with mock .patch ('requests.get' , return_value = test_response ) as mock_request :
382+ with mock .patch ('requests.Session. get' , return_value = test_response ) as mock_request :
383383 project_config_manager = config_manager .PollingConfigManager (sdk_key = sdk_key )
384384 project_config_manager .stop ()
385385
@@ -392,7 +392,7 @@ def test_fetch_datafile(self, _):
392392 self .assertIsInstance (project_config_manager .get_config (), project_config .ProjectConfig )
393393
394394 # Call fetch_datafile again and assert that request to URL is with If-Modified-Since header.
395- with mock .patch ('requests.get' , return_value = test_response ) as mock_requests :
395+ with mock .patch ('requests.Session. get' , return_value = test_response ) as mock_requests :
396396 project_config_manager ._initialize_thread ()
397397 project_config_manager .start ()
398398 project_config_manager .stop ()
@@ -421,7 +421,7 @@ def raise_for_status(self):
421421 test_response .headers = test_headers
422422 test_response ._content = test_datafile
423423
424- with mock .patch ('requests.get' , return_value = test_response ) as mock_request :
424+ with mock .patch ('requests.Session. get' , return_value = test_response ) as mock_request :
425425 project_config_manager = config_manager .PollingConfigManager (sdk_key = sdk_key , logger = mock_logger )
426426 project_config_manager .stop ()
427427
@@ -434,7 +434,7 @@ def raise_for_status(self):
434434 self .assertIsInstance (project_config_manager .get_config (), project_config .ProjectConfig )
435435
436436 # Call fetch_datafile again, but raise exception this time
437- with mock .patch ('requests.get' , return_value = MockExceptionResponse ()) as mock_requests :
437+ with mock .patch ('requests.Session. get' , return_value = MockExceptionResponse ()) as mock_requests :
438438 project_config_manager ._initialize_thread ()
439439 project_config_manager .start ()
440440 project_config_manager .stop ()
@@ -462,7 +462,7 @@ def test_fetch_datafile__request_exception_raised(self, _):
462462 test_response .status_code = 200
463463 test_response .headers = test_headers
464464 test_response ._content = test_datafile
465- with mock .patch ('requests.get' , return_value = test_response ) as mock_request :
465+ with mock .patch ('requests.Session. get' , return_value = test_response ) as mock_request :
466466 project_config_manager = config_manager .PollingConfigManager (sdk_key = sdk_key , logger = mock_logger )
467467 project_config_manager .stop ()
468468
@@ -476,7 +476,7 @@ def test_fetch_datafile__request_exception_raised(self, _):
476476
477477 # Call fetch_datafile again, but raise exception this time
478478 with mock .patch (
479- 'requests.get' ,
479+ 'requests.Session. get' ,
480480 side_effect = requests .exceptions .RequestException ('Error Error !!' ),
481481 ) as mock_requests :
482482 project_config_manager ._initialize_thread ()
@@ -506,7 +506,7 @@ def test_fetch_datafile__exception_polling_thread_failed(self, _):
506506 test_response .headers = test_headers
507507 test_response ._content = test_datafile
508508
509- with mock .patch ('requests.get' , return_value = test_response ):
509+ with mock .patch ('requests.Session. get' , return_value = test_response ):
510510 project_config_manager = config_manager .PollingConfigManager (sdk_key = sdk_key ,
511511 logger = mock_logger ,
512512 update_interval = 12345678912345 )
@@ -529,7 +529,7 @@ def test_is_running(self, _):
529529 project_config_manager .stop ()
530530
531531
532- @mock .patch ('requests.get' )
532+ @mock .patch ('requests.Session. get' )
533533class AuthDatafilePollingConfigManagerTest (base .BaseTest ):
534534 def test_init__datafile_access_token_none__fails (self , _ ):
535535 """ Test that initialization fails if datafile_access_token is None. """
@@ -569,7 +569,7 @@ def test_fetch_datafile(self, _):
569569 test_response ._content = test_datafile
570570
571571 # Call fetch_datafile and assert that request was sent with correct authorization header
572- with mock .patch ('requests.get' ,
572+ with mock .patch ('requests.Session. get' ,
573573 return_value = test_response ) as mock_request :
574574 project_config_manager .fetch_datafile ()
575575
@@ -596,7 +596,7 @@ def test_fetch_datafile__request_exception_raised(self, _):
596596 test_response ._content = test_datafile
597597
598598 # Call fetch_datafile and assert that request was sent with correct authorization header
599- with mock .patch ('requests.get' , return_value = test_response ) as mock_request :
599+ with mock .patch ('requests.Session. get' , return_value = test_response ) as mock_request :
600600 project_config_manager = config_manager .AuthDatafilePollingConfigManager (
601601 datafile_access_token = datafile_access_token ,
602602 sdk_key = sdk_key ,
@@ -614,7 +614,7 @@ def test_fetch_datafile__request_exception_raised(self, _):
614614
615615 # Call fetch_datafile again, but raise exception this time
616616 with mock .patch (
617- 'requests.get' ,
617+ 'requests.Session. get' ,
618618 side_effect = requests .exceptions .RequestException ('Error Error !!' ),
619619 ) as mock_requests :
620620 project_config_manager ._initialize_thread ()
0 commit comments