mirror of
https://github.com/aclist/dztui.git
synced 2026-10-25 12:12:31 +01:00
fix: handle alternate client versions when parsing vdf
This commit is contained in:
1 parent
bbaec35a5f
commit
6a30ed44fc
7 files changed
+112
-20
No files matched your search
+13
@@ -0,0 +1,13 @@
|
||||
"users"
|
||||
{
|
||||
"0"
|
||||
{
|
||||
"AccountName" "STEAMUSER"
|
||||
"PersonaName" "STEAMUSER"
|
||||
"RememberPassword" "0"
|
||||
"WantsOfflineMode" "0"
|
||||
"SkipOfflineModeWarning" "0"
|
||||
"AutoLogin" "1"
|
||||
"Timestamp" "0"
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
"users"
|
||||
{
|
||||
"0"
|
||||
{
|
||||
"AccountName" "STEAMUSER"
|
||||
"PersonaName" "STEAMUSER"
|
||||
"RememberPassword" "0"
|
||||
"WantsOfflineMode" "0"
|
||||
"SkipOfflineModeWarning" "0"
|
||||
"AllowAutoLogin" "1"
|
||||
"MostRecent" "1"
|
||||
"Timestamp" "0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
"users"
|
||||
{
|
||||
"0"
|
||||
{
|
||||
"AccountName" "STEAMUSER"
|
||||
"PersonaName" "STEAMUSER"
|
||||
"RememberPassword" "0"
|
||||
"WantsOfflineMode" "0"
|
||||
"SkipOfflineModeWarning" "0"
|
||||
"AllowAutoLogin" "1"
|
||||
"MostRecent" "0"
|
||||
"Timestamp" "0"
|
||||
}
|
||||
"1"
|
||||
{
|
||||
"AccountName" "STEAMUSER2"
|
||||
"PersonaName" "STEAMUSER2"
|
||||
"RememberPassword" "0"
|
||||
"WantsOfflineMode" "0"
|
||||
"SkipOfflineModeWarning" "0"
|
||||
"AllowAutoLogin" "1"
|
||||
"MostRecent" "1"
|
||||
"Timestamp" "0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import pytest
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from dzgui.api.steam import find_user_id
|
||||
from tests.fixtures import fixture_path
|
||||
|
||||
pytestmark = pytest.mark.apitest
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"fixture, expect",
|
||||
[
|
||||
("api/loginusers_legacy_client.vdf", 0),
|
||||
("api/loginusers_legacy_client_multiple.vdf", 1),
|
||||
("api/loginusers_beta_client.vdf", 0),
|
||||
],
|
||||
)
|
||||
def test_loginusers(monkeypatch, fixture: str, expect: int) -> None:
|
||||
def mock_loginusers(path: Path) -> Path:
|
||||
return fixture_path(fixture)
|
||||
|
||||
monkeypatch.setattr("dzgui.api.steam.find_loginusers", mock_loginusers)
|
||||
uid = find_user_id(Path(""))
|
||||
assert int(uid) == expect
|
||||
@@ -30,9 +30,9 @@ def test_no_shortcuts(monkeypatch) -> None:
|
||||
@pytest.fixture
|
||||
def dummy_app() -> None:
|
||||
d = {
|
||||
"appname": "TEST APP",
|
||||
"AppName": "TEST APP",
|
||||
"StartDir": "TEST_DIR",
|
||||
"exe": "TEST_DIR/TEST_EXE.EXE",
|
||||
"Exe": "TEST_DIR/TEST_EXE.EXE",
|
||||
"icon": "IMAGES_DIR/TEST_IMAGE.PNG",
|
||||
}
|
||||
return d
|
||||
@@ -41,8 +41,8 @@ def dummy_app() -> None:
|
||||
def test_wrap_exe(dummy_app) -> None:
|
||||
s = Shortcuts(Path(""))
|
||||
s.add_shortcut(*dummy_app.values())
|
||||
assert s.shortcuts["shortcuts"]["0"]["exe"][0] == '"'
|
||||
assert s.shortcuts["shortcuts"]["0"]["exe"][-1] == '"'
|
||||
assert s.shortcuts["shortcuts"]["0"]["Exe"][0] == '"'
|
||||
assert s.shortcuts["shortcuts"]["0"]["Exe"][-1] == '"'
|
||||
|
||||
|
||||
def test_add_shortcut(dummy_app) -> None:
|
||||
@@ -51,7 +51,7 @@ def test_add_shortcut(dummy_app) -> None:
|
||||
new = s.shortcuts["shortcuts"]
|
||||
ind = str(len(new) - 1)
|
||||
for k, v in dummy_app.items():
|
||||
if k == "exe":
|
||||
if k == "Exe":
|
||||
v = f'"{v}"'
|
||||
assert new[ind][k] == v
|
||||
|
||||
|
||||
Reference in new issue
Block a user