62 lines
1.6 KiB
Python
62 lines
1.6 KiB
Python
|
|
from app import (
|
||
|
|
build_archinstall_config,
|
||
|
|
build_archinstall_creds,
|
||
|
|
validate_step1,
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
def test_validate_step1_accepts_good_input():
|
||
|
|
errors, values = validate_step1(
|
||
|
|
{
|
||
|
|
"hostname": "furtka",
|
||
|
|
"username": "daniel",
|
||
|
|
"password": "topsecretpw",
|
||
|
|
"password2": "topsecretpw",
|
||
|
|
"language": "de",
|
||
|
|
}
|
||
|
|
)
|
||
|
|
assert errors == []
|
||
|
|
assert values == {
|
||
|
|
"hostname": "furtka",
|
||
|
|
"username": "daniel",
|
||
|
|
"password": "topsecretpw",
|
||
|
|
"language": "de",
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
def test_validate_step1_collects_all_errors():
|
||
|
|
errors, _ = validate_step1(
|
||
|
|
{
|
||
|
|
"hostname": "BAD!",
|
||
|
|
"username": "1bad",
|
||
|
|
"password": "short",
|
||
|
|
"password2": "mismatch",
|
||
|
|
"language": "xx",
|
||
|
|
}
|
||
|
|
)
|
||
|
|
assert len(errors) == 5
|
||
|
|
|
||
|
|
|
||
|
|
def test_build_archinstall_config_uses_selected_locale():
|
||
|
|
cfg = build_archinstall_config(
|
||
|
|
{
|
||
|
|
"hostname": "h",
|
||
|
|
"username": "u",
|
||
|
|
"password": "pw12345678",
|
||
|
|
"language": "pl",
|
||
|
|
"boot_drive": "/dev/sda",
|
||
|
|
}
|
||
|
|
)
|
||
|
|
assert cfg["disk_config"]["device"] == "/dev/sda"
|
||
|
|
assert cfg["hostname"] == "h"
|
||
|
|
assert cfg["users"][0]["username"] == "u"
|
||
|
|
assert cfg["locale_config"]["locale"] == "pl_PL.UTF-8"
|
||
|
|
|
||
|
|
|
||
|
|
def test_build_archinstall_creds_reuses_password_for_root_and_user():
|
||
|
|
creds = build_archinstall_creds(
|
||
|
|
{"username": "u", "password": "pw12345678"}
|
||
|
|
)
|
||
|
|
assert creds["root_password"] == "pw12345678"
|
||
|
|
assert creds["users"] == [{"username": "u", "password": "pw12345678"}]
|