]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
[RM-12644] Add tests for DNF package manager
authorTravis Rhoden <trhoden@redhat.com>
Fri, 7 Aug 2015 21:55:31 +0000 (14:55 -0700)
committerTravis Rhoden <trhoden@redhat.com>
Fri, 7 Aug 2015 21:55:31 +0000 (14:55 -0700)
Signed-off-by: Travis Rhoden <trhoden@redhat.com>
ceph_deploy/tests/unit/util/test_pkg_managers.py

index 5c629938102766c533de1188946b973adbfe9556..d634e034bd9eb9f0b5352d05856ecc9e26dbb3b0 100644 (file)
@@ -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]