def space_required_for_mount_points(self): """Generates list of mount points with sum of required space :returns: dict where key is mount point and value is required free space """ sum_of_spaces = {} for required_space in self.required_spaces: if not required_space: continue for path, size in sorted(required_space.items()): mount_path = utils.find_mount_point(path) sum_of_spaces.setdefault(mount_path, 0) sum_of_spaces[mount_path] += size return sum_of_spaces
def space_required_for_mount_points(self): """Iterates over required spaces generates list of mount points with sum of required space :returns: dict where key is mount point and value is required free space """ sum_of_spaces = {} for required_space in self.required_spaces: if not required_space: continue for path, size in sorted(required_space.items()): mount_path = utils.find_mount_point(path) sum_of_spaces.setdefault(mount_path, 0) sum_of_spaces[mount_path] += size return sum_of_spaces
def test_find_mount_point(self, mock_ismount): path = '/dir1/dir2/dir3/dir4' self.assertEqual(utils.find_mount_point(path), '/dir1/dir2') self.called_times(mock_ismount, 3)