forked from osbuild/osbuild
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 trivial but also cheap and runs fast.
- Loading branch information
Showing
3 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../org.osbuild.kickstart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters