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': {
|
||||
'type': ['string', 'null'],
|
||||
'enum': constants.RESOURCE_LOCK_RESOURCE_TYPES + (None,),
|
||||
'enum': list(constants.RESOURCE_LOCK_RESOURCE_TYPES)
|
||||
+ [None],
|
||||
'default': constants.SHARE_RESOURCE_TYPE,
|
||||
'description': helpers.description(
|
||||
'resource_lock_resource_type'
|
||||
@ -50,7 +51,8 @@ create_request_body = {
|
||||
},
|
||||
'resource_action': {
|
||||
'type': ['string', 'null'],
|
||||
'enum': constants.RESOURCE_LOCK_RESOURCE_ACTIONS + (None,),
|
||||
'enum': list(constants.RESOURCE_LOCK_RESOURCE_ACTIONS)
|
||||
+ [None],
|
||||
'default': constants.RESOURCE_ACTION_DELETE,
|
||||
'description': helpers.description(
|
||||
'resource_lock_resource_action_create_optional'
|
||||
@ -74,7 +76,8 @@ update_request_body = {
|
||||
'properties': {
|
||||
'resource_action': {
|
||||
'type': ['string', 'null'],
|
||||
'enum': constants.RESOURCE_LOCK_RESOURCE_ACTIONS + (None,),
|
||||
'enum': list(constants.RESOURCE_LOCK_RESOURCE_ACTIONS)
|
||||
+ [None],
|
||||
'description': helpers.description(
|
||||
'resource_lock_resource_action_optional'
|
||||
),
|
||||
@ -158,14 +161,14 @@ index_request_query = {
|
||||
}),
|
||||
'resource_action': parameter_types.multi_params({
|
||||
'type': ['string', 'null'],
|
||||
'enum': constants.RESOURCE_LOCK_RESOURCE_ACTIONS + (None,),
|
||||
'enum': list(constants.RESOURCE_LOCK_RESOURCE_ACTIONS) + [None],
|
||||
'description': helpers.description(
|
||||
'resource_lock_resource_action_query'
|
||||
),
|
||||
}),
|
||||
'resource_type': parameter_types.multi_params({
|
||||
'type': ['string', 'null'],
|
||||
'enum': constants.RESOURCE_LOCK_RESOURCE_TYPES + (None,),
|
||||
'enum': list(constants.RESOURCE_LOCK_RESOURCE_TYPES) + [None],
|
||||
'description': helpers.description(
|
||||
'resource_lock_resource_type_query'
|
||||
),
|
||||
@ -228,7 +231,7 @@ _resource_lock_response = {
|
||||
},
|
||||
'resource_type': {
|
||||
'type': 'string',
|
||||
'enum': constants.RESOURCE_LOCK_RESOURCE_TYPES,
|
||||
'enum': list(constants.RESOURCE_LOCK_RESOURCE_TYPES),
|
||||
'description': helpers.description('resource_lock_resource_type'),
|
||||
},
|
||||
'resource_id': {
|
||||
@ -238,7 +241,7 @@ _resource_lock_response = {
|
||||
},
|
||||
'resource_action': {
|
||||
'type': 'string',
|
||||
'enum': constants.RESOURCE_LOCK_RESOURCE_ACTIONS,
|
||||
'enum': list(constants.RESOURCE_LOCK_RESOURCE_ACTIONS),
|
||||
'description': helpers.description(
|
||||
'resource_lock_resource_action'
|
||||
),
|
||||
|
@ -11,11 +11,14 @@
|
||||
# under the License.
|
||||
|
||||
import jsonschema.exceptions
|
||||
from oslo_log import log
|
||||
|
||||
from manila.api.v2 import router
|
||||
from manila.api.validation import validators
|
||||
from manila import test
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
|
||||
class SchemaTest(test.TestCase):
|
||||
|
||||
@ -34,6 +37,7 @@ class SchemaTest(test.TestCase):
|
||||
try:
|
||||
self.meta_schema.check_schema(schema)
|
||||
except jsonschema.exceptions.SchemaError:
|
||||
LOG.exception('schema validation failed')
|
||||
invalid_schemas.add(func.__qualname__)
|
||||
|
||||
def _validate_func(func, method):
|
||||
@ -152,3 +156,9 @@ class SchemaTest(test.TestCase):
|
||||
f"Found API resources without response body 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