mirror of
https://github.com/dw-0/kiauh.git
synced 2026-08-04 05:17:53 +05:00
Replace monolithic client_setup.py, client_config_setup.py and their remove counterparts with service classes under components/webui_client/services. Update menus and core install/update menus to call the new services. Add unit tests for services, client_utils and menu wiring.
64 lines
2.2 KiB
Python
64 lines
2.2 KiB
Python
# ======================================================================= #
|
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
|
# #
|
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
|
# https://github.com/dw-0/kiauh #
|
|
# #
|
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
|
# ======================================================================= #
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass, field
|
|
from pathlib import Path
|
|
from typing import Any
|
|
|
|
import pytest
|
|
from components.webui_client.base_data import WebClientType
|
|
|
|
|
|
@dataclass
|
|
class FakeClientConfig:
|
|
name: str = "mainsail-config"
|
|
display_name: str = "Mainsail-Config"
|
|
config_filename: str = "mainsail.cfg"
|
|
config_section: str = "include mainsail.cfg"
|
|
repo_url: str = "https://github.com/mainsail-crew/mainsail-config.git"
|
|
config_dir: Path = Path("/tmp/mainsail-config")
|
|
|
|
|
|
@dataclass
|
|
class FakeWebClient:
|
|
name: str = "mainsail"
|
|
display_name: str = "Mainsail"
|
|
client: WebClientType = WebClientType.MAINSAIL
|
|
client_dir: Path = Path("/tmp/mainsail")
|
|
config_file: Path = Path("/tmp/mainsail/config.json")
|
|
repo_path: str = "mainsail-crew/mainsail"
|
|
nginx_config: Path = Path("/tmp/nginx/mainsail")
|
|
nginx_access_log: Path = Path("/tmp/log/mainsail-access.log")
|
|
nginx_error_log: Path = Path("/tmp/log/mainsail-error.log")
|
|
download_url: str = "https://example.com/mainsail.zip"
|
|
client_config: Any = field(default_factory=FakeClientConfig)
|
|
|
|
|
|
@pytest.fixture
|
|
def client() -> FakeWebClient:
|
|
return FakeWebClient()
|
|
|
|
|
|
@pytest.fixture
|
|
def reset_settings(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
from core.settings.kiauh_settings import KiauhSettings
|
|
|
|
KiauhSettings._KiauhSettings__instance = None
|
|
KiauhSettings._KiauhSettings__initialized = False
|
|
|
|
|
|
@pytest.fixture
|
|
def settings(reset_settings) -> Any:
|
|
from core.settings.kiauh_settings import KiauhSettings
|
|
|
|
return KiauhSettings()
|
|
|
|
|