Skip to content

Commit

Permalink
Fix test coverage of adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
jplacht committed Nov 16, 2023
1 parent 0b54fe3 commit 4a87fd7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion fio_wrapper/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def cache_url_expirations(self) -> Dict[str, any]:
for url, expiration in self.data["cache"]["urls"].items():
# decide on potential values coming as int or str:
# int = take as seconds
if type(expiration) == int:
if isinstance(expiration, int):
expiration_list[url] = expiration
# NEVER_EXPIRE
elif expiration == "NEVER_EXPIRE":
Expand Down
7 changes: 7 additions & 0 deletions tests/config_cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cache:
enabled: true
default_expire: 10 # 10 seconds
urls:
"*/material/*": 3600
"*/exchange/all": NEVER_EXPIRE
"*/exchange/full": DO_NOT_CACHE
10 changes: 10 additions & 0 deletions tests/test_fio_adapter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import pytest
import importlib.util
from requests_cache import CachedSession
from fio_wrapper import FIO, EndpointNotImplemented
from fio_wrapper.exceptions import UnknownFIOResponse

Expand All @@ -13,6 +15,14 @@ def test_fio_adapter_version_notimplemented() -> None:
FIO(version="0.0.0")


def test_fio_adapter_requests_cache() -> None:
adapter = FIO(config="tests/config_cache.yml")

assert adapter.config.cache == True
assert importlib.util.find_spec("requests_cache") is not None
assert type(adapter.adapter._session) == CachedSession


def test_fio_adapter_blankinit() -> None:
adapter = FIO()

Expand Down

0 comments on commit 4a87fd7

Please sign in to comment.