buildinstall: Move tweaking configs into a function

This will allow us to more easily test the code and also reuse it in
other places.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2017-02-20 10:34:13 +01:00
parent 55035487de
commit 05a666fb3b
2 changed files with 74 additions and 37 deletions

View file

@ -13,7 +13,8 @@ import sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
from pungi.phases.buildinstall import BuildinstallPhase, BuildinstallThread, link_boot_iso
from pungi.phases.buildinstall import (BuildinstallPhase, BuildinstallThread, link_boot_iso,
BOOT_CONFIGS, tweak_configs)
from tests.helpers import DummyCompose, PungiTestCase, touch, boom
@ -750,5 +751,33 @@ class TestSymlinkIso(PungiTestCase):
[mock.call('Server', 'x86_64', image)])
class TestTweakConfigs(PungiTestCase):
def test_tweak_configs(self):
configs = []
for cfg in BOOT_CONFIGS:
if 'yaboot' not in cfg:
configs.append(os.path.join(self.topdir, cfg))
touch(configs[-1], ':LABEL=baz')
tweak_configs(self.topdir, 'new volid', os.path.join(self.topdir, 'ks.cfg'))
for cfg in configs:
with open(cfg) as f:
self.assertEqual(
f.read().strip(),
':LABEL=new\\x20volid ks=hd:LABEL=new\\x20volid:/ks.cfg')
def test_tweak_configs_yaboot(self):
configs = []
for cfg in BOOT_CONFIGS:
if 'yaboot' in cfg:
configs.append(os.path.join(self.topdir, cfg))
touch(configs[-1], ':LABEL=baz')
tweak_configs(self.topdir, 'new volid', os.path.join(self.topdir, 'ks.cfg'))
for cfg in configs:
with open(os.path.join(self.topdir, cfg)) as f:
self.assertEqual(
f.read().strip(),
':LABEL=new\\\\x20volid ks=hd:LABEL=new\\\\x20volid:/ks.cfg')
if __name__ == "__main__":
unittest.main()