diff options
author | Jordan Cook <jordan.cook@pioneer.com> | 2022-04-20 13:37:56 -0500 |
---|---|---|
committer | Jordan Cook <jordan.cook@pioneer.com> | 2022-04-20 14:32:31 -0500 |
commit | ca12fbb97b65ba22199acbb6a41efbcd67082cc5 (patch) | |
tree | 51094d81773981fd925ab7bb70fae78c5d86640e /requests_cache | |
parent | d6c5fcfaaa312ccd5b2e65db7338b9d83a9b5ea5 (diff) | |
download | requests-cache-ca12fbb97b65ba22199acbb6a41efbcd67082cc5.tar.gz |
Add misc missing test coverage
Diffstat (limited to 'requests_cache')
-rw-r--r-- | requests_cache/_utils.py | 3 | ||||
-rw-r--r-- | requests_cache/backends/sqlite.py | 6 | ||||
-rw-r--r-- | requests_cache/cache_keys.py | 5 | ||||
-rw-r--r-- | requests_cache/models/raw_response.py | 2 |
4 files changed, 5 insertions, 11 deletions
diff --git a/requests_cache/_utils.py b/requests_cache/_utils.py index a57f4ea..c5b5a28 100644 --- a/requests_cache/_utils.py +++ b/requests_cache/_utils.py @@ -45,9 +45,6 @@ def get_placeholder_class(original_exception: Exception = None): def __init__(self, *args, **kwargs): _log_error() - def __getattr__(self, *args, **kwargs): - _log_error() - def dumps(self, *args, **kwargs): _log_error() diff --git a/requests_cache/backends/sqlite.py b/requests_cache/backends/sqlite.py index 43a0485..eb9b712 100644 --- a/requests_cache/backends/sqlite.py +++ b/requests_cache/backends/sqlite.py @@ -13,7 +13,7 @@ from os import unlink from os.path import isfile from pathlib import Path from tempfile import gettempdir -from typing import Collection, Iterable, Iterator, List, Tuple, Type, Union +from typing import Collection, Iterator, List, Tuple, Type, Union from platformdirs import user_cache_dir @@ -319,9 +319,7 @@ class SQLitePickleDict(SQLiteDict): def _format_sequence(values: Collection) -> Tuple[str, List]: - """Get SQL parameter marks for a sequence-based query, and ensure value is a sequence""" - if not isinstance(values, Iterable): - values = [values] + """Get SQL parameter marks for a sequence-based query""" return ','.join(['?'] * len(values)), list(values) diff --git a/requests_cache/cache_keys.py b/requests_cache/cache_keys.py index 71606fe..d551979 100644 --- a/requests_cache/cache_keys.py +++ b/requests_cache/cache_keys.py @@ -159,8 +159,7 @@ def normalize_json_body( original_body: Union[str, bytes], ignored_parameters: ParamList ) -> Union[str, bytes]: """Normalize and filter a request body with serialized JSON data""" - - if len(original_body) == 0 or len(original_body) > MAX_NORM_BODY_SIZE: + if len(original_body) <= 2 or len(original_body) > MAX_NORM_BODY_SIZE: return original_body try: @@ -169,7 +168,7 @@ def normalize_json_body( return json.dumps(body) # If it's invalid JSON, then don't mess with it except (AttributeError, TypeError, ValueError): - logger.debug('Invalid JSON body:', exc_info=True) + logger.debug('Invalid JSON body') return original_body diff --git a/requests_cache/models/raw_response.py b/requests_cache/models/raw_response.py index 27f871f..9c01b88 100644 --- a/requests_cache/models/raw_response.py +++ b/requests_cache/models/raw_response.py @@ -75,7 +75,7 @@ class CachedHTTPResponse(HTTPResponse, RichMixin): :py:meth:`urllib3.response.HTTPResponse.read()` """ if 'content-encoding' in self.headers and decode_content is False: - logger.warning('read() returns decoded data, even with decode_content=False') + logger.warning('read(decode_content=False) is not supported for cached responses') data = self._fp.read(amt) # "close" the file to inform consumers to stop reading from it |