]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
[RM-16979] Change test to use check function. 413/head
authorOwen Synge <osynge@suse.com>
Wed, 10 Aug 2016 14:58:31 +0000 (16:58 +0200)
committerOwen Synge <osynge@suse.com>
Wed, 10 Aug 2016 15:10:17 +0000 (17:10 +0200)
Check function testable in same way as run function.

Signed-off-by: Owen Synge <osynge@suse.com>
ceph_deploy/tests/unit/util/test_pkg_managers.py

index b7c7976e4d3b77055bbc3780265349fd15e765de..1e4cedc645eeb0780ef14d6bbb2a17fb5b1a2a51 100644 (file)
@@ -82,6 +82,7 @@ class TestZypper(object):
 
     def setup(self):
         self.to_patch = 'ceph_deploy.util.pkg_managers.remoto.process.run'
+        self.to_check = 'ceph_deploy.util.pkg_managers.remoto.process.check'
 
     def test_install_single_package(self):
         fake_run = Mock()
@@ -100,18 +101,20 @@ class TestZypper(object):
         assert result[0][-1][-2:] == ['vim', 'zsh']
 
     def test_remove_single_package(self):
-        fake_run = Mock()
-        with patch(self.to_patch, fake_run):
+        fake_check = Mock()
+        fake_check.return_value = '', '', 0
+        with patch(self.to_check, fake_check):
             pkg_managers.Zypper(Mock()).remove('vim')
-            result = fake_run.call_args_list[-1]
+            result = fake_check.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):
+        fake_check = Mock()
+        fake_check.return_value = '', '', 0
+        with patch(self.to_check, fake_check):
             pkg_managers.Zypper(Mock()).remove(['vim', 'zsh'])
-            result = fake_run.call_args_list[-1]
+            result = fake_check.call_args_list[-1]
         assert 'remove' in result[0][-1]
         assert result[0][-1][-2:] == ['vim', 'zsh']