Skip to content

Commit 86cae7e

Browse files
author
Tang Chen
committed
Add functional tests for "image" command v2
The tests for image v2 are quite similar to the tests for v1. The only difference things are: 1. v2 "image set" command only allows to change the disk format for a queued image 2. v2 "image show" command output is different from v1 Change-Id: Ieb6bec7467887aab567743153ea3181afa49537d
1 parent 5a978b9 commit 86cae7e

2 files changed

Lines changed: 67 additions & 0 deletions

File tree

functional/tests/image/v2/__init__.py

Whitespace-only changes.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
2+
# not use this file except in compliance with the License. You may obtain
3+
# a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10+
# License for the specific language governing permissions and limitations
11+
# under the License.
12+
13+
import os
14+
import uuid
15+
16+
from functional.common import test
17+
18+
19+
class ImageTests(test.TestCase):
20+
"""Functional tests for image. """
21+
22+
NAME = uuid.uuid4().hex
23+
OTHER_NAME = uuid.uuid4().hex
24+
HEADERS = ['Name']
25+
FIELDS = ['name']
26+
27+
@classmethod
28+
def setUpClass(cls):
29+
os.environ['OS_IMAGE_API_VERSION'] = '2'
30+
opts = cls.get_show_opts(cls.FIELDS)
31+
raw_output = cls.openstack('image create ' + cls.NAME + opts)
32+
expected = cls.NAME + '\n'
33+
cls.assertOutput(expected, raw_output)
34+
35+
@classmethod
36+
def tearDownClass(cls):
37+
# Rename test
38+
raw_output = cls.openstack('image set --name ' + cls.OTHER_NAME + ' '
39+
+ cls.NAME)
40+
cls.assertOutput('', raw_output)
41+
# Delete test
42+
raw_output = cls.openstack('image delete ' + cls.OTHER_NAME)
43+
cls.assertOutput('', raw_output)
44+
45+
def test_image_list(self):
46+
opts = self.get_list_opts(self.HEADERS)
47+
raw_output = self.openstack('image list' + opts)
48+
self.assertIn(self.NAME, raw_output)
49+
50+
def test_image_show(self):
51+
opts = self.get_show_opts(self.FIELDS)
52+
raw_output = self.openstack('image show ' + self.NAME + opts)
53+
self.assertEqual(self.NAME + "\n", raw_output)
54+
55+
def test_image_set(self):
56+
opts = self.get_show_opts([
57+
"disk_format", "visibility", "min_disk", "min_ram", "name"])
58+
self.openstack('image set --min-disk 4 --min-ram 5 ' +
59+
'--public ' + self.NAME)
60+
raw_output = self.openstack('image show ' + self.NAME + opts)
61+
self.assertEqual("raw\n4\n5\n" + self.NAME + '\npublic\n', raw_output)
62+
63+
def test_image_metadata(self):
64+
opts = self.get_show_opts(["name", "properties"])
65+
self.openstack('image set --property a=b --property c=d ' + self.NAME)
66+
raw_output = self.openstack('image show ' + self.NAME + opts)
67+
self.assertEqual(self.NAME + "\na='b', c='d'\n", raw_output)

0 commit comments

Comments
 (0)