diff --git a/requirements-dev.txt b/requirements-dev.txt index 05660865..f0da32c3 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,6 +1,7 @@ pytest>=6 pytest-env pytest-mock +freezegun # only used in CI coveralls diff --git a/tests/test_base_connection.py b/tests/test_base_connection.py index 0510374a..23112759 100644 --- a/tests/test_base_connection.py +++ b/tests/test_base_connection.py @@ -3,6 +3,7 @@ """ import base64 import json +from datetime import datetime from uuid import UUID import urllib3 @@ -15,6 +16,7 @@ from botocore.exceptions import BotoCoreError import pytest +from freezegun import freeze_time from pynamodb.connection import Connection from pynamodb.connection.base import MetaTable @@ -1517,11 +1519,10 @@ def test_connection__botocore_config(): assert c.client._client_config.max_pool_connections == 20 -@mock.patch('botocore.httpsession.URLLib3Session.send') -def test_connection_make_api_call___extra_headers(send_mock, mocker): +@freeze_time() +def test_connection_make_api_call___extra_headers(mocker): good_response = mock.Mock(spec=AWSResponse, status_code=200, headers={}, text='{}', content=b'{}') - - send_mock.return_value = good_response + send_mock = mocker.patch('botocore.httpsession.URLLib3Session.send', return_value=good_response) # return constant UUID mocker.patch('uuid.uuid4', return_value=UUID('01FC4BDB-B223-4B86-88F4-DEE79B77F275'))