Add guided env setup modal
This commit is contained in:
parent
c9859a5324
commit
8c90306c75
6 changed files with 474 additions and 9 deletions
|
|
@ -3,7 +3,7 @@ from pathlib import Path
|
|||
import pytest
|
||||
|
||||
from pve_vm_setup.errors import SettingsError
|
||||
from pve_vm_setup.settings import AppSettings
|
||||
from pve_vm_setup.settings import AppSettings, resolve_dotenv_paths, write_config_dotenv
|
||||
|
||||
|
||||
def test_settings_load_defaults_and_normalize_api_base() -> None:
|
||||
|
|
@ -152,3 +152,37 @@ def test_settings_prefers_environment_over_config_and_current_directory_dotenv(
|
|||
)
|
||||
|
||||
assert settings.proxmox_url == "https://env.example.invalid:8006"
|
||||
|
||||
|
||||
def test_resolve_dotenv_paths_uses_standard_config_location(tmp_path: Path, monkeypatch) -> None:
|
||||
home = tmp_path / "home"
|
||||
monkeypatch.setenv("HOME", str(home))
|
||||
|
||||
paths = resolve_dotenv_paths()
|
||||
|
||||
assert paths.cwd == Path(".env")
|
||||
assert paths.config == home / ".config" / "pve-vm-setup" / ".env"
|
||||
assert paths.any_exists is False
|
||||
|
||||
|
||||
def test_write_config_dotenv_creates_parent_directory_and_skips_blank_values(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
target = tmp_path / "home" / ".config" / "pve-vm-setup" / ".env"
|
||||
|
||||
written_path = write_config_dotenv(
|
||||
{
|
||||
"PROXMOX_URL": "https://pve.example.invalid:8006",
|
||||
"PROXMOX_USER": "root",
|
||||
"PROXMOX_PASSWORD": "",
|
||||
},
|
||||
config_dotenv_path=target,
|
||||
)
|
||||
|
||||
assert written_path == target
|
||||
assert target.exists()
|
||||
assert target.read_text(encoding="utf-8") == (
|
||||
"# Generated by pve-vm-setup\n"
|
||||
"PROXMOX_URL=https://pve.example.invalid:8006\n"
|
||||
"PROXMOX_USER=root\n"
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue