diff options
author | Jordan Cook <jordan.cook@pioneer.com> | 2022-03-19 16:49:27 -0500 |
---|---|---|
committer | Jordan Cook <jordan.cook@pioneer.com> | 2022-03-29 12:17:43 -0500 |
commit | 2578cde2692714f1d74fcc20b47fd68d81295b51 (patch) | |
tree | ca2b41d3c171394eac0cf2ea009d19182193c9ce /tests/conftest.py | |
parent | b3646b03bc05f5b05f4384eb9a2b4796fa59cb34 (diff) | |
download | requests-cache-2578cde2692714f1d74fcc20b47fd68d81295b51.tar.gz |
Fix some regression bugs and broken tests
Diffstat (limited to 'tests/conftest.py')
-rw-r--r-- | tests/conftest.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/conftest.py b/tests/conftest.py index aa2cb33..a21b3fc 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -13,6 +13,7 @@ from datetime import datetime, timedelta from functools import wraps from logging import basicConfig, getLogger from os.path import abspath, dirname, join +from unittest.mock import MagicMock from uuid import uuid4 import pytest @@ -213,6 +214,21 @@ def get_mock_adapter() -> Adapter: return adapter +def get_mock_response( + method='GET', + url='https://img.site.com/base/img.jpg', + status_code=200, + headers={}, + request_headers={}, +): + return MagicMock( + url=url, + status_code=status_code, + headers=headers, + request=MagicMock(method=method, url=url, headers=request_headers), + ) + + def fail_if_no_connection(connect_timeout: float = 1.0) -> bool: """Decorator for testing a backend connection. This will intentionally cause a test failure if the wrapped function doesn't have dependencies installed, doesn't connect after a short timeout, |