summaryrefslogtreecommitdiff
path: root/openstackclient/tests/unit/image/v1/fakes.py
diff options
context:
space:
mode:
authorStephen Finucane <sfinucan@redhat.com>2021-11-17 10:35:51 +0000
committerStephen Finucane <sfinucan@redhat.com>2021-11-17 11:34:42 +0000
commit2135a9ea05c79a11185ca87f6bb5ade3b71501bb (patch)
tree8d9dd5543f988ab13a6b3db04229457f5f295606 /openstackclient/tests/unit/image/v1/fakes.py
parent690e9a13a232f522162adc109d32c8eee864814e (diff)
downloadpython-openstackclient-2135a9ea05c79a11185ca87f6bb5ade3b71501bb.tar.gz
image: Remove FakeImage test helper
We're no longer creating fake versions of glanceclient's 'Resource' object but rather openstacksdk objects. As such, there's no point nesting things under a fake resource class. Change-Id: I39cd5302622f4542db9eebcccfad0cb90d077441 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
Diffstat (limited to 'openstackclient/tests/unit/image/v1/fakes.py')
-rw-r--r--openstackclient/tests/unit/image/v1/fakes.py74
1 files changed, 33 insertions, 41 deletions
diff --git a/openstackclient/tests/unit/image/v1/fakes.py b/openstackclient/tests/unit/image/v1/fakes.py
index 59ae5f7a..3097a42f 100644
--- a/openstackclient/tests/unit/image/v1/fakes.py
+++ b/openstackclient/tests/unit/image/v1/fakes.py
@@ -22,10 +22,6 @@ from openstackclient.tests.unit import utils
from openstackclient.tests.unit.volume.v1 import fakes as volume_fakes
-image_id = 'im1'
-image_name = 'graven'
-
-
class FakeImagev1Client(object):
def __init__(self, **kwargs):
@@ -51,40 +47,36 @@ class TestImagev1(utils.TestCommand):
)
-class FakeImage(object):
- """Fake one or more images."""
-
- @staticmethod
- def create_one_image(attrs=None):
- """Create a fake image.
-
- :param Dictionary attrs:
- A dictionary with all attrbutes of image
- :return:
- A FakeResource object with id, name, owner, protected,
- visibility and tags attrs
- """
- attrs = attrs or {}
-
- # Set default attribute
- image_info = {
- 'id': str(uuid.uuid4()),
- 'name': 'image-name' + uuid.uuid4().hex,
- 'owner': 'image-owner' + uuid.uuid4().hex,
- 'container_format': '',
- 'disk_format': '',
- 'min_disk': 0,
- 'min_ram': 0,
- 'is_public': True,
- 'protected': False,
- 'properties': {
- 'Alpha': 'a',
- 'Beta': 'b',
- 'Gamma': 'g'},
- 'status': 'status' + uuid.uuid4().hex
- }
-
- # Overwrite default attributes if there are some attributes set
- image_info.update(attrs)
-
- return image.Image(**image_info)
+def create_one_image(attrs=None):
+ """Create a fake image.
+
+ :param Dictionary attrs:
+ A dictionary with all attrbutes of image
+ :return:
+ A FakeResource object with id, name, owner, protected,
+ visibility and tags attrs
+ """
+ attrs = attrs or {}
+
+ # Set default attribute
+ image_info = {
+ 'id': str(uuid.uuid4()),
+ 'name': 'image-name' + uuid.uuid4().hex,
+ 'owner': 'image-owner' + uuid.uuid4().hex,
+ 'container_format': '',
+ 'disk_format': '',
+ 'min_disk': 0,
+ 'min_ram': 0,
+ 'is_public': True,
+ 'protected': False,
+ 'properties': {
+ 'Alpha': 'a',
+ 'Beta': 'b',
+ 'Gamma': 'g'},
+ 'status': 'status' + uuid.uuid4().hex
+ }
+
+ # Overwrite default attributes if there are some attributes set
+ image_info.update(attrs)
+
+ return image.Image(**image_info)