mirror of
https://github.com/aclist/dztui.git
synced 2026-11-01 15:42:51 +01:00
chore: add tests for mod signatures
Mirror to Codeberg / mirror-to-codeberg (push) Has been cancelled
Mirror to Codeberg / mirror-to-codeberg (push) Has been cancelled
This commit is contained in:
1 parent
525dc24508
commit
0653f064b2
2 files changed
+60
No files matched your search
Vendored
+8
@@ -0,0 +1,8 @@
|
|||||||
|
1559212036,1771519119
|
||||||
|
1564026768,1770917948
|
||||||
|
2545327648,1780174455
|
||||||
|
2276010135,1756744083
|
||||||
|
1654462998,1780501511
|
||||||
|
3410710885,1752864732
|
||||||
|
2918418331,1780413260
|
||||||
|
3739934289,1780855136
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import pytest
|
||||||
|
import shutil
|
||||||
|
import tempfile
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
import dzgui.api.mods
|
||||||
|
import dzgui.config.query
|
||||||
|
|
||||||
|
from tests.fixtures import fixture_path
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from dzgui.const.enums import Preferences
|
||||||
|
|
||||||
|
pytestmark = pytest.mark.mods
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def versions() -> str:
|
||||||
|
return fixture_path("dzg.versions")
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def tmp() -> str:
|
||||||
|
with tempfile.NamedTemporaryFile(delete=False) as f:
|
||||||
|
tmp = f.name
|
||||||
|
return tmp
|
||||||
|
|
||||||
|
def mock_local_ids(path: Path) -> list[int]:
|
||||||
|
return [3410710885, 3739934289]
|
||||||
|
|
||||||
|
def mock_lookup(path: Path, prefs: "Preferences") -> str:
|
||||||
|
return ""
|
||||||
|
|
||||||
|
def test_signatures(monkeypatch, tmp: str, versions: str) -> None:
|
||||||
|
ids = [1559212036, 1654462998]
|
||||||
|
shutil.copyfile(versions, tmp)
|
||||||
|
path = Path(tmp)
|
||||||
|
monkeypatch.setattr("dzgui.api.mods.lookup", mock_lookup)
|
||||||
|
dzgui.api.mods.remove_stale_signatures(path, path, ids)
|
||||||
|
with open(tmp, "r") as f:
|
||||||
|
lines = f.readlines()
|
||||||
|
assert ids not in lines
|
||||||
|
|
||||||
|
def test_signatures_with_no_ids(monkeypatch, tmp: str, versions: str) -> None:
|
||||||
|
shutil.copyfile(versions, tmp)
|
||||||
|
path = Path(tmp)
|
||||||
|
monkeypatch.setattr("dzgui.api.mods.get_local_mod_ids", mock_local_ids)
|
||||||
|
monkeypatch.setattr("dzgui.api.mods.lookup", mock_lookup)
|
||||||
|
dzgui.api.mods.remove_stale_signatures(path, path)
|
||||||
|
with open(tmp, "r") as f:
|
||||||
|
lines = f.readlines()
|
||||||
|
assert lines == ["3410710885,1752864732\n", "3739934289,1780855136\n"]
|
||||||
Reference in new issue
Block a user