From a30a1bf267ae3591d417876c37071f990ac1cc77 Mon Sep 17 00:00:00 2001 From: Ilya Priven Date: Sun, 26 May 2024 00:48:40 -0400 Subject: [PATCH] freeze time too --- requirements-dev.txt | 1 + tests/test_base_connection.py | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) 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'))