From: Travis Rhoden Date: Fri, 7 Aug 2015 21:55:31 +0000 (-0700) Subject: [RM-12644] Add tests for DNF package manager X-Git-Tag: v1.5.28~8^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2880e71d2a4940f69fc229c23377253d62df94f3;p=ceph-deploy.git [RM-12644] Add tests for DNF package manager Signed-off-by: Travis Rhoden --- diff --git a/ceph_deploy/tests/unit/util/test_pkg_managers.py b/ceph_deploy/tests/unit/util/test_pkg_managers.py index 5c62993..d634e03 100644 --- a/ceph_deploy/tests/unit/util/test_pkg_managers.py +++ b/ceph_deploy/tests/unit/util/test_pkg_managers.py @@ -137,3 +137,39 @@ class TestZypper(object): assert 'remove' in result[0][-1] assert result[0][-1][-2:] == ['vim', 'zsh'] + +class TestDNF(object): + + def setup(self): + self.to_patch = 'ceph_deploy.util.pkg_managers.remoto.process.run' + + def test_install_single_package(self): + fake_run = Mock() + with patch(self.to_patch, fake_run): + pkg_managers.DNF(Mock()).install('vim') + result = fake_run.call_args_list[-1] + assert 'install' in result[0][-1] + assert result[0][-1][-1] == 'vim' + + def test_install_multiple_packages(self): + fake_run = Mock() + with patch(self.to_patch, fake_run): + pkg_managers.DNF(Mock()).install(['vim', 'zsh']) + result = fake_run.call_args_list[-1] + assert 'install' in result[0][-1] + assert result[0][-1][-2:] == ['vim', 'zsh'] + + def test_remove_single_package(self): + fake_run = Mock() + with patch(self.to_patch, fake_run): + pkg_managers.DNF(Mock()).remove('vim') + result = fake_run.call_args_list[-1] + assert 'remove' in result[0][-1] + assert result[0][-1][-1] == 'vim' + + def test_remove_multiple_packages(self): + fake_run = Mock() + with patch(self.to_patch, fake_run): + pkg_managers.DNF(Mock()).remove(['vim', 'zsh']) + result = fake_run.call_args_list[-1] + assert 'remove' in result[0][-1]