def test_fetch_image(self, mock_images): context = 'opaque context' target = '/tmp/targetfile' image_id = '4' libvirt_utils.fetch_image(context, target, image_id) mock_images.assert_called_once_with( context, image_id, target)
def test_fetch_image(self, mock_images): context = "opaque context" target = "/tmp/targetfile" image_id = "4" user_id = "fake" project_id = "fake" libvirt_utils.fetch_image(context, target, image_id, user_id, project_id) mock_images.assert_called_once_with(context, image_id, target, user_id, project_id, max_size=0)
def test_cache_image_with_clean(self): self.mox.StubOutWithMock(libvirt_utils, "fetch_image") temp_f, temp_file = tempfile.mkstemp() libvirt_utils.fetch_image(None, temp_file, None, None, None) self.mox.ReplayAll() utils.cache_image(None, temp_file, None, None, None, clean=True) self.mox.VerifyAll() self.assertFalse(os.path.exists(temp_file))
def test_fetch_image(self, mock_images): context = 'opaque context' target = '/tmp/targetfile' image_id = '4' trusted_certs = objects.TrustedCerts( ids=['0b5d2c72-12cc-4ba6-a8d7-3ff5cc1d8cb8', '674736e3-f25c-405c-8362-bbf991e0ce0a']) libvirt_utils.fetch_image(context, target, image_id, trusted_certs) mock_images.assert_called_once_with( context, image_id, target, trusted_certs)
def test_fetch_image(self, mock_images): context = 'opaque context' target = '/tmp/targetfile' image_id = '4' user_id = 'fake' project_id = 'fake' libvirt_utils.fetch_image(context, target, image_id, user_id, project_id) mock_images.assert_called_once_with( context, image_id, target, user_id, project_id, max_size=0)
def test_fetch_image(self): self.mox.StubOutWithMock(images, "fetch_to_raw") context = "opaque context" target = "/tmp/targetfile" image_id = "4" user_id = "fake" project_id = "fake" images.fetch_to_raw(context, image_id, target, user_id, project_id, max_size=0) self.mox.ReplayAll() libvirt_utils.fetch_image(context, target, image_id, user_id, project_id)
def test_fetch_image(self): self.mox.StubOutWithMock(images, 'fetch_to_raw') context = 'opaque context' target = '/tmp/targetfile' image_id = '4' user_id = 'fake' project_id = 'fake' images.fetch_to_raw(context, image_id, target, user_id, project_id, max_size=0) self.mox.ReplayAll() libvirt_utils.fetch_image(context, target, image_id, user_id, project_id)
def cache_image(context, target, image_id, user_id, project_id): if not os.path.exists(target): libvirt_utils.fetch_image(context, target, image_id, user_id, project_id)
def _cache_image_x(context, target, image_id, user_id, project_id): if not os.path.exists(target): libvirt_utils.fetch_image(context, target, image_id, user_id, project_id)
def cache_image(context, target, image_id, user_id, project_id, clean=False): if clean and os.path.exists(target): os.unlink(target) if not os.path.exists(target): libvirt_utils.fetch_image(context, target, image_id, user_id, project_id)