summaryrefslogtreecommitdiff
path: root/glanceclient/tests/unit
diff options
context:
space:
mode:
authorLi Wei <wei.li@easystack.cn>2016-09-27 16:16:05 +0800
committerChangBo Guo(gcb) <glongwave@gmail.com>2017-01-10 07:41:02 +0000
commitefb5e2aa32db3f36557abdb1ddf85709b116e746 (patch)
tree15f3f0bfc1fee3ae7aa1b7ca3a67e378118f5191 /glanceclient/tests/unit
parentfa11427af53595532124c74991ddcee6a89624ff (diff)
downloadpython-glanceclient-efb5e2aa32db3f36557abdb1ddf85709b116e746.tar.gz
Add vhdx in disk_format
vhdx is also a format of the disk valid value in v2 version, so add it in disk_format. Related-Bug: 1635518 Co-Authored-By: Stuart McLaren <stuart.mclaren@hpe.com> Change-Id: I7d82d4a4bdb180a53e86552f6f6b3bed908e6dc0
Diffstat (limited to 'glanceclient/tests/unit')
-rw-r--r--glanceclient/tests/unit/v2/fixtures.py24
-rw-r--r--glanceclient/tests/unit/v2/test_client_requests.py32
-rw-r--r--glanceclient/tests/unit/v2/test_shell_v2.py4
3 files changed, 58 insertions, 2 deletions
diff --git a/glanceclient/tests/unit/v2/fixtures.py b/glanceclient/tests/unit/v2/fixtures.py
index e4ece7e..daf7d35 100644
--- a/glanceclient/tests/unit/v2/fixtures.py
+++ b/glanceclient/tests/unit/v2/fixtures.py
@@ -68,6 +68,30 @@ image_show_fixture = {
"visibility": "private"
}
+image_create_fixture = {
+ "checksum": "9cb02fe7fcac26f8a25d6db3109063ae",
+ "container_format": "bare",
+ "created_at": "2015-07-24T12:18:13Z",
+ "disk_format": "raw",
+ "file": "/v2/images/%s/file" % UUID,
+ "id": UUID,
+ "kernel_id": "af81fccd-b2e8-4232-886c-aa98dda22882",
+ "min_disk": 0,
+ "min_ram": 0,
+ "name": "img1",
+ "owner": "411423405e10431fb9c47ac5b2446557",
+ "protected": False,
+ "ramdisk_id": "fdb3f864-9458-4185-bd26-5d27fe6b6adf",
+ "schema": "/v2/schemas/image",
+ "self": "/v2/images/%s" % UUID,
+ "size": 145,
+ "status": "active",
+ "tags": [],
+ "updated_at": "2015-07-24T12:18:13Z",
+ "virtual_size": 123,
+ "visibility": "private"
+}
+
schema_fixture = {
"additionalProperties": {
"type": "string"
diff --git a/glanceclient/tests/unit/v2/test_client_requests.py b/glanceclient/tests/unit/v2/test_client_requests.py
index 2332619..5c97689 100644
--- a/glanceclient/tests/unit/v2/test_client_requests.py
+++ b/glanceclient/tests/unit/v2/test_client_requests.py
@@ -17,10 +17,12 @@
from requests_mock.contrib import fixture as rm_fixture
from glanceclient import client
+from glanceclient.tests.unit.v2.fixtures import image_create_fixture
from glanceclient.tests.unit.v2.fixtures import image_list_fixture
from glanceclient.tests.unit.v2.fixtures import image_show_fixture
from glanceclient.tests.unit.v2.fixtures import schema_fixture
from glanceclient.tests import utils as testutils
+from glanceclient.v2.image_schema import _BASE_SCHEMA
class ClientTestRequests(testutils.TestCase):
@@ -52,3 +54,33 @@ class ClientTestRequests(testutils.TestCase):
gc = client.Client(2.2, "http://example.com/v2.1")
img = gc.images.get(image_show_fixture['id'])
self.assertEqual(image_show_fixture['checksum'], img['checksum'])
+
+ def test_invalid_disk_format(self):
+ self.requests = self.useFixture(rm_fixture.Fixture())
+ self.requests.get('http://example.com/v2/schemas/image',
+ json=_BASE_SCHEMA)
+ self.requests.post('http://example.com/v2/images',
+ json=image_create_fixture)
+ self.requests.get('http://example.com/v2/images/%s'
+ % image_show_fixture['id'],
+ json=image_show_fixture)
+ gc = client.Client(2.2, "http://example.com/v2.1")
+ fields = {"disk_format": "qbull2"}
+ try:
+ gc.images.create(**fields)
+ self.fail("Failed to raise exception when using bad disk format")
+ except TypeError:
+ pass
+
+ def test_valid_disk_format(self):
+ self.requests = self.useFixture(rm_fixture.Fixture())
+ self.requests.get('http://example.com/v2/schemas/image',
+ json=_BASE_SCHEMA)
+ self.requests.post('http://example.com/v2/images',
+ json=image_create_fixture)
+ self.requests.get('http://example.com/v2/images/%s'
+ % image_show_fixture['id'],
+ json=image_show_fixture)
+ gc = client.Client(2.2, "http://example.com/v2.1")
+ fields = {"disk_format": "vhdx"}
+ gc.images.create(**fields)
diff --git a/glanceclient/tests/unit/v2/test_shell_v2.py b/glanceclient/tests/unit/v2/test_shell_v2.py
index e79a42c..407775d 100644
--- a/glanceclient/tests/unit/v2/test_shell_v2.py
+++ b/glanceclient/tests/unit/v2/test_shell_v2.py
@@ -45,8 +45,8 @@ def schema_args(schema_getter, omit=None):
'type': 'string',
'description': 'Format of the container'},
'disk_format': {
- 'enum': [None, 'ami', 'ari', 'aki', 'vhd', 'vmdk', 'raw',
- 'qcow2', 'vdi', 'iso'],
+ 'enum': [None, 'ami', 'ari', 'aki', 'vhd', 'vhdx', 'vmdk',
+ 'raw', 'qcow2', 'vdi', 'iso'],
'type': 'string',
'description': 'Format of the disk'},
'location': {'type': 'string'},