summaryrefslogtreecommitdiff
path: root/openstackclient/tests/unit/image/v2/fakes.py
diff options
context:
space:
mode:
authorArtem Goncharov <artem.goncharov@gmail.com>2019-09-13 18:03:15 +0200
committerMonty Taylor <mordred@inaugust.com>2020-03-23 14:38:32 -0500
commit60e7c51df4cf061ebbb435a959ad63c7d3a296bf (patch)
tree1c974aae914cd316ac90be5f5bca2cae9531e466 /openstackclient/tests/unit/image/v2/fakes.py
parentfc12033f1da53fe11f930dd405eae5e2bf814621 (diff)
downloadpython-openstackclient-60e7c51df4cf061ebbb435a959ad63c7d3a296bf.tar.gz
Switch image to use SDK
This is a work to switch OSC from using glanceclient to OpenStackSDK. With this change only v2 is using OpenStackSDK. V1 is still using glanceclient and will be switched in a separate change. Remove the direct depend on keystoneauth- let that flow through openstacksdk. Depends-on: https://review.opendev.org/#/c/698972 Change-Id: I36f292fb70c98f6e558f58be55d533d979c47ca7
Diffstat (limited to 'openstackclient/tests/unit/image/v2/fakes.py')
-rw-r--r--openstackclient/tests/unit/image/v2/fakes.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/openstackclient/tests/unit/image/v2/fakes.py b/openstackclient/tests/unit/image/v2/fakes.py
index 655ae341..516d5630 100644
--- a/openstackclient/tests/unit/image/v2/fakes.py
+++ b/openstackclient/tests/unit/image/v2/fakes.py
@@ -18,9 +18,9 @@ import random
from unittest import mock
import uuid
-from glanceclient.v2 import schemas
+from openstack.image.v2 import image
+from openstack.image.v2 import member
from osc_lib.cli import format_columns
-import warlock
from openstackclient.tests.unit import fakes
from openstackclient.tests.unit.identity.v3 import fakes as identity_fakes
@@ -154,6 +154,12 @@ class FakeImagev2Client(object):
self.image_members.resource_class = fakes.FakeResource(None, {})
self.image_tags = mock.Mock()
self.image_tags.resource_class = fakes.FakeResource(None, {})
+
+ self.find_image = mock.Mock()
+ self.find_image.resource_class = fakes.FakeResource(None, {})
+
+ self.get_image = mock.Mock()
+ self.get_image.resource_class = fakes.FakeResource(None, {})
self.auth_token = kwargs['token']
self.management_url = kwargs['endpoint']
self.version = 2.0
@@ -197,8 +203,8 @@ class FakeImage(object):
image_info = {
'id': str(uuid.uuid4()),
'name': 'image-name' + uuid.uuid4().hex,
- 'owner': 'image-owner' + uuid.uuid4().hex,
- 'protected': bool(random.choice([0, 1])),
+ 'owner_id': 'image-owner' + uuid.uuid4().hex,
+ 'is_protected': bool(random.choice([0, 1])),
'visibility': random.choice(['public', 'private']),
'tags': [uuid.uuid4().hex for r in range(2)],
}
@@ -206,13 +212,7 @@ class FakeImage(object):
# Overwrite default attributes if there are some attributes set
image_info.update(attrs)
- # Set up the schema
- model = warlock.model_factory(
- IMAGE_schema,
- schemas.SchemaBasedModel,
- )
-
- return model(**image_info)
+ return image.Image(**image_info)
@staticmethod
def create_images(attrs=None, count=2):
@@ -307,6 +307,8 @@ class FakeImage(object):
# Overwrite default attributes if there are some attributes set
image_member_info.update(attrs)
+ return member.Member(**image_member_info)
+
image_member = fakes.FakeModel(
copy.deepcopy(image_member_info))