mirror of
https://github.com/aclist/dztui.git
synced 2026-10-30 14:42:54 +01:00
change: return client name from controller
This commit is contained in:
1 parent
07460a1f8f
commit
eed40e6f1a
3 files changed
+25
-2
No files matched your search
@@ -541,6 +541,11 @@ class Controller(GObject.GObject):
|
|||||||
def update_status(self) -> None:
|
def update_status(self) -> None:
|
||||||
self.mediator.preconnect.mark_finished()
|
self.mediator.preconnect.mark_finished()
|
||||||
|
|
||||||
|
def get_client_name(self) -> str:
|
||||||
|
# NOTE: only possible values are "Steam" and "Flatpak"
|
||||||
|
cmd = self.query_config(Preferences.CLIENT)
|
||||||
|
return cmd.split()[0].capitalize()
|
||||||
|
|
||||||
def present_window(self) -> None:
|
def present_window(self) -> None:
|
||||||
self.mediator.window.present_with_time(Gdk.CURRENT_TIME)
|
self.mediator.window.present_with_time(Gdk.CURRENT_TIME)
|
||||||
|
|
||||||
|
|||||||
@@ -185,8 +185,7 @@ class ConnectionManager:
|
|||||||
allows_downloads = (True, "")
|
allows_downloads = (True, "")
|
||||||
|
|
||||||
client = self.controller.query_config(Preferences.CLIENT)
|
client = self.controller.query_config(Preferences.CLIENT)
|
||||||
# TODO: add test
|
client_name = self.controller.get_client_name()
|
||||||
client_name = client.split()[0].capitalize()
|
|
||||||
running = is_steam_running(client)
|
running = is_steam_running(client)
|
||||||
steam_proc = SteamProcess(client_name, running)
|
steam_proc = SteamProcess(client_name, running)
|
||||||
self.client = client
|
self.client = client
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import pytest
|
||||||
|
|
||||||
|
from dzgui.const.constants import FLATPAK_RUN_CMD, STEAM_CMD
|
||||||
|
from dzgui.controllers.mc import Controller
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"value, expected", [(FLATPAK_RUN_CMD, "Flatpak"), (STEAM_CMD, "Steam")]
|
||||||
|
)
|
||||||
|
def test_human_name(monkeypatch, value, expected) -> None:
|
||||||
|
def mock_query_config(*args) -> str:
|
||||||
|
return value
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
"dzgui.controllers.mc.Controller.query_config", mock_query_config
|
||||||
|
)
|
||||||
|
controller = Controller()
|
||||||
|
client = controller.get_client_name()
|
||||||
|
assert client == expected
|
||||||
Reference in new issue
Block a user