def test_get_free_space(self, exec_mock): """Test the get_free_space function.""" output = """ Mounted on Avail /dev 100 /dev/shm 200 /run 300 / 400 /tmp 500 /boot 600 /home 700 /boot/efi 800 """ exec_mock.return_value = dedent(output).strip() assert get_free_space_map() == { '/dev': Size("100 KiB"), '/dev/shm': Size("200 KiB"), '/run': Size("300 KiB"), '/': Size("400 KiB"), '/tmp': Size("500 KiB"), '/boot': Size("600 KiB"), '/home': Size("700 KiB"), '/boot/efi': Size("800 KiB"), }
def get_combined_free_space_test(self, proxy_getter, exec_mock): """Test the get_free_space function with the combined options.""" output = """ Mounted on Avail / 100 /tmp 200 """ exec_mock.return_value = dedent(output).strip() mount_points = { '/': Size("300 KiB"), '/boot': Size("400 KiB"), } def get_mount_points(): return list(mount_points.keys()) def get_free_space(paths): return sum(map(mount_points.get, paths)) device_tree = STORAGE.get_proxy(DEVICE_TREE) device_tree.GetMountPoints.side_effect = get_mount_points device_tree.GetFileSystemFreeSpace.side_effect = get_free_space self.assertEqual(get_free_space_map(current=True, scheduled=False), { '/': Size("100 KiB"), '/tmp': Size("200 KiB"), }) self.assertEqual( get_free_space_map(current=False, scheduled=True), { '/mnt/sysroot': Size("300 KiB"), '/mnt/sysroot/boot': Size("400 KiB"), }) self.assertEqual( get_free_space_map(current=True, scheduled=True), { '/': Size("100 KiB"), '/tmp': Size("200 KiB"), '/mnt/sysroot': Size("300 KiB"), '/mnt/sysroot/boot': Size("400 KiB"), }) self.assertEqual(get_free_space_map(current=False, scheduled=False), {})
def test_get_free_space_image(self, exec_mock, conf_mock, statvfs_mock): """Test the get_free_space function.""" output = """ Mounted on Avail / 100 /boot 200 """ exec_mock.return_value = dedent(output).strip() conf_mock.target.is_hardware = False statvfs_mock.return_value = Mock(f_frsize=1024, f_bfree=300) assert get_free_space_map() == { '/': Size("100 KiB"), '/boot': Size("200 KiB"), '/var/tmp': Size("300 KiB"), }