diff --git a/osbuild.spec b/osbuild.spec index 16a8815664..a2fc4adeff 100644 --- a/osbuild.spec +++ b/osbuild.spec @@ -152,7 +152,7 @@ bzip2 -9 osbuild.pp %py3_install mkdir -p %{buildroot}%{pkgdir}/stages -install -p -m 0755 $(find stages -type f) %{buildroot}%{pkgdir}/stages/ +install -p -m 0755 $(find stages -type f -not -name "test_*.py") %{buildroot}%{pkgdir}/stages/ mkdir -p %{buildroot}%{pkgdir}/assemblers install -p -m 0755 $(find assemblers -type f) %{buildroot}%{pkgdir}/assemblers/ diff --git a/stages/test/test_kickstart.py b/stages/test/test_kickstart.py new file mode 100644 index 0000000000..22a3b78ca3 --- /dev/null +++ b/stages/test/test_kickstart.py @@ -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" diff --git a/tox.ini b/tox.ini index 30b1b3b726..031a4d90f6 100644 --- a/tox.ini +++ b/tox.ini @@ -19,7 +19,7 @@ deps = pyyaml setenv = - LINTABLES = osbuild/ assemblers/* devices/* inputs/* mounts/* runners/* sources/* stages/* + LINTABLES = osbuild/ assemblers/* devices/* inputs/* mounts/* runners/* sources/* stages/*.* stages/test/*.py TYPEABLES = osbuild passenv =