Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul V Craven committed Feb 24, 2025
1 parent f4c8173 commit 8624e1e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions optimizely/config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ def fetch_datafile(self) -> None:

session.mount('http://', adapter)
session.mount("https://", adapter)
response = session.get(self.datafile_url, timeout=enums.ConfigManager.REQUEST_TIMEOUT)
response = session.get(self.datafile_url, headers=request_headers, timeout=enums.ConfigManager.REQUEST_TIMEOUT)
except requests_exceptions.RequestException as err:
self.logger.error(f'Fetching datafile from {self.datafile_url} failed. Error: {err}')
return
Expand Down Expand Up @@ -495,7 +495,7 @@ def fetch_datafile(self) -> None:

session.mount('http://', adapter)
session.mount("https://", adapter)
response = session.get(self.datafile_url, timeout=enums.ConfigManager.REQUEST_TIMEOUT)
response = session.get(self.datafile_url, headers=request_headers, timeout=enums.ConfigManager.REQUEST_TIMEOUT)
except requests_exceptions.RequestException as err:
self.logger.error(f'Fetching datafile from {self.datafile_url} failed. Error: {err}')
return
Expand Down
3 changes: 2 additions & 1 deletion tests/test_config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,9 @@ def test_fetch_datafile__exception_polling_thread_failed(self, _):
# verify the error log message
log_messages = [args[0] for args, _ in mock_logger.error.call_args_list]
for message in log_messages:
print(message)
if "Thread for background datafile polling failed. " \
"Error: timestamp too large to convert to C _PyTime_t" not in message:
"Error: timestamp too large to convert to C PyTime_t" not in message:
assert False

def test_is_running(self, _):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_event_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_dispatch_event__post_request(self):
}
event = event_builder.Event(url, params, http_verb='POST', headers={'Content-Type': 'application/json'})

with mock.patch('requests.post') as mock_request_post:
with mock.patch('requests.Session.post') as mock_request_post:
event_dispatcher.EventDispatcher.dispatch_event(event)

mock_request_post.assert_called_once_with(
Expand All @@ -69,7 +69,7 @@ def test_dispatch_event__handle_request_exception(self):
event = event_builder.Event(url, params, http_verb='POST', headers={'Content-Type': 'application/json'})

with mock.patch(
'requests.post', side_effect=request_exception.RequestException('Failed Request'),
'requests.Session.post', side_effect=request_exception.RequestException('Failed Request'),
) as mock_request_post, mock.patch('logging.error') as mock_log_error:
event_dispatcher.EventDispatcher.dispatch_event(event)

Expand Down

0 comments on commit 8624e1e

Please sign in to comment.