Fix compatibility with jsonschema 4.x
This changed one of the error messages we depend on [1]. [1] https://github.com/python-jsonschema/jsonschema/commit/641e9b8c Change-Id: I643ec568ee2eb2ec1a555f813fd2f1acff915afa Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
parent
e1a925772b
commit
2709e30956
@ -31,7 +31,7 @@ property__source_file_present_value:
|
||||
schema_version: '1.0'
|
||||
__source_file: "present"
|
||||
expected_messages:
|
||||
- "{} is not allowed for"
|
||||
- "should not be valid under {}"
|
||||
- "validating 'not' in schema['properties']['__source_file']"
|
||||
property__source_file_present_null:
|
||||
config:
|
||||
@ -39,7 +39,7 @@ property__source_file_present_null:
|
||||
schema_version: '1.0'
|
||||
__source_file: null
|
||||
expected_messages:
|
||||
- "{} is not allowed for"
|
||||
- "should not be valid under {}"
|
||||
- "validating 'not' in schema['properties']['__source_file']"
|
||||
provider_invalid_uuid:
|
||||
config:
|
||||
|
@ -13,13 +13,14 @@
|
||||
import copy
|
||||
import ddt
|
||||
import fixtures
|
||||
import importlib.metadata
|
||||
import microversion_parse
|
||||
import os
|
||||
|
||||
from unittest import mock
|
||||
|
||||
from oslo_utils.fixture import uuidsentinel
|
||||
from oslotest import base
|
||||
from packaging import version
|
||||
|
||||
from nova.compute import provider_config
|
||||
from nova import exception as nova_exc
|
||||
@ -118,6 +119,17 @@ class SchemaValidationTestCasesV1(SchemaValidationMixin):
|
||||
@ddt.unpack
|
||||
@ddt.file_data('provider_config_data/v1/validation_error_test_data.yaml')
|
||||
def test_validation_errors(self, config, expected_messages):
|
||||
# TODO(stephenfin): Drop this once we no longer support jsonschema 3.x
|
||||
jsonschema_version = importlib.metadata.version('jsonschema')
|
||||
if version.parse(jsonschema_version) < version.parse('4.0.0'):
|
||||
if expected_messages == [
|
||||
"should not be valid under {}",
|
||||
"validating 'not' in schema['properties']['__source_file']",
|
||||
]:
|
||||
expected_messages = [
|
||||
"{} is not allowed for",
|
||||
"validating 'not' in schema['properties']['__source_file']", # noqa: E501
|
||||
]
|
||||
self.run_test_validation_errors(config, expected_messages)
|
||||
|
||||
@ddt.unpack
|
||||
|
@ -66,3 +66,4 @@ python-dateutil>=2.7.0 # BSD
|
||||
futurist>=1.8.0 # Apache-2.0
|
||||
openstacksdk>=0.35.0 # Apache-2.0
|
||||
PyYAML>=5.1 # MIT
|
||||
packaging>=21.0 # Apache-2.0
|
||||
|
Loading…
Reference in New Issue
Block a user