Add basic yum and apt package install tests

Change-Id: I96e3bdc2566222fb4926e8a8f88a7f6b822e16f7
Partial-bug: #1235796
This commit is contained in:
Angus Salkeld 2013-11-01 17:09:01 +11:00
parent e8d2522397
commit 8cbb79aff2
1 changed files with 51 additions and 0 deletions

View File

@ -74,6 +74,57 @@ class TestCommandRunner(MockPopenTestCase):
self.m.VerifyAll()
class TestPackages(MockPopenTestCase):
def test_rpm_install(self):
install_list = []
for pack in ('httpd', 'wordpress', 'mysql-server'):
self.mock_cmd_run(['su', 'root', '-c',
'rpm -q %s' % pack]).AndReturn(
FakePOpen(returncode=1))
self.mock_cmd_run(
['su', 'root', '-c',
'yum -y --showduplicates list available %s' % pack]) \
.AndReturn(FakePOpen(returncode=0))
install_list.append(pack)
self.mock_cmd_run(
['su', 'root', '-c',
'yum -y install %s' % ' '.join(install_list)]) \
.AndReturn(FakePOpen(returncode=0))
self.m.ReplayAll()
packages = {
"yum": {
"mysql-server": [],
"httpd": [],
"wordpress": []
}
}
cfn_helper.PackagesHandler(packages).apply_packages()
self.m.VerifyAll()
def test_apt_install(self):
install_list = 'httpd wordpress mysql-server'
cmd = 'DEBIAN_FRONTEND=noninteractive apt-get -y install'
self.mock_cmd_run(['su', 'root', '-c',
'%s %s' % (cmd, install_list)]).AndReturn(
FakePOpen(returncode=0))
self.m.ReplayAll()
packages = {
"apt": {
"mysql-server": [],
"httpd": [],
"wordpress": []
}
}
cfn_helper.PackagesHandler(packages).apply_packages()
self.m.VerifyAll()
class TestServicesHandler(MockPopenTestCase):
def test_services_handler_systemd(self):