summaryrefslogtreecommitdiff
path: root/glanceclient/tests/unit/v2/test_images.py
diff options
context:
space:
mode:
Diffstat (limited to 'glanceclient/tests/unit/v2/test_images.py')
-rw-r--r--glanceclient/tests/unit/v2/test_images.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/glanceclient/tests/unit/v2/test_images.py b/glanceclient/tests/unit/v2/test_images.py
index 55610d8..199d6ec 100644
--- a/glanceclient/tests/unit/v2/test_images.py
+++ b/glanceclient/tests/unit/v2/test_images.py
@@ -20,6 +20,7 @@ from unittest import mock
import ddt
+from glanceclient.common import utils as common_utils
from glanceclient import exc
from glanceclient.tests.unit.v2 import base
from glanceclient.tests import utils
@@ -674,6 +675,19 @@ data_fixtures = {
]},
),
},
+ '/v2/images/3a4560a1-e585-443e-9b39-553b46ec92d1/tasks': {
+ 'GET': (
+ {},
+ {'tasks': [
+ {
+ 'id': '6f99bf80-2ee6-47cf-acfe-1f1fabb7e810',
+ 'status': 'succeed',
+ 'message': 'Copied 44 MiB',
+ 'updated_at': '2021-03-01T18:28:26.000000'
+ }
+ ]},
+ ),
+ },
}
schema_fixtures = {
@@ -715,6 +729,22 @@ class TestController(testtools.TestCase):
self.controller = base.BaseController(self.api, self.schema_api,
images.Controller)
+ def test_image_tasks_supported(self):
+ with mock.patch.object(common_utils,
+ 'has_version') as mock_has_version:
+ mock_has_version.return_value = True
+ image_tasks = self.controller.get_associated_image_tasks(
+ '3a4560a1-e585-443e-9b39-553b46ec92d1')
+ self.assertEqual(1, len(image_tasks['tasks']))
+
+ def test_image_tasks_not_supported(self):
+ with mock.patch.object(common_utils,
+ 'has_version') as mock_has_version:
+ mock_has_version.return_value = False
+ self.assertRaises(exc.HTTPNotImplemented,
+ self.controller.get_associated_image_tasks,
+ '3a4560a1-e585-443e-9b39-553b46ec92d1')
+
def test_list_images(self):
images = self.controller.list()
self.assertEqual('3a4560a1-e585-443e-9b39-553b46ec92d1', images[0].id)