Exemple #1
0
    def test_calculate_free_space(self):
        dev_info = mock.Mock()
        dev_info.f_bsize = 1048576
        dev_info.f_bavail = 2
        with patch.object(os, 'statvfs', return_value=dev_info) as st_mock:
            self.assertEqual(calculate_free_space('/tmp/dir/file'), 2)

        st_mock.assert_called_once_with('/tmp/dir')
Exemple #2
0
    def _check_free_space(self):
        """Check `self.dst_path` free space

        :raises: errors.NotEnoughFreeSpace
        """
        free_space = calculate_free_space(self.dst_path)
        if free_space < self.required_free_space:
            raise errors.NotEnoughFreeSpace(
                u'Not enough free space, path - "{0}", '
                'free space - "{1}", '
                'required free space - "{2}"'.format(self.dst_path, free_space,
                                                     self.required_free_space))