summaryrefslogtreecommitdiff
path: root/openstackclient/tests/unit/image/v2/fakes.py
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2022-09-30 11:59:21 +0000
committerGerrit Code Review <review@openstack.org>2022-09-30 11:59:21 +0000
commit46ead4abea4296a86e862fc035811eba2c7efac4 (patch)
treed214f5a92c829b78ec7ab8bc8eaf62b79282c067 /openstackclient/tests/unit/image/v2/fakes.py
parent97af1b661e96f2d6359898f7959a7bfd78657953 (diff)
parentc9d445fc4baf036793103b15c9eb2632da3610e0 (diff)
downloadpython-openstackclient-46ead4abea4296a86e862fc035811eba2c7efac4.tar.gz
Merge "image: Add 'image task list' command"
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