fix: clean up config.py unused imports, null-YAML safety, and add non-default roundtrip test
This commit is contained in:
@@ -2,7 +2,7 @@ import pytest
|
||||
import click
|
||||
from autossh_mgr.config import (
|
||||
TunnelConfig, ensure_dirs, load_tunnels, save_tunnels, get_tunnel
|
||||
)
|
||||
) # TunnelConfig kept for test_save_preserves_non_default_values
|
||||
|
||||
|
||||
def test_ensure_dirs_creates_structure(tmp_path):
|
||||
@@ -59,3 +59,22 @@ def test_get_config_dir_env_override(monkeypatch, tmp_path):
|
||||
monkeypatch.setenv("AUTOSSH_MGR_CONFIG_DIR", str(tmp_path))
|
||||
from autossh_mgr.config import get_config_dir
|
||||
assert get_config_dir() == tmp_path
|
||||
|
||||
|
||||
def test_save_preserves_non_default_values(config_dir):
|
||||
tunnel = TunnelConfig(
|
||||
name="custom", host="h.com", user="u",
|
||||
local_port=80, remote_port=8080,
|
||||
port=2222,
|
||||
identity_file="~/.ssh/custom_key",
|
||||
local_host="0.0.0.0",
|
||||
remote_host="127.0.0.1",
|
||||
ssh_options="-v",
|
||||
)
|
||||
save_tunnels(config_dir, [tunnel])
|
||||
loaded = load_tunnels(config_dir)[0]
|
||||
assert loaded.port == 2222
|
||||
assert loaded.identity_file == "~/.ssh/custom_key"
|
||||
assert loaded.local_host == "0.0.0.0"
|
||||
assert loaded.remote_host == "127.0.0.1"
|
||||
assert loaded.ssh_options == "-v"
|
||||
|
||||
Reference in New Issue
Block a user