Exemplo n.º 1
0
 def test__fetch(self, mock_clean, mock_raw, mock_fetch, mock_size):
     mock_size.return_value = 100
     image_cache._fetch('fake', 'fake-uuid', '/foo/bar', force_raw=True)
     mock_fetch.assert_called_once_with('fake', 'fake-uuid',
                                        '/foo/bar.part', force_raw=False)
     mock_clean.assert_called_once_with('/foo', 100)
     mock_raw.assert_called_once_with('fake-uuid', '/foo/bar',
                                      '/foo/bar.part')
Exemplo n.º 2
0
 def test__fetch(self, mock_clean, mock_raw, mock_fetch, mock_size):
     mock_size.return_value = 100
     image_cache._fetch('fake', 'fake-uuid', '/foo/bar', force_raw=True)
     mock_fetch.assert_called_once_with('fake', 'fake-uuid',
                                        '/foo/bar.part', force_raw=False)
     mock_clean.assert_called_once_with('/foo', 100)
     mock_raw.assert_called_once_with('fake-uuid', '/foo/bar',
                                      '/foo/bar.part')
Exemplo n.º 3
0
 def test__fetch_already_raw(
         self, mock_clean, mock_will_convert, mock_raw, mock_fetch,
         mock_size):
     image_cache._fetch('fake', 'fake-uuid', '/foo/bar', force_raw=True)
     mock_fetch.assert_called_once_with('fake', 'fake-uuid',
                                        '/foo/bar.part', force_raw=False)
     mock_clean.assert_not_called()
     mock_size.assert_not_called()
     mock_raw.assert_called_once_with('fake-uuid', '/foo/bar',
                                      '/foo/bar.part')
     mock_will_convert.assert_called_once_with('fake-uuid', '/foo/bar.part')
Exemplo n.º 4
0
    def test__fetch_estimate_fallback(
            self, mock_clean, mock_will_convert, mock_raw, mock_fetch,
            mock_size):
        mock_size.side_effect = [100, 10]
        mock_clean.side_effect = [exception.InsufficientDiskSpace(), None]

        image_cache._fetch('fake', 'fake-uuid', '/foo/bar', force_raw=True)
        mock_fetch.assert_called_once_with('fake', 'fake-uuid',
                                           '/foo/bar.part', force_raw=False)
        mock_size.assert_has_calls([
            mock.call('/foo/bar.part', estimate=False),
            mock.call('/foo/bar.part', estimate=True),
        ])
        mock_clean.assert_has_calls([
            mock.call('/foo', 100),
            mock.call('/foo', 10),
        ])
        mock_raw.assert_called_once_with('fake-uuid', '/foo/bar',
                                         '/foo/bar.part')
        mock_will_convert.assert_called_once_with('fake-uuid', '/foo/bar.part')