summaryrefslogtreecommitdiff
path: root/openstackclient/tests/unit/image/v1
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
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')
-rw-r--r--openstackclient/tests/unit/image/v1/fakes.py74
-rw-r--r--openstackclient/tests/unit/image/v1/test_image.py11
2 files changed, 38 insertions, 47 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)
diff --git a/openstackclient/tests/unit/image/v1/test_image.py b/openstackclient/tests/unit/image/v1/test_image.py
index 5c69bf0f..06519800 100644
--- a/openstackclient/tests/unit/image/v1/test_image.py
+++ b/openstackclient/tests/unit/image/v1/test_image.py
@@ -34,7 +34,7 @@ class TestImage(image_fakes.TestImagev1):
class TestImageCreate(TestImage):
- new_image = image_fakes.FakeImage.create_one_image()
+ new_image = image_fakes.create_one_image()
columns = (
'container_format',
'disk_format',
@@ -210,7 +210,7 @@ class TestImageCreate(TestImage):
class TestImageDelete(TestImage):
- _image = image_fakes.FakeImage.create_one_image()
+ _image = image_fakes.create_one_image()
def setUp(self):
super(TestImageDelete, self).setUp()
@@ -239,7 +239,7 @@ class TestImageDelete(TestImage):
class TestImageList(TestImage):
- _image = image_fakes.FakeImage.create_one_image()
+ _image = image_fakes.create_one_image()
columns = (
'ID',
@@ -443,7 +443,7 @@ class TestImageList(TestImage):
class TestImageSet(TestImage):
- _image = image_fakes.FakeImage.create_one_image()
+ _image = image_fakes.create_one_image()
def setUp(self):
super(TestImageSet, self).setUp()
@@ -682,8 +682,7 @@ class TestImageSet(TestImage):
class TestImageShow(TestImage):
- _image = image_fakes.FakeImage.create_one_image(
- attrs={'size': 2000})
+ _image = image_fakes.create_one_image(attrs={'size': 2000})
columns = (
'container_format',
'disk_format',