mirror of
https://github.com/aclist/dztui.git
synced 2026-08-30 03:37:00 +02:00
Compare commits
4 Commits
6fdf5547dc
...
26a2362172
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
26a2362172 | ||
|
|
50cf347164 | ||
|
|
dd69bc88b1 | ||
|
|
5c84b5ae0a |
@ -8,7 +8,7 @@ If you are a developer, you can skip to the end.
|
|||||||
# Requesting help
|
# Requesting help
|
||||||
|
|
||||||
If you encounter a problem with DZGUI, you can submit tickets on the GitHub
|
If you encounter a problem with DZGUI, you can submit tickets on the GitHub
|
||||||
(issue tracker)[https://github.com/aclist/dztui/issues] under the
|
[issue tracker](https://github.com/aclist/dztui/issues) under the
|
||||||
`troubleshooting` tag.
|
`troubleshooting` tag.
|
||||||
|
|
||||||
# How can I help the project?
|
# How can I help the project?
|
||||||
@ -24,7 +24,7 @@ accordingly.
|
|||||||
|
|
||||||
## Submitting a ticket
|
## Submitting a ticket
|
||||||
|
|
||||||
Navigate to the GitHub (issue tracker)[https://github.com/aclist/dztui/issues].
|
Navigate to the GitHub [issue tracker](https://github.com/aclist/dztui/issues).
|
||||||
From there, follow the onscreen prompts. You will be asked questions such as:
|
From there, follow the onscreen prompts. You will be asked questions such as:
|
||||||
|
|
||||||
- What version are you using?
|
- What version are you using?
|
||||||
|
|||||||
@ -59,7 +59,7 @@ class Shortcuts:
|
|||||||
logger.critical(e)
|
logger.critical(e)
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
def find_shortcuts_path(self, steam_path: Path) -> None:
|
def find_shortcuts_path(self, steam_path: Path) -> Path:
|
||||||
uid = find_user_id_32(steam_path)
|
uid = find_user_id_32(steam_path)
|
||||||
self.user_config_path = steam_path.joinpath(f"userdata/{uid}/config")
|
self.user_config_path = steam_path.joinpath(f"userdata/{uid}/config")
|
||||||
return self.user_config_path.joinpath("shortcuts.vdf")
|
return self.user_config_path.joinpath("shortcuts.vdf")
|
||||||
|
|||||||
@ -484,8 +484,6 @@ class Assistant(Gtk.Assistant):
|
|||||||
):
|
):
|
||||||
continue
|
continue
|
||||||
# NOTE: disabled for now on system-provided packages
|
# NOTE: disabled for now on system-provided packages
|
||||||
# TODO: drop, for testing purposes
|
|
||||||
os.environ["PYAPP"] = str(Path.home().joinpath("dzgui/dzgui"))
|
|
||||||
if isinstance(page, ShortcutCreationPage) and os.getenv("PYAPP") is None:
|
if isinstance(page, ShortcutCreationPage) and os.getenv("PYAPP") is None:
|
||||||
continue
|
continue
|
||||||
self._add_page(page, page.get_page_type())
|
self._add_page(page, page.get_page_type())
|
||||||
|
|||||||
BIN
tests/fixtures/api/no_shortcuts.vdf
vendored
Normal file
BIN
tests/fixtures/api/no_shortcuts.vdf
vendored
Normal file
Binary file not shown.
67
tests/test_shortcuts.py
Normal file
67
tests/test_shortcuts.py
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
import pytest
|
||||||
|
import tempfile
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
from _pytest.monkeypatch import MonkeyPatch
|
||||||
|
|
||||||
|
from dzgui.api.shortcuts import Shortcuts
|
||||||
|
from tests.fixtures import fixture_path
|
||||||
|
|
||||||
|
pytestmark = pytest.mark.apitest
|
||||||
|
|
||||||
|
|
||||||
|
def mock_find_shortcuts(self, steam_path: Path) -> Path:
|
||||||
|
return Path(fixture_path("api/no_shortcuts.vdf"))
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope="module", autouse=True)
|
||||||
|
def patch_api() -> None:
|
||||||
|
mp = MonkeyPatch()
|
||||||
|
mp.setattr("dzgui.api.shortcuts.Shortcuts.find_shortcuts_path", mock_find_shortcuts)
|
||||||
|
yield
|
||||||
|
mp.undo()
|
||||||
|
|
||||||
|
|
||||||
|
def test_no_shortcuts(monkeypatch) -> None:
|
||||||
|
s = Shortcuts(Path(""))
|
||||||
|
assert len(s.shortcuts["shortcuts"]) == 0
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def dummy_app() -> None:
|
||||||
|
d = {
|
||||||
|
"appname": "TEST APP",
|
||||||
|
"StartDir": "TEST_DIR",
|
||||||
|
"exe": "TEST_DIR/TEST_EXE.EXE",
|
||||||
|
"icon": "IMAGES_DIR/TEST_IMAGE.PNG",
|
||||||
|
}
|
||||||
|
return d
|
||||||
|
|
||||||
|
|
||||||
|
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] == '"'
|
||||||
|
|
||||||
|
|
||||||
|
def test_add_shortcut(dummy_app) -> None:
|
||||||
|
s = Shortcuts(Path(""))
|
||||||
|
s.add_shortcut(*dummy_app.values())
|
||||||
|
new = s.shortcuts["shortcuts"]
|
||||||
|
ind = str(len(new) - 1)
|
||||||
|
for k, v in dummy_app.items():
|
||||||
|
if k == "exe":
|
||||||
|
v = f'"{v}"'
|
||||||
|
assert new[ind][k] == v
|
||||||
|
|
||||||
|
|
||||||
|
def test_save_shortcut(dummy_app) -> None:
|
||||||
|
s = Shortcuts(Path(""))
|
||||||
|
s.add_shortcut(*dummy_app.values())
|
||||||
|
with tempfile.NamedTemporaryFile() as f:
|
||||||
|
tmp = Path(f.name)
|
||||||
|
s.shortcuts_path = tmp
|
||||||
|
s.save_shortcuts()
|
||||||
|
s._load_shortcuts(tmp)
|
||||||
|
assert len(s.shortcuts["shortcuts"]) == 1
|
||||||
Loading…
Reference in New Issue
Block a user