Skip to content

Commit 690e9a1

Browse files
committed
image: Remove dead test helper methods
These haven't been used since we switched the image commands from glanceclient to openstacksdk. There's more cleanup to be done here but that can be done later. Change-Id: I3de1f24323886b122b3a30660fb3de18eb7014e9 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
1 parent 8b394e5 commit 690e9a1

2 files changed

Lines changed: 0 additions & 204 deletions

File tree

openstackclient/tests/unit/image/v1/fakes.py

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
1212
# License for the specific language governing permissions and limitations
1313
# under the License.
14-
#
1514

1615
from unittest import mock
1716
import uuid
@@ -25,36 +24,6 @@
2524

2625
image_id = 'im1'
2726
image_name = 'graven'
28-
image_owner = 'baal'
29-
image_protected = False
30-
image_public = True
31-
image_properties = {
32-
'Alpha': 'a',
33-
'Beta': 'b',
34-
'Gamma': 'g',
35-
}
36-
image_properties_str = "Alpha='a', Beta='b', Gamma='g'"
37-
image_data = 'line 1\nline 2\n'
38-
image_size = 0
39-
40-
IMAGE = {
41-
'id': image_id,
42-
'name': image_name,
43-
'container_format': '',
44-
'disk_format': '',
45-
'owner': image_owner,
46-
'min_disk': 0,
47-
'min_ram': 0,
48-
'is_public': image_public,
49-
'protected': image_protected,
50-
'properties': image_properties,
51-
'size': image_size,
52-
}
53-
54-
IMAGE_columns = tuple(sorted(IMAGE))
55-
IMAGE_output = dict(IMAGE)
56-
IMAGE_output['properties'] = image_properties_str
57-
IMAGE_data = tuple((IMAGE_output[x] for x in sorted(IMAGE_output)))
5827

5928

6029
class FakeImagev1Client(object):

openstackclient/tests/unit/image/v2/fakes.py

Lines changed: 0 additions & 173 deletions
Original file line numberDiff line numberDiff line change
@@ -11,138 +11,20 @@
1111
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
1212
# License for the specific language governing permissions and limitations
1313
# under the License.
14-
#
1514

16-
import copy
1715
import random
1816
from unittest import mock
1917
import uuid
2018

2119
from openstack.image.v2 import image
2220
from openstack.image.v2 import member
23-
from osc_lib.cli import format_columns
2421

2522
from openstackclient.tests.unit import fakes
2623
from openstackclient.tests.unit.identity.v3 import fakes as identity_fakes
2724
from openstackclient.tests.unit import utils
2825

