mirror of
https://github.com/aclist/dztui.git
synced 2026-08-29 19:27:13 +02:00
Merge pull request #376 from aclist/fix/missing-config-key
fix: missing config key
This commit is contained in:
commit
e056ac924a
@ -10,7 +10,6 @@ from shlex import shlex
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from dzgui.init.prereqs import has_steam_client
|
from dzgui.init.prereqs import has_steam_client
|
||||||
from dzgui.api.mods import _hash
|
|
||||||
from dzgui.const.constants import (
|
from dzgui.const.constants import (
|
||||||
APPID_DAYZ,
|
APPID_DAYZ,
|
||||||
APP_NAME,
|
APP_NAME,
|
||||||
@ -58,6 +57,9 @@ def get_steam_paths() -> list[tuple[Path, str]]:
|
|||||||
|
|
||||||
|
|
||||||
def concat_mods(mods: list[str]) -> str:
|
def concat_mods(mods: list[str]) -> str:
|
||||||
|
# TODO: circular import workaround
|
||||||
|
from dzgui.api.mods import _hash
|
||||||
|
|
||||||
hashes = []
|
hashes = []
|
||||||
for mod in mods:
|
for mod in mods:
|
||||||
md5sum = _hash(mod)
|
md5sum = _hash(mod)
|
||||||
|
|||||||
@ -3,6 +3,8 @@ import shlex
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
from dzgui.const.boilerplate import config_boilerplate
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Convert legacy dztuirc to config.json
|
Convert legacy dztuirc to config.json
|
||||||
@ -89,4 +91,8 @@ def rc2json(file: Path) -> str:
|
|||||||
keys["ip_list"] = ips
|
keys["ip_list"] = ips
|
||||||
keys["use_miles"] = False
|
keys["use_miles"] = False
|
||||||
keys["start_tab"] = 0
|
keys["start_tab"] = 0
|
||||||
|
# NOTE: workaround for DZGUI 6 logic (see #375)
|
||||||
|
for key in config_boilerplate.keys():
|
||||||
|
if key not in keys:
|
||||||
|
keys[key] = config_boilerplate[key]
|
||||||
return json.dumps(keys, indent=2)
|
return json.dumps(keys, indent=2)
|
||||||
|
|||||||
@ -107,6 +107,7 @@ config-settings-package = { pygobject-stubs = { config = "Gtk3,Gdk3,Soup2" } }
|
|||||||
[tool.pytest.ini_options]
|
[tool.pytest.ini_options]
|
||||||
markers = [
|
markers = [
|
||||||
"config: config file keys/values",
|
"config: config file keys/values",
|
||||||
|
"mods: tests mod metadata/link creation",
|
||||||
"pefile: validate PE files",
|
"pefile: validate PE files",
|
||||||
"post_install: requires a completed installation",
|
"post_install: requires a completed installation",
|
||||||
"slow: long-running tests",
|
"slow: long-running tests",
|
||||||
|
|||||||
3
tests/fixtures/cpp/test.py
vendored
3
tests/fixtures/cpp/test.py
vendored
@ -1,3 +0,0 @@
|
|||||||
from dzgui.api.mods import tokenize
|
|
||||||
|
|
||||||
print(tokenize("meta4.cpp"))
|
|
||||||
42
tests/fixtures/dztuirc_3
vendored
Normal file
42
tests/fixtures/dztuirc_3
vendored
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
#Path to DayZ installation
|
||||||
|
steam_path="/tmp"
|
||||||
|
|
||||||
|
#Battlemetrics API key
|
||||||
|
api_key=""
|
||||||
|
|
||||||
|
#Favorited server IP:PORT array
|
||||||
|
ip_list=(
|
||||||
|
)
|
||||||
|
|
||||||
|
#Favorite server to fast-connect to (limit one)
|
||||||
|
fav_server=""
|
||||||
|
|
||||||
|
#Favorite server label (human readable)
|
||||||
|
fav_label=""
|
||||||
|
|
||||||
|
#Custom player name (optional, required by some servers)
|
||||||
|
name=""
|
||||||
|
|
||||||
|
#Set to 1 to perform dry-run and print launch options
|
||||||
|
debug="1"
|
||||||
|
|
||||||
|
#Toggle stable/testing branch
|
||||||
|
branch="testing"
|
||||||
|
|
||||||
|
#Steam API key
|
||||||
|
steam_api=""
|
||||||
|
|
||||||
|
#Auto-install mods
|
||||||
|
auto_install="2"
|
||||||
|
|
||||||
|
#Automod staging directory
|
||||||
|
staging_dir="/tmp"
|
||||||
|
|
||||||
|
#Path to default Steam client
|
||||||
|
default_steam_path="/tmp"
|
||||||
|
|
||||||
|
#Preferred Steam launch command (for Flatpak support)
|
||||||
|
preferred_client="steam"
|
||||||
|
|
||||||
|
#DZGUI source path
|
||||||
|
src_path=""
|
||||||
@ -1,6 +1,7 @@
|
|||||||
import json
|
import json
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from dzgui.const.boilerplate import config_boilerplate
|
||||||
from dzgui.config.query import get_config
|
from dzgui.config.query import get_config
|
||||||
from dzgui.config.xdg import get_xdg_paths, parse_filepaths
|
from dzgui.config.xdg import get_xdg_paths, parse_filepaths
|
||||||
from dzgui.config import convert
|
from dzgui.config import convert
|
||||||
@ -11,7 +12,11 @@ pytestmark = pytest.mark.config
|
|||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def legacy_config():
|
def legacy_config():
|
||||||
return fixture_path("dztuirc_one")
|
return fixture_path("dztuirc_1")
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def unset_values():
|
||||||
|
return fixture_path("dztuirc_3")
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
@ -60,8 +65,8 @@ def test_contains_invalid_values(keys, config):
|
|||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"fixture, expect",
|
"fixture, expect",
|
||||||
[
|
[
|
||||||
("dztuirc_one", (False, True, True)),
|
("dztuirc_1", (False, True, True)),
|
||||||
("dztuirc_two", (False, False, False)),
|
("dztuirc_2", (False, False, False)),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_bool_conversion(fixture, expect):
|
def test_bool_conversion(fixture, expect):
|
||||||
@ -86,5 +91,12 @@ def test_key_conversion(legacy_config):
|
|||||||
for key in keys:
|
for key in keys:
|
||||||
assert key not in j
|
assert key not in j
|
||||||
|
|
||||||
|
def test_missing_values(unset_values):
|
||||||
|
j = convert.rc2json(unset_values)
|
||||||
|
j = json.loads(j)
|
||||||
|
assert j.keys() == config_boilerplate.keys()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# TODO: test that when a config file is created from scratch, it contains all values
|
# TODO: test that when a config file is created from scratch, it contains all values
|
||||||
|
|||||||
@ -1,17 +1,13 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from dzgui.api.mods import tokenize
|
from dzgui.api.mods import tokenize
|
||||||
from tests.fixtures import fixture_path
|
from tests.fixtures import fixture_path
|
||||||
|
|
||||||
@pytest.mark.mods
|
@pytest.mark.mods
|
||||||
@pytest.mark.parametrize("fixture", [
|
@pytest.mark.parametrize("i", range(1, 7))
|
||||||
fixture_path("cpp/meta1.cpp"),
|
def test_modmeta(i: int) -> None:
|
||||||
fixture_path("cpp/meta2.cpp"),
|
fixture = fixture_path(f"cpp/mod{i}")
|
||||||
fixture_path("cpp/meta3.cpp"),
|
path = Path(fixture)
|
||||||
fixture_path("cpp/meta4.cpp"),
|
meta = tokenize(path)
|
||||||
fixture_path("cpp/meta5.cpp"),
|
|
||||||
fixture_path("cpp/meta6.cpp"),
|
|
||||||
]
|
|
||||||
)
|
|
||||||
def test_modmeta(fixture: str) -> None:
|
|
||||||
meta = tokenize(fixture)
|
|
||||||
assert meta["name"] == "ModName"
|
assert meta["name"] == "ModName"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user