def mount_target_flat(self): """Mount a set of file systems into a set of temporary directories :returns: Mount map dict """ LOG.debug('Mounting target file systems into a flat set ' 'of temporary directories') mount_map = {} for fs in self.driver.partition_scheme.fss: if fs.mount == 'swap': continue # It is an ugly hack to resolve python2/3 encoding issues and # should be removed after transistion to python3 try: type(fs.mount) is unicode fs_mount = fs.mount.encode('ascii', 'ignore') except NameError: fs_mount = fs.mount mount_map[fs_mount] = fu.mount_fs_temp(fs.type, str(fs.device)) LOG.debug('Flat mount map: %s', mount_map) return mount_map
def test_mount_fs_temp(self, mock_mkdtemp, mock_mount, mock_exec): mock_mkdtemp.return_value = '/tmp/dir' self.assertEqual('/tmp/dir', fu.mount_fs_temp('ext4', '/dev/fake')) mock_mkdtemp.assert_called_once_with(dir=None, suffix='') mock_mount.assert_called_once_with('ext4', '/dev/fake', '/tmp/dir')