From 92c23ec609ade6b3cc3c962149d1a86f9e6c2d32 Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Sun, 12 Jul 2026 12:22:12 +0900 Subject: [PATCH] chore: update tests to reflect get_app_path() changes --- pyproject.toml | 2 +- .../{ => api}/in_library_but_bad_path.vdf | 0 .../{ => api}/in_library_on_second_drive.vdf | 0 tests/fixtures/{ => api}/malformed.vdf | 0 tests/fixtures/{ => api}/not_in_library.vdf | 0 tests/test_pefile.py | 40 +++++++++++++------ 6 files changed, 28 insertions(+), 14 deletions(-) rename tests/fixtures/{ => api}/in_library_but_bad_path.vdf (100%) rename tests/fixtures/{ => api}/in_library_on_second_drive.vdf (100%) rename tests/fixtures/{ => api}/malformed.vdf (100%) rename tests/fixtures/{ => api}/not_in_library.vdf (100%) diff --git a/pyproject.toml b/pyproject.toml index 6c813ec..ebaca2d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -76,7 +76,7 @@ build-backend = "setuptools.build_meta" line-length = 88 indent-width = 4 extend-exclude = ["*lib/a2s"] -lint.unfixable = ["F401"] +lint.unfixable = ["F401", "I001"] [tool.ruff.format] quote-style = "double" diff --git a/tests/fixtures/in_library_but_bad_path.vdf b/tests/fixtures/api/in_library_but_bad_path.vdf similarity index 100% rename from tests/fixtures/in_library_but_bad_path.vdf rename to tests/fixtures/api/in_library_but_bad_path.vdf diff --git a/tests/fixtures/in_library_on_second_drive.vdf b/tests/fixtures/api/in_library_on_second_drive.vdf similarity index 100% rename from tests/fixtures/in_library_on_second_drive.vdf rename to tests/fixtures/api/in_library_on_second_drive.vdf diff --git a/tests/fixtures/malformed.vdf b/tests/fixtures/api/malformed.vdf similarity index 100% rename from tests/fixtures/malformed.vdf rename to tests/fixtures/api/malformed.vdf diff --git a/tests/fixtures/not_in_library.vdf b/tests/fixtures/api/not_in_library.vdf similarity index 100% rename from tests/fixtures/not_in_library.vdf rename to tests/fixtures/api/not_in_library.vdf diff --git a/tests/test_pefile.py b/tests/test_pefile.py index 6f02557..987888e 100644 --- a/tests/test_pefile.py +++ b/tests/test_pefile.py @@ -1,21 +1,22 @@ import pytest from pathlib import Path + import dzgui.api.pefile as PeFile -from dzgui.api.steam import VDFLoadError, AppNotInstalledError, AppMovedError, get_app_path +from dzgui.api.steam import ( + VDFLoadError, + AppNotInstalledError, + AppMovedError, + get_app_path +) from dzgui.config.query import get_config from dzgui.config.xdg import get_xdg_paths, parse_filepaths -from dzgui.const.constants import APPID_DAYZ +from dzgui.const.constants import APPID_DAYZ, LIBRARYFOLDERS_PATH from tests.fixtures import fixture_path -pytestmark = pytest.mark.pefile - - -@pytest.fixture -def second_drive(): - return fixture_path("in_library_on_second_drive.vdf") +pytestmark = pytest.mark.apitest @pytest.fixture @@ -26,6 +27,8 @@ def default_steam_path(): return conf["default_steam_path"] +# TODO: split into separate test file +# FIXME: use fixtures def test_pefile_length(default_steam_path): try: pe_file_path = PeFile.get_pefile_path(Path(default_steam_path), APPID_DAYZ) @@ -52,15 +55,26 @@ def test_invalid_pefile_path(): ("malformed.vdf", VDFLoadError), ], ) -def test_not_in_library(fixture, exception): - fixture = fixture_path(fixture) +def test_not_in_library(monkeypatch, fixture, exception): + import dzgui.api.steam as steam + monkeypatch.setattr(steam, "LIBRARYFOLDERS_PATH", fixture) + + folder_path = Path(fixture_path("api")) with pytest.raises(exception): try: - get_app_path(fixture, APPID_DAYZ) + get_app_path(folder_path, APPID_DAYZ) except Exception as e: raise e -def test_on_second_drive(second_drive): - path = get_app_path(second_drive, APPID_DAYZ) +@pytest.fixture +def second_drive(): + return "in_library_on_second_drive.vdf" + + +def test_on_second_drive(monkeypatch, second_drive): + import dzgui.api.steam as steam + monkeypatch.setattr(steam, "LIBRARYFOLDERS_PATH", second_drive) + folder_path = Path(fixture_path("api")) + path = get_app_path(folder_path, APPID_DAYZ) assert path == Path("/tmp")