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)
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)
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)
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)
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)