mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-14 05:14:19 +00:00
* update uv.lock * fix tests and dependencies * fix test_fred_fetchers --------- Co-authored-by: deeleeramone <>
38 lines
1.0 KiB
Python
38 lines
1.0 KiB
Python
"""Shared fixtures for the FRED provider tests."""
|
|
|
|
import os
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.fixture(scope="session", autouse=True)
|
|
def fred_cache(tmp_path_factory):
|
|
"""Give the run its own FRED response cache, and empty it at the end."""
|
|
from openbb_fred.utils import cache
|
|
from openbb_fred.utils.rate_limiter import cache_clear
|
|
|
|
directory = tmp_path_factory.mktemp("fred-cache")
|
|
previous = os.environ.get("OPENBB_FRED_DISK_CACHE_DIR")
|
|
os.environ["OPENBB_FRED_DISK_CACHE_DIR"] = str(directory)
|
|
cache.close()
|
|
cache_clear()
|
|
|
|
yield cache
|
|
|
|
cache.clear()
|
|
cache.close()
|
|
cache_clear()
|
|
|
|
if previous is None:
|
|
os.environ.pop("OPENBB_FRED_DISK_CACHE_DIR", None)
|
|
else:
|
|
os.environ["OPENBB_FRED_DISK_CACHE_DIR"] = previous
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def no_request_spacing(monkeypatch):
|
|
"""Replay recorded requests without the live API's request spacing."""
|
|
from openbb_fred.utils import rate_limiter
|
|
|
|
monkeypatch.setattr(rate_limiter, "MIN_INTERVAL_SECONDS", 0.0)
|