summaryrefslogtreecommitdiff
path: root/openstackclient/tests/unit/image/v2/fakes.py
diff options
context:
space:
mode:
authorStephen Finucane <sfinucan@redhat.com>2022-07-07 12:31:44 +0100
committerStephen Finucane <sfinucan@redhat.com>2022-09-21 10:43:35 +0100
commitc9d445fc4baf036793103b15c9eb2632da3610e0 (patch)
treea01d18f8989025ab5442740d40a5a23d98ef81c5 /openstackclient/tests/unit/image/v2/fakes.py
parentd163a2090471c8f90c8ad84827fb97dfbf06280b (diff)
downloadpython-openstackclient-c9d445fc4baf036793103b15c9eb2632da3610e0.tar.gz
image: Add 'image task list' command
This replaces the 'glance task-list' command. $ openstack image task list We also indicate that the 'image task create' command will never be implemented. This is an admin-only API that isn't really intended to be used by humans thus it does not need an OSC command implementation. Change-Id: Id8a943a5443782fc70c0fbf3639f5aa17b9d30af
Diffstat (limited to 'openstackclient/tests/unit/image/v2/fakes.py')
-rw-r--r--openstackclient/tests/unit/image/v2/fakes.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/openstackclient/tests/unit/image/v2/fakes.py b/openstackclient/tests/unit/image/v2/fakes.py
index 2decd122..f2015450 100644
--- a/openstackclient/tests/unit/image/v2/fakes.py
+++ b/openstackclient/tests/unit/image/v2/fakes.py
@@ -52,6 +52,9 @@ class FakeImagev2Client:
self.management_url = kwargs['endpoint']
self.version = 2.0
+ self.tasks = mock.Mock()
+ self.tasks.resource_class = fakes.FakeResource(None, {})
+
class TestImagev2(utils.TestCommand):
@@ -176,10 +179,26 @@ def create_one_task(attrs=None):
# https://github.com/openstack/glance/blob/24.0.0/glance/api/v2/tasks.py#L186-L190
'type': 'import',
'updated_at': '2016-06-29T16:13:07Z',
-
}
# Overwrite default attributes if there are some attributes set
task_info.update(attrs)
return task.Task(**task_info)
+
+
+def create_tasks(attrs=None, count=2):
+ """Create multiple fake tasks.
+
+ :param attrs: A dictionary with all attributes of Task
+ :type attrs: dict
+ :param count: The number of tasks to be faked
+ :type count: int
+ :return: A list of fake Task objects
+ :rtype: list
+ """
+ tasks = []
+ for n in range(0, count):
+ tasks.append(create_one_task(attrs))
+
+ return tasks