stages: add new unit test for kickstart stage
This commit adds a simple and lightweight unit test for the new kickstart options. It's pretty simple but also cheap and runs fast.
This commit is contained in:
parent
061501d4c2
commit
ed95c10530
3 changed files with 34 additions and 2 deletions
32
stages/test/test_kickstart.py
Normal file
32
stages/test/test_kickstart.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import os.path
|
||||
|
||||
import pytest
|
||||
|
||||
from osbuild.testutil.imports import import_module_from_path
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_input,expected", [
|
||||
({"lang": "en_US.UTF-8"}, "lang en_US.UTF-8"),
|
||||
({"keyboard": "us"}, "keyboard us"),
|
||||
({"timezone": "UTC"}, "timezone UTC"),
|
||||
({"lang": "en_US.UTF-8",
|
||||
"keyboard": "us",
|
||||
"timezone": "UTC",
|
||||
},
|
||||
"lang en_US.UTF-8\nkeyboard us\ntimezone UTC"),
|
||||
])
|
||||
def test_kickstart(tmp_path, test_input, expected):
|
||||
ks_stage_path = os.path.join(os.path.dirname(__file__), "../org.osbuild.kickstart")
|
||||
ks_stage = import_module_from_path("ks_stage", ks_stage_path)
|
||||
|
||||
ks_path = "kickstart/kfs.cfg"
|
||||
options = {"path": ks_path}
|
||||
options.update(test_input)
|
||||
|
||||
ks_stage.main(tmp_path, options)
|
||||
|
||||
with open(os.path.join(tmp_path, ks_path), encoding="utf-8") as fp:
|
||||
ks_content = fp.read()
|
||||
assert ks_content == expected + "\n"
|
||||
Loading…
Add table
Add a link
Reference in a new issue