Update yum unittest
This commit is contained in:
parent
345aefcd9f
commit
27658cc929
@ -137,9 +137,10 @@ def handle(_name, cfg, cloud, log, args):
|
|||||||
util.write_file(ssh_util.DEF_SSHD_CFG, "\n".join(lines))
|
util.write_file(ssh_util.DEF_SSHD_CFG, "\n".join(lines))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cmd = cloud.distro.init_cmd
|
cmd = cloud.distro.init_cmd # Default service
|
||||||
cmd.append(cloud.distro.get_option('ssh_svcname', 'ssh'))
|
cmd.append(cloud.distro.get_option('ssh_svcname', 'ssh'))
|
||||||
cmd.append('restart')
|
cmd.append('restart')
|
||||||
|
cmd = filter(None, cmd) # Remove empty arguments
|
||||||
util.subp(cmd)
|
util.subp(cmd)
|
||||||
log.debug("Restarted the ssh daemon")
|
log.debug("Restarted the ssh daemon")
|
||||||
except:
|
except:
|
||||||
|
@ -1483,7 +1483,6 @@ def subp(args, data=None, rcs=None, env=None, capture=True, shell=False,
|
|||||||
logstring=False):
|
logstring=False):
|
||||||
if rcs is None:
|
if rcs is None:
|
||||||
rcs = [0]
|
rcs = [0]
|
||||||
args = filter(None, args) # Remove empty arguments
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
if not logstring:
|
if not logstring:
|
||||||
|
@ -2,6 +2,7 @@ from cloudinit import helpers
|
|||||||
from cloudinit import util
|
from cloudinit import util
|
||||||
|
|
||||||
from cloudinit.config import cc_yum_add_repo
|
from cloudinit.config import cc_yum_add_repo
|
||||||
|
from cloudinit.distros import rhel
|
||||||
|
|
||||||
from tests.unittests import helpers
|
from tests.unittests import helpers
|
||||||
|
|
||||||
@ -18,6 +19,8 @@ class TestConfig(helpers.FilesystemMockingTestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestConfig, self).setUp()
|
super(TestConfig, self).setUp()
|
||||||
self.tmp = self.makeDir(prefix="unittest_")
|
self.tmp = self.makeDir(prefix="unittest_")
|
||||||
|
self.cloud = type('', (), {})()
|
||||||
|
self.cloud.distro = rhel.Distro('test', {}, None)
|
||||||
|
|
||||||
def test_bad_config(self):
|
def test_bad_config(self):
|
||||||
cfg = {
|
cfg = {
|
||||||
@ -34,7 +37,7 @@ class TestConfig(helpers.FilesystemMockingTestCase):
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
self.patchUtils(self.tmp)
|
self.patchUtils(self.tmp)
|
||||||
cc_yum_add_repo.handle('yum_add_repo', cfg, None, LOG, [])
|
cc_yum_add_repo.handle('yum_add_repo', cfg, self.cloud, LOG, [])
|
||||||
self.assertRaises(IOError, util.load_file,
|
self.assertRaises(IOError, util.load_file,
|
||||||
"/etc/yum.repos.d/epel_testing.repo")
|
"/etc/yum.repos.d/epel_testing.repo")
|
||||||
|
|
||||||
@ -52,7 +55,7 @@ class TestConfig(helpers.FilesystemMockingTestCase):
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
self.patchUtils(self.tmp)
|
self.patchUtils(self.tmp)
|
||||||
cc_yum_add_repo.handle('yum_add_repo', cfg, None, LOG, [])
|
cc_yum_add_repo.handle('yum_add_repo', cfg, self.cloud, LOG, [])
|
||||||
contents = util.load_file("/etc/yum.repos.d/epel_testing.repo")
|
contents = util.load_file("/etc/yum.repos.d/epel_testing.repo")
|
||||||
contents = configobj.ConfigObj(StringIO(contents))
|
contents = configobj.ConfigObj(StringIO(contents))
|
||||||
expected = {
|
expected = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user