2926
image_id = '0f41529e-7c12-4de8-be2d-181abb825b3c'
3027
image_name = 'graven'
31-
image_owner = 'baal'
32-
image_protected = False
33-
image_visibility = 'public'
34-
image_tags = []
35-
image_size = 0
36-
37-
IMAGE = {
38-
'id': image_id,
39-
'name': image_name,
40-
'owner': image_owner,
41-
'protected': image_protected,
42-
'visibility': image_visibility,
43-
'tags': image_tags,
44-
'size': image_size
45-
}
46-
47-
IMAGE_columns = tuple(sorted(IMAGE))
48-
IMAGE_data = tuple((IMAGE[x] for x in sorted(IMAGE)))
49-
50-
IMAGE_SHOW = copy.copy(IMAGE)
51-
IMAGE_SHOW['tags'] = format_columns.ListColumn(IMAGE_SHOW['tags'])
52-
IMAGE_SHOW_data = tuple((IMAGE_SHOW[x] for x in sorted(IMAGE_SHOW)))
53-
54-
# Just enough v2 schema to do some testing
55-
IMAGE_schema = {
56-
"additionalProperties": {
57-
"type": "string"
58-
},
59-
"name": "image",
60-
"links": [
61-
{
62-
"href": "{self}",
63-
"rel": "self"
64-
},
65-
{
66-
"href": "{file}",
67-
"rel": "enclosure"
68-
},
69-
{
70-
"href": "{schema}",
71-
"rel": "describedby"
72-
}
73-
],
74-
"properties": {
75-
"id": {
76-
"pattern": "^([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}$", # noqa
77-
"type": "string",
78-
"description": "An identifier for the image"
79-
},
80-
"name": {
81-
"type": [
82-
"null",
83-
"string"
84-
],
85-
"description": "Descriptive name for the image",
86-
"maxLength": 255
87-
},
88-
"owner": {
89-
"type": [
90-
"null",
91-
"string"
92-
],
93-
"description": "Owner of the image",
94-
"maxLength": 255
95-
},
96-
"protected": {
97-
"type": "boolean",
98-
"description": "If true, image will not be deletable."
99-
},
100-
"self": {
101-
"type": "string",
102-
"description": "(READ-ONLY)"
103-
},
104-
"schema": {
105-
"type": "string",
106-
"description": "(READ-ONLY)"
107-
},
108-
"size": {
109-
"type": [
110-
"null",
111-
"integer",
112-
"string"
113-
],
114-
"description": "Size of image file in bytes (READ-ONLY)"
115-
},
116-
"status": {
117-
"enum": [
118-
"queued",
119-
"saving",
120-
"active",
121-
"killed",
122-
"deleted",
123-
"pending_delete"
124-
],
125-
"type": "string",
126-
"description": "Status of the image (READ-ONLY)"
127-
},
128-
"tags": {
129-
"items": {
130-
"type": "string",
131-
"maxLength": 255
132-
},
133-
"type": "array",
134-
"description": "List of strings related to the image"
135-
},
136-
"visibility": {
137-
"enum": [
138-
"public",
139-
"private"
140-
],
141-
"type": "string",
142-
"description": "Scope of image accessibility"
143-
},
144-
}
145-
}
14628

14729

14830
class FakeImagev2Client(object):
@@ -231,61 +113,6 @@ def create_images(attrs=None, count=2):
231113

232114
return images
233115

234-
@staticmethod
235-
def get_images(images=None, count=2):
236-
"""Get an iterable MagicMock object with a list of faked images.
237-
238-
If images list is provided, then initialize the Mock object with the
239-
list. Otherwise create one.
240-
241-
:param List images:
242-
A list of FakeResource objects faking images
243-
:param Integer count:
244-
The number of images to be faked
245-
:return:
246-
An iterable Mock object with side_effect set to a list of faked
247-
images
248-
"""
249-
if images is None:
250-
images = FakeImage.create_images(count)
251-
252-
return mock.Mock(side_effect=images)
253-
254-
@staticmethod
255-
def get_image_columns(image=None):
256-
"""Get the image columns from a faked image object.
257-
258-
:param image:
259-
A FakeResource objects faking image
260-
:return:
261-
A tuple which may include the following keys:
262-
('id', 'name', 'owner', 'protected', 'visibility', 'tags')
263-
"""
264-
if image is not None:
265-
return tuple(sorted(image))
266-
return IMAGE_columns
267-
268-
@staticmethod
269-
def get_image_data(image=None):
270-
"""Get the image data from a faked image object.
271-
272-
:param image:
273-
A FakeResource objects faking image
274-
:return:
275-
A tuple which may include the following values:
276-
('image-123', 'image-foo', 'admin', False, 'public', 'bar, baz')
277-
"""
278-
data_list = []
279-
if image is not None:
280-
for x in sorted(image.keys()):
281-
if x == 'tags':
282-
# The 'tags' should be format_list
283-
data_list.append(
284-
format_columns.ListColumn(getattr(image, x)))
285-
else:
286-
data_list.append(getattr(image, x))
287-
return tuple(data_list)
288-
289116
@staticmethod
290117
def create_one_image_member(attrs=None):
291118
"""Create a fake image member.

0 commit comments

Comments
 (0)