From 22e3bf0234049982c83f13d3404ef0aaf6413aec Mon Sep 17 00:00:00 2001 From: zwei Date: Mon, 18 Jan 2016 10:17:14 +0800 Subject: [PATCH] v2 - "readOnly" key should be used in schemas If it has a value of boolean true, this keyword indicates that the instance property SHOULD NOT be changed, and attempts by a user agent to modify the value of this property are expected to be rejected by a server. The value of this keyword MUST be a boolean. The default value is false. Further link for reference: http://json-schema.org/latest/json-schema-hypermedia.html#anchor15 Closes-Bug: #1521581 Depends-On: I279fba4099667d193609a31259057b897380d6f0 Change-Id: I96717506259c0d28500b8747369c47029b1dd9b6 --- glanceclient/tests/unit/test_utils.py | 3 +- glanceclient/tests/unit/v2/fixtures.py | 30 ++++++++++++------- .../tests/unit/v2/test_metadefs_namespaces.py | 7 +++-- .../tests/unit/v2/test_metadefs_objects.py | 7 +++-- .../unit/v2/test_metadefs_resource_types.py | 7 +++-- .../tests/unit/v2/test_metadefs_tags.py | 7 +++-- glanceclient/v2/image_schema.py | 30 ++++++++++++------- 7 files changed, 58 insertions(+), 33 deletions(-) diff --git a/glanceclient/tests/unit/test_utils.py b/glanceclient/tests/unit/test_utils.py index d2b73dce..272ad594 100644 --- a/glanceclient/tests/unit/test_utils.py +++ b/glanceclient/tests/unit/test_utils.py @@ -112,7 +112,8 @@ class TestUtils(testtools.TestCase): def schema_getter(_type='string', enum=False): prop = { 'type': ['null', _type], - 'description': 'Test schema (READ-ONLY)', + 'readOnly': True, + 'description': 'Test schema', } if enum: diff --git a/glanceclient/tests/unit/v2/fixtures.py b/glanceclient/tests/unit/v2/fixtures.py index 6cc2966f..703d43b9 100644 --- a/glanceclient/tests/unit/v2/fixtures.py +++ b/glanceclient/tests/unit/v2/fixtures.py @@ -96,7 +96,8 @@ schema_fixture = { "type": "string" }, "checksum": { - "description": "md5 hash of image contents. (READ-ONLY)", + "readOnly": True, + "description": "md5 hash of image contents.", "maxLength": 32, "type": [ "null", @@ -121,12 +122,14 @@ schema_fixture = { ] }, "created_at": { - "description": "Date and time of image registration (READ-ONLY)", + "readOnly": True, + "description": "Date and time of image registration", "type": "string" }, "direct_url": { + "readOnly": True, "description": "URL to access the image file kept in external " - "store (READ-ONLY)", + "store", "type": "string" }, "disk_format": { @@ -149,7 +152,8 @@ schema_fixture = { ] }, "file": { - "description": "(READ-ONLY)", + "readOnly": True, + "description": "An image file url", "type": "string" }, "id": { @@ -253,22 +257,26 @@ schema_fixture = { ] }, "schema": { - "description": "(READ-ONLY)", + "readOnly": True, + "description": "An image schema url", "type": "string" }, "self": { - "description": "(READ-ONLY)", + "readOnly": True, + "description": "An image self url", "type": "string" }, "size": { - "description": "Size of image file in bytes (READ-ONLY)", + "readOnly": True, + "description": "Size of image file in bytes", "type": [ "null", "integer" ] }, "status": { - "description": "Status of the image (READ-ONLY)", + "readOnly": True, + "description": "Status of the image", "enum": [ "queued", "saving", @@ -288,12 +296,14 @@ schema_fixture = { "type": "array" }, "updated_at": { + "readOnly": True, "description": "Date and time of the last image " - "modification (READ-ONLY)", + "modification", "type": "string" }, "virtual_size": { - "description": "Virtual size of image in bytes (READ-ONLY)", + "readOnly": True, + "description": "Virtual size of image in bytes", "type": [ "null", "integer" diff --git a/glanceclient/tests/unit/v2/test_metadefs_namespaces.py b/glanceclient/tests/unit/v2/test_metadefs_namespaces.py index 5995e6e7..afadda81 100644 --- a/glanceclient/tests/unit/v2/test_metadefs_namespaces.py +++ b/glanceclient/tests/unit/v2/test_metadefs_namespaces.py @@ -444,8 +444,9 @@ schema_fixtures = { }, "updated_at": { "type": "string", + "readOnly": True, "description": "Date and time of the last namespace " - "modification (READ-ONLY)", + "modification", "format": "date-time" }, "visibility": { @@ -512,8 +513,8 @@ schema_fixtures = { }, "created_at": { "type": "string", - "description": "Date and time of namespace creation " - "(READ-ONLY)", + "readOnly": True, + "description": "Date and time of namespace creation ", "format": "date-time" }, "namespace": { diff --git a/glanceclient/tests/unit/v2/test_metadefs_objects.py b/glanceclient/tests/unit/v2/test_metadefs_objects.py index 610aaee5..f554fcbb 100644 --- a/glanceclient/tests/unit/v2/test_metadefs_objects.py +++ b/glanceclient/tests/unit/v2/test_metadefs_objects.py @@ -222,8 +222,8 @@ schema_fixtures = { "properties": { "created_at": { "type": "string", - "description": "Date and time of object creation " - "(READ-ONLY)", + "readOnly": True, + "description": "Date and time of object creation ", "format": "date-time" }, "description": { @@ -246,8 +246,9 @@ schema_fixtures = { }, "updated_at": { "type": "string", + "readOnly": True, "description": "Date and time of the last object " - "modification (READ-ONLY)", + "modification", "format": "date-time" }, } diff --git a/glanceclient/tests/unit/v2/test_metadefs_resource_types.py b/glanceclient/tests/unit/v2/test_metadefs_resource_types.py index de3f9c2e..7893e963 100644 --- a/glanceclient/tests/unit/v2/test_metadefs_resource_types.py +++ b/glanceclient/tests/unit/v2/test_metadefs_resource_types.py @@ -127,15 +127,16 @@ schema_fixtures = { }, "created_at": { "type": "string", + "readOnly": True, "description": "Date and time of resource type " - "association (READ-ONLY)", + "association", "format": "date-time" }, "updated_at": { "type": "string", + "readOnly": True, "description": "Date and time of the last resource " - "type association modification " - "(READ-ONLY)", + "type association modification ", "format": "date-time" }, } diff --git a/glanceclient/tests/unit/v2/test_metadefs_tags.py b/glanceclient/tests/unit/v2/test_metadefs_tags.py index 10822ef8..1df53b6a 100644 --- a/glanceclient/tests/unit/v2/test_metadefs_tags.py +++ b/glanceclient/tests/unit/v2/test_metadefs_tags.py @@ -111,14 +111,15 @@ schema_fixtures = { }, "created_at": { "type": "string", - "description": ("Date and time of tag creation" - " (READ-ONLY)"), + "readOnly": True, + "description": ("Date and time of tag creation"), "format": "date-time" }, "updated_at": { "type": "string", + "readOnly": True, "description": ("Date and time of the last tag" - " modification (READ-ONLY)"), + " modification"), "format": "date-time" }, 'properties': {} diff --git a/glanceclient/v2/image_schema.py b/glanceclient/v2/image_schema.py index aee71446..1e1d3bfa 100644 --- a/glanceclient/v2/image_schema.py +++ b/glanceclient/v2/image_schema.py @@ -86,7 +86,8 @@ _BASE_SCHEMA = { }, "file": { "type": "string", - "description": "(READ-ONLY)" + "readOnly": True, + "description": ("An image file url") }, "owner": { "type": "string", @@ -102,7 +103,8 @@ _BASE_SCHEMA = { }, "size": { "type": "integer", - "description": "Size of image file in bytes (READ-ONLY)" + "readOnly": True, + "description": "Size of image file in bytes" }, "os_distro": { "type": "string", @@ -111,7 +113,8 @@ _BASE_SCHEMA = { }, "self": { "type": "string", - "description": "(READ-ONLY)" + "readOnly": True, + "description": ("An image self url") }, "disk_format": { "enum": [ @@ -135,12 +138,14 @@ _BASE_SCHEMA = { }, "direct_url": { "type": "string", + "readOnly": True, "description": ("URL to access the image file kept in " - "external store (READ-ONLY)") + "external store") }, "schema": { "type": "string", - "description": "(READ-ONLY)" + "readOnly": True, + "description": ("An image schema url") }, "status": { "enum": [ @@ -152,7 +157,8 @@ _BASE_SCHEMA = { "pending_delete" ], "type": "string", - "description": "Status of the image (READ-ONLY)" + "readOnly": True, + "description": "Status of the image" }, "tags": { "items": { @@ -181,8 +187,9 @@ _BASE_SCHEMA = { }, "updated_at": { "type": "string", + "readOnly": True, "description": ("Date and time of the last " - "image modification (READ-ONLY)") + "image modification") }, "min_disk": { "type": "integer", @@ -191,7 +198,8 @@ _BASE_SCHEMA = { }, "virtual_size": { "type": "integer", - "description": "Virtual size of image in bytes (READ-ONLY)" + "readOnly": True, + "description": "Virtual size of image in bytes" }, "instance_uuid": { "type": "string", @@ -207,12 +215,14 @@ _BASE_SCHEMA = { }, "checksum": { "type": "string", - "description": "md5 hash of image contents. (READ-ONLY)", + "readOnly": True, + "description": "md5 hash of image contents.", "maxLength": 32 }, "created_at": { "type": "string", - "description": "Date and time of image registration (READ-ONLY)" + "readOnly": True, + "description": "Date and time of image registration " }, "protected": { "type": "boolean",