Exemplo n.º 1
0
 def test_delete_with_backends_deletes(self):
     task = import_flow._DeleteFromFS(TASK_ID1, TASK_TYPE)
     self.config(enabled_backends='file:foo')
     with mock.patch.object(import_flow.store_api, 'delete') as mock_del:
         task.execute(mock.sentinel.path)
         mock_del.assert_called_once_with(mock.sentinel.path,
                                          'os_glance_staging_store')
Exemplo n.º 2
0
 def test_web_download_delete_staging_image_succeed(self, mock_exists):
     mock_exists.return_value = True
     staging_path = "file:///tmp/staging/temp-image"
     delete_from_fs_task = api_image_import._DeleteFromFS(
         self.task.task_id, self.task_type)
     with mock.patch.object(os, "unlink") as mock_unlik:
         delete_from_fs_task.execute(staging_path)
         self.assertEqual(1, mock_exists.call_count)
         self.assertEqual(1, mock_unlik.call_count)
Exemplo n.º 3
0
 def test_web_download_delete_staging_image_succeed(self, mock_exists):
     mock_exists.return_value = True
     staging_path = "file:///tmp/staging/temp-image"
     delete_from_fs_task = api_image_import._DeleteFromFS(
         self.task.task_id, self.task_type)
     with mock.patch.object(os, "unlink") as mock_unlik:
         delete_from_fs_task.execute(staging_path)
         self.assertEqual(1, mock_exists.call_count)
         self.assertEqual(1, mock_unlik.call_count)
Exemplo n.º 4
0
    def test_delete_without_backends_exists(self, mock_unlink, mock_exists):
        mock_exists.return_value = True
        task = import_flow._DeleteFromFS(TASK_ID1, TASK_TYPE)
        task.execute('1234567foo')
        # FIXME(danms): I have no idea why the code arbitrarily snips
        # the first seven characters from the path. Need a comment or
        # *something*.
        mock_unlink.assert_called_once_with('foo')

        mock_unlink.reset_mock()
        mock_unlink.side_effect = OSError(123, 'failed')
        # Make sure we swallow the OSError and don't explode
        task.execute('1234567foo')
Exemplo n.º 5
0
    def test_delete_with_backends_delete_fails(self):
        self.config(enabled_backends='file:foo')
        task = import_flow._DeleteFromFS(TASK_ID1, TASK_TYPE)
        with mock.patch.object(import_flow.store_api, 'delete') as mock_del:
            mock_del.side_effect = store_exceptions.NotFound(image=IMAGE_ID1,
                                                             message='Testing')
            # If we didn't swallow this we would explode here
            task.execute(mock.sentinel.path)
            mock_del.assert_called_once_with(mock.sentinel.path,
                                             'os_glance_staging_store')

            # Raise something unexpected and make sure it bubbles up
            mock_del.side_effect = RuntimeError
            self.assertRaises(RuntimeError, task.execute, mock.sentinel.path)
Exemplo n.º 6
0
 def test_delete_without_backends_missing(self, mock_unlink, mock_exists):
     mock_exists.return_value = False
     task = import_flow._DeleteFromFS(TASK_ID1, TASK_TYPE)
     task.execute('foo')
     mock_unlink.assert_not_called()