Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions tests/test_tdx_provider_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from tests.test_tdx_source_request_adapter import (
EchoTqlexClient,
FakeTdxClient,
_expected_default_tdx_stats_cache_root,
_minimal_stat2_line,
_minimal_stat_line,
_stats_zip_bytes,
Expand Down Expand Up @@ -6769,9 +6770,7 @@ def test_tdx_provider_installed_from_wheel_is_discovered_and_can_route(
).stdout.strip()
for cwd in (first_cwd, second_cwd)
]
expected_cache = str(
(local_app_data / "AxData" / "cache" / "tdx" / "stats").resolve()
)
expected_cache = str(_expected_default_tdx_stats_cache_root(local_app_data))
assert cache_paths == [expected_cache, expected_cache]


Expand Down
18 changes: 17 additions & 1 deletion tests/test_tdx_source_request_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5515,6 +5515,22 @@ def test_tdx_stats_resource_reuses_parsed_resource_in_process(tmp_path):
assert second is first


def _expected_default_tdx_stats_cache_root(local_app_data: Path) -> Path:
"""Expected default TDX stats cache root for the current OS.

Mirrors ``axdata_source_tdx.stats_cache.user_tdx_stats_cache_root`` so the
assertion matches the running platform instead of assuming the Windows
``LOCALAPPDATA`` layout.
"""

if os.name == "nt":
return (local_app_data / "AxData" / "cache" / "tdx" / "stats").resolve()
if sys.platform == "darwin":
return (Path.home() / "Library" / "Caches" / "AxData" / "tdx" / "stats").resolve()
base = Path(os.getenv("XDG_CACHE_HOME") or (Path.home() / ".cache"))
return (base / "axdata" / "tdx" / "stats").resolve()


def test_tdx_direct_adapter_default_stats_cache_is_independent_of_cwd(monkeypatch, tmp_path):
from axdata_source_tdx.stats_cache import default_tdx_stats_cache_root

Expand All @@ -5532,7 +5548,7 @@ def test_tdx_direct_adapter_default_stats_cache_is_independent_of_cwd(monkeypatc
second = default_tdx_stats_cache_root()

assert first == second
assert first == (local_app_data / "AxData" / "cache" / "tdx" / "stats").resolve()
assert first == _expected_default_tdx_stats_cache_root(local_app_data)


def test_tdx_adapter_refreshes_stats_cache_older_than_previous_trade_date(monkeypatch, tmp_path):
Expand Down