Files
kernalix7--winpodx/tests/test_setup_wizard_prompts.py
wehub-resource-sync 3e779be6f3
CI / lint (push) Failing after 13m4s
CI / test (3.11, ubuntu-latest) (push) Failing after 2m4s
CI / test (3.13, ubuntu-latest) (push) Successful in 13m30s
CI / test (3.14, ubuntu-latest) (push) Successful in 17m21s
CI / test (3.12, ubuntu-latest) (push) Successful in 17m55s
CI / discover-apps-ps (push) Successful in 1m56s
CI / test (3.9, ubuntu-latest) (push) Successful in 13m17s
CI / test (3.10, ubuntu-latest) (push) Successful in 26m21s
CI / audit (push) Successful in 13m38s
Deploy site / deploy (push) Has been cancelled
CI / test (3.14, ubuntu-24.04-arm) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:32:37 +08:00

87 lines
2.7 KiB
Python

# SPDX-License-Identifier: MIT
"""Tests for the extended setup wizard (#255 PR 7 completion):
edition / locale / tuning prompts + the full-provision gate.
0.6.0 item B: ``--create-only`` was removed; ``_run_full_provision`` is now
a thin wrapper over ``core.provisioner.finish_provisioning``. The non-
container short-circuit it kept is what ``test_full_provision_noop_*`` pins.
"""
from __future__ import annotations
from unittest.mock import patch
from winpodx.cli.setup_cmd import _prompt_edition_locale_tuning, _run_full_provision
from winpodx.core.config import Config
def _cfg() -> Config:
cfg = Config()
cfg.pod.backend = "podman"
return cfg
def test_wizard_prompts_set_all_locale_edition_tuning_fields() -> None:
"""Each answered prompt maps to the matching cfg.pod field."""
cfg = _cfg()
answers = iter(
[
"ltsc11", # edition / win_version
"German", # language
"en-US", # region
"de-DE", # keyboard
"performance", # tuning_profile
]
)
with patch("builtins.input", lambda _prompt: next(answers)):
_prompt_edition_locale_tuning(cfg)
assert cfg.pod.win_version == "ltsc11"
assert cfg.pod.language == "German"
assert cfg.pod.region == "en-US"
assert cfg.pod.keyboard == "de-DE"
assert cfg.pod.tuning_profile == "performance"
def test_wizard_prompts_enter_keeps_defaults() -> None:
"""Empty input (Enter) keeps the existing cfg defaults."""
cfg = _cfg()
before = (
cfg.pod.win_version,
cfg.pod.language,
cfg.pod.region,
cfg.pod.keyboard,
cfg.pod.tuning_profile,
)
with patch("builtins.input", lambda _prompt: ""):
_prompt_edition_locale_tuning(cfg)
after = (
cfg.pod.win_version,
cfg.pod.language,
cfg.pod.region,
cfg.pod.keyboard,
cfg.pod.tuning_profile,
)
assert before == after
def test_wizard_rejects_unknown_tuning_profile_keeps_default() -> None:
"""A bogus tuning profile is rejected, default preserved."""
cfg = _cfg()
cfg.pod.tuning_profile = "auto"
answers = iter(["11", "English", "en-001", "en-US", "turbo-nonsense"])
with patch("builtins.input", lambda _prompt: next(answers)):
_prompt_edition_locale_tuning(cfg)
assert cfg.pod.tuning_profile == "auto"
def test_full_provision_noop_for_non_container_backend() -> None:
"""manual backends have no container provision flow -- the
helper must return immediately without touching wait-ready etc."""
cfg = _cfg()
cfg.pod.backend = "manual"
# If it tried to import/run _wait_ready it'd need a real pod; the
# early return keeps it a pure no-op. No exception = pass.
_run_full_provision(cfg)