summaryrefslogtreecommitdiff
path: root/tests/unittests/config/test_cc_scripts_vendor.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unittests/config/test_cc_scripts_vendor.py')
-rw-r--r--tests/unittests/config/test_cc_scripts_vendor.py26
1 files changed, 17 insertions, 9 deletions
diff --git a/tests/unittests/config/test_cc_scripts_vendor.py b/tests/unittests/config/test_cc_scripts_vendor.py
index a8cbfb4f..1dcd0573 100644
--- a/tests/unittests/config/test_cc_scripts_vendor.py
+++ b/tests/unittests/config/test_cc_scripts_vendor.py
@@ -5,24 +5,32 @@ from cloudinit.config.schema import (
get_schema,
validate_cloudconfig_schema,
)
-from tests.unittests.helpers import skipUnlessJsonSchema
+from tests.unittests.helpers import does_not_raise, skipUnlessJsonSchema
class TestScriptsVendorSchema:
@pytest.mark.parametrize(
- "config, error_msg",
+ "config, expectation",
(
- ({"vendor_data": {"enabled": True}}, None),
- ({"vendor_data": {"enabled": "yes"}}, None),
+ ({"vendor_data": {"enabled": True}}, does_not_raise()),
+ ({"vendor_data": {"enabled": False}}, does_not_raise()),
+ (
+ {"vendor_data": {"enabled": "yes"}},
+ pytest.raises(
+ SchemaValidationError,
+ match=(
+ "deprecations: vendor_data.enabled: DEPRECATED."
+ " Use of string for this value is DEPRECATED."
+ " Use a boolean value instead."
+ ),
+ ),
+ ),
),
)
@skipUnlessJsonSchema()
- def test_schema_validation(self, config, error_msg):
+ def test_schema_validation(self, config, expectation):
"""Assert expected schema validation and error messages."""
# New-style schema $defs exist in config/cloud-init-schema*.json
schema = get_schema()
- if error_msg is None:
+ with expectation:
validate_cloudconfig_schema(config, schema, strict=True)
- else:
- with pytest.raises(SchemaValidationError, match=error_msg):
- validate_cloudconfig_schema(config, schema, strict=True)