コード例 #1
0
 def test_virtual(self):
     '''
     On expected platform with correct utils in PATH, register "partition" module
     '''
     with patch('salt.utils.platform.is_windows', lambda: False), \
             patch('salt.utils.path.which', lambda exe: exe in ('parted', 'lsblk', 'partprobe')):
         ret = parted.__virtual__()
         expect = 'partition'
         self.assertEqual(ret, expect)
コード例 #2
0
 def test_virtual_bails_without_partprobe(self):
     '''
     If partprobe not in PATH, __virtual__ shouldn't register module
     '''
     with patch('salt.utils.path.which', lambda exe: not exe == "partprobe"),\
             patch('salt.utils.platform.is_windows', return_value=False):
         ret = parted.__virtual__()
         err = (False, 'The parted execution module failed to load partprobe binary is not in the path.')
         self.assertEqual(err, ret)
コード例 #3
0
 def test_virtual(self):
     """
     On expected platform with correct utils in PATH, register "partition" module
     """
     with patch("salt.utils.platform.is_windows", lambda: False), patch(
             "salt.utils.path.which", lambda exe: exe in
         ("parted", "lsblk", "partprobe")):
         ret = parted.__virtual__()
         expect = "partition"
         self.assertEqual(ret, expect)
コード例 #4
0
 def test_virtual_bails_on_windows(self):
     '''
     If running windows, __virtual__ shouldn't register module
     '''
     with patch('salt.utils.platform.is_windows', lambda: True):
         ret = parted.__virtual__()
         err = (
             False,
             'The parted execution module failed to load Windows systems are not supported.'
         )
         self.assertEqual(err, ret)
コード例 #5
0
 def test_virtual_bails_without_lsblk(self):
     """
     If lsblk not in PATH, __virtual__ shouldn't register module
     """
     with patch("salt.utils.path.which",
                lambda exe: not exe == "lsblk"), patch(
                    "salt.utils.platform.is_windows", return_value=False):
         ret = parted.__virtual__()
         err = (
             False,
             "The parted execution module failed to load lsblk binary is not in the path.",
         )
         self.assertEqual(err, ret)