@@ -494,6 +494,32 @@ def test_fetch_datafile__request_exception_raised(self, _):
494494 self .assertEqual (test_headers ['Last-Modified' ], project_config_manager .last_modified )
495495 self .assertIsInstance (project_config_manager .get_config (), project_config .ProjectConfig )
496496
497+ def test_fetch_datafile__exception_polling_thread_failed (self , _ ):
498+ """ Test that exception is raised when polling thread stops. """
499+ sdk_key = 'some_key'
500+ mock_logger = mock .Mock ()
501+
502+ test_headers = {'Last-Modified' : 'New Time' }
503+ test_datafile = json .dumps (self .config_dict_with_features )
504+ test_response = requests .Response ()
505+ test_response .status_code = 200
506+ test_response .headers = test_headers
507+ test_response ._content = test_datafile
508+
509+ with mock .patch ('requests.get' , return_value = test_response ):
510+ project_config_manager = config_manager .PollingConfigManager (sdk_key = sdk_key ,
511+ logger = mock_logger ,
512+ update_interval = 12345678912345 )
513+
514+ project_config_manager .stop ()
515+
516+ # verify the error log message
517+ log_messages = [args [0 ] for args , _ in mock_logger .error .call_args_list ]
518+ for message in log_messages :
519+ if "Thread for background datafile polling failed. " \
520+ "Error: timestamp too large to convert to C _PyTime_t" not in message :
521+ assert False
522+
497523 def test_is_running (self , _ ):
498524 """ Test that polling thread is running after instance of PollingConfigManager is created. """
499525 with mock .patch ('optimizely.config_manager.PollingConfigManager.fetch_datafile' ):
0 commit comments