tests: Actually raise on invalid schemas
We added schema checks in Ie085fbe965894a1cd5e78ba8d652ced50c77f3de but forgot the final check. We also fix the issues that have been introduced since. Signed-off-by: Stephen Finucane <stephenfin@redhat.com> Change-Id: I5efcb967b8cf677207a3ba812d8ddb4bcd7ab0b9
This commit is contained in:
parent
98a5e8c7ac
commit
d8902ee621
@ -42,7 +42,8 @@ create_request_body = {
|
|||||||
},
|
},
|
||||||
'resource_type': {
|
'resource_type': {
|
||||||
'type': ['string', 'null'],
|
'type': ['string', 'null'],
|
||||||
'enum': constants.RESOURCE_LOCK_RESOURCE_TYPES + (None,),
|
'enum': list(constants.RESOURCE_LOCK_RESOURCE_TYPES)
|
||||||
|
+ [None],
|
||||||
'default': constants.SHARE_RESOURCE_TYPE,
|
'default': constants.SHARE_RESOURCE_TYPE,
|
||||||
'description': helpers.description(
|
'description': helpers.description(
|
||||||
'resource_lock_resource_type'
|
'resource_lock_resource_type'
|
||||||
@ -50,7 +51,8 @@ create_request_body = {
|
|||||||
},
|
},
|
||||||
'resource_action': {
|
'resource_action': {
|
||||||
'type': ['string', 'null'],
|
'type': ['string', 'null'],
|
||||||
'enum': constants.RESOURCE_LOCK_RESOURCE_ACTIONS + (None,),
|
'enum': list(constants.RESOURCE_LOCK_RESOURCE_ACTIONS)
|
||||||
|
+ [None],
|
||||||
'default': constants.RESOURCE_ACTION_DELETE,
|
'default': constants.RESOURCE_ACTION_DELETE,
|
||||||
'description': helpers.description(
|
'description': helpers.description(
|
||||||
'resource_lock_resource_action_create_optional'
|
'resource_lock_resource_action_create_optional'
|
||||||
@ -74,7 +76,8 @@ update_request_body = {
|
|||||||
'properties': {
|
'properties': {
|
||||||
'resource_action': {
|
'resource_action': {
|
||||||
'type': ['string', 'null'],
|
'type': ['string', 'null'],
|
||||||
'enum': constants.RESOURCE_LOCK_RESOURCE_ACTIONS + (None,),
|
'enum': list(constants.RESOURCE_LOCK_RESOURCE_ACTIONS)
|
||||||
|
+ [None],
|
||||||
'description': helpers.description(
|
'description': helpers.description(
|
||||||
'resource_lock_resource_action_optional'
|
'resource_lock_resource_action_optional'
|
||||||
),
|
),
|
||||||
@ -158,14 +161,14 @@ index_request_query = {
|
|||||||
}),
|
}),
|
||||||
'resource_action': parameter_types.multi_params({
|
'resource_action': parameter_types.multi_params({
|
||||||
'type': ['string', 'null'],
|
'type': ['string', 'null'],
|
||||||
'enum': constants.RESOURCE_LOCK_RESOURCE_ACTIONS + (None,),
|
'enum': list(constants.RESOURCE_LOCK_RESOURCE_ACTIONS) + [None],
|
||||||
'description': helpers.description(
|
'description': helpers.description(
|
||||||
'resource_lock_resource_action_query'
|
'resource_lock_resource_action_query'
|
||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
'resource_type': parameter_types.multi_params({
|
'resource_type': parameter_types.multi_params({
|
||||||
'type': ['string', 'null'],
|
'type': ['string', 'null'],
|
||||||
'enum': constants.RESOURCE_LOCK_RESOURCE_TYPES + (None,),
|
'enum': list(constants.RESOURCE_LOCK_RESOURCE_TYPES) + [None],
|
||||||
'description': helpers.description(
|
'description': helpers.description(
|
||||||
'resource_lock_resource_type_query'
|
'resource_lock_resource_type_query'
|
||||||
),
|
),
|
||||||
@ -228,7 +231,7 @@ _resource_lock_response = {
|
|||||||
},
|
},
|
||||||
'resource_type': {
|
'resource_type': {
|
||||||
'type': 'string',
|
'type': 'string',
|
||||||
'enum': constants.RESOURCE_LOCK_RESOURCE_TYPES,
|
'enum': list(constants.RESOURCE_LOCK_RESOURCE_TYPES),
|
||||||
'description': helpers.description('resource_lock_resource_type'),
|
'description': helpers.description('resource_lock_resource_type'),
|
||||||
},
|
},
|
||||||
'resource_id': {
|
'resource_id': {
|
||||||
@ -238,7 +241,7 @@ _resource_lock_response = {
|
|||||||
},
|
},
|
||||||
'resource_action': {
|
'resource_action': {
|
||||||
'type': 'string',
|
'type': 'string',
|
||||||
'enum': constants.RESOURCE_LOCK_RESOURCE_ACTIONS,
|
'enum': list(constants.RESOURCE_LOCK_RESOURCE_ACTIONS),
|
||||||
'description': helpers.description(
|
'description': helpers.description(
|
||||||
'resource_lock_resource_action'
|
'resource_lock_resource_action'
|
||||||
),
|
),
|
||||||
|
@ -11,11 +11,14 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import jsonschema.exceptions
|
import jsonschema.exceptions
|
||||||
|
from oslo_log import log
|
||||||
|
|
||||||
from manila.api.v2 import router
|
from manila.api.v2 import router
|
||||||
from manila.api.validation import validators
|
from manila.api.validation import validators
|
||||||
from manila import test
|
from manila import test
|
||||||
|
|
||||||
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class SchemaTest(test.TestCase):
|
class SchemaTest(test.TestCase):
|
||||||
|
|
||||||
@ -34,6 +37,7 @@ class SchemaTest(test.TestCase):
|
|||||||
try:
|
try:
|
||||||
self.meta_schema.check_schema(schema)
|
self.meta_schema.check_schema(schema)
|
||||||
except jsonschema.exceptions.SchemaError:
|
except jsonschema.exceptions.SchemaError:
|
||||||
|
LOG.exception('schema validation failed')
|
||||||
invalid_schemas.add(func.__qualname__)
|
invalid_schemas.add(func.__qualname__)
|
||||||
|
|
||||||
def _validate_func(func, method):
|
def _validate_func(func, method):
|
||||||
@ -152,3 +156,9 @@ class SchemaTest(test.TestCase):
|
|||||||
f"Found API resources without response body schemas: "
|
f"Found API resources without response body schemas: "
|
||||||
f"{sorted(missing_response_schemas)}"
|
f"{sorted(missing_response_schemas)}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if invalid_schemas:
|
||||||
|
raise self.failureException(
|
||||||
|
f"Found API resources with invalid schemas: "
|
||||||
|
f"{sorted(invalid_schemas)}"
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user