@@ -218,7 +218,7 @@ def test_get_config_blocks(self):
218
218
self .assertEqual (1 , round (end_time - start_time ))
219
219
220
220
221
- @mock .patch ('requests.get' )
221
+ @mock .patch ('requests.Session. get' )
222
222
class PollingConfigManagerTest (base .BaseTest ):
223
223
def test_init__no_sdk_key_no_datafile__fails (self , _ ):
224
224
""" Test that initialization fails if there is no sdk_key or datafile provided. """
@@ -379,7 +379,7 @@ def test_fetch_datafile(self, _):
379
379
test_response .status_code = 200
380
380
test_response .headers = test_headers
381
381
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 :
383
383
project_config_manager = config_manager .PollingConfigManager (sdk_key = sdk_key )
384
384
project_config_manager .stop ()
385
385
@@ -392,7 +392,7 @@ def test_fetch_datafile(self, _):
392
392
self .assertIsInstance (project_config_manager .get_config (), project_config .ProjectConfig )
393
393
394
394
# 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 :
396
396
project_config_manager ._initialize_thread ()
397
397
project_config_manager .start ()
398
398
project_config_manager .stop ()
@@ -421,7 +421,7 @@ def raise_for_status(self):
421
421
test_response .headers = test_headers
422
422
test_response ._content = test_datafile
423
423
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 :
425
425
project_config_manager = config_manager .PollingConfigManager (sdk_key = sdk_key , logger = mock_logger )
426
426
project_config_manager .stop ()
427
427
@@ -434,7 +434,7 @@ def raise_for_status(self):
434
434
self .assertIsInstance (project_config_manager .get_config (), project_config .ProjectConfig )
435
435
436
436
# 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 :
438
438
project_config_manager ._initialize_thread ()
439
439
project_config_manager .start ()
440
440
project_config_manager .stop ()
@@ -462,7 +462,7 @@ def test_fetch_datafile__request_exception_raised(self, _):
462
462
test_response .status_code = 200
463
463
test_response .headers = test_headers
464
464
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 :
466
466
project_config_manager = config_manager .PollingConfigManager (sdk_key = sdk_key , logger = mock_logger )
467
467
project_config_manager .stop ()
468
468
@@ -476,7 +476,7 @@ def test_fetch_datafile__request_exception_raised(self, _):
476
476
477
477
# Call fetch_datafile again, but raise exception this time
478
478
with mock .patch (
479
- 'requests.get' ,
479
+ 'requests.Session. get' ,
480
480
side_effect = requests .exceptions .RequestException ('Error Error !!' ),
481
481
) as mock_requests :
482
482
project_config_manager ._initialize_thread ()
@@ -506,7 +506,7 @@ def test_fetch_datafile__exception_polling_thread_failed(self, _):
506
506
test_response .headers = test_headers
507
507
test_response ._content = test_datafile
508
508
509
- with mock .patch ('requests.get' , return_value = test_response ):
509
+ with mock .patch ('requests.Session. get' , return_value = test_response ):
510
510
project_config_manager = config_manager .PollingConfigManager (sdk_key = sdk_key ,
511
511
logger = mock_logger ,
512
512
update_interval = 12345678912345 )
@@ -529,7 +529,7 @@ def test_is_running(self, _):
529
529
project_config_manager .stop ()
530
530
531
531
532
- @mock .patch ('requests.get' )
532
+ @mock .patch ('requests.Session. get' )
533
533
class AuthDatafilePollingConfigManagerTest (base .BaseTest ):
534
534
def test_init__datafile_access_token_none__fails (self , _ ):
535
535
""" Test that initialization fails if datafile_access_token is None. """
@@ -569,7 +569,7 @@ def test_fetch_datafile(self, _):
569
569
test_response ._content = test_datafile
570
570
571
571
# 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' ,
573
573
return_value = test_response ) as mock_request :
574
574
project_config_manager .fetch_datafile ()
575
575
@@ -596,7 +596,7 @@ def test_fetch_datafile__request_exception_raised(self, _):
596
596
test_response ._content = test_datafile
597
597
598
598
# 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 :
600
600
project_config_manager = config_manager .AuthDatafilePollingConfigManager (
601
601
datafile_access_token = datafile_access_token ,
602
602
sdk_key = sdk_key ,
@@ -614,7 +614,7 @@ def test_fetch_datafile__request_exception_raised(self, _):
614
614
615
615
# Call fetch_datafile again, but raise exception this time
616
616
with mock .patch (
617
- 'requests.get' ,
617
+ 'requests.Session. get' ,
618
618
side_effect = requests .exceptions .RequestException ('Error Error !!' ),
619
619
) as mock_requests :
620
620
project_config_manager ._initialize_thread ()
0 commit comments