diff --git a/stages/test/org_osbuild_kickstart.py b/stages/test/org_osbuild_kickstart.py new file mode 120000 index 000000000..da529c68f --- /dev/null +++ b/stages/test/org_osbuild_kickstart.py @@ -0,0 +1 @@ +../org.osbuild.kickstart \ No newline at end of file diff --git a/stages/test/test_kickstart.py b/stages/test/test_kickstart.py new file mode 100644 index 000000000..61aab5ba9 --- /dev/null +++ b/stages/test/test_kickstart.py @@ -0,0 +1,53 @@ +#!/usr/bin/python3 + +import os.path +import shutil +import unittest +from tempfile import mkdtemp + +from org_osbuild_kickstart import main as kickstart_main + +test_cases = [ + { + "options": {"lang": "en_US.UTF-8"}, + "expected": "lang en_US.UTF-8", + }, + { + "options": {"keyboard": "us"}, + "expected": "keyboard us", + }, + { + "options": {"timezone": "UTC"}, + "expected": "timezone UTC", + }, + { + "options": { + "lang": "en_US.UTF-8", + "keyboard": "us", + "timezone": "UTC", + }, + "expected": "lang en_US.UTF-8\nkeyboard us\ntimezone UTC", + }, +] + + +class TestOrgOsbuilderKickstart(unittest.TestCase): + + def setUp(self): + self.tmpdir = mkdtemp() + self.addCleanup(shutil.rmtree, self.tmpdir) + + def test_kickstart(self): + ks_path = "kickstart/kfs.cfg" + for tc in test_cases: + options = {"path": ks_path} + options.update(tc["options"]) + kickstart_main(self.tmpdir, options) + + with open(os.path.join(self.tmpdir, ks_path), encoding="utf-8") as fp: + ks_content = fp.read() + self.assertEqual(ks_content, tc["expected"] + "\n") + + +if __name__ == "__main__": + unittest.main() diff --git a/tox.ini b/tox.ini index 30b1b3b72..031a4d90f 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 =