mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Add a validation test for DictItem required attribute validation
This commit is contained in:
parent
f74cc21d70
commit
fa826c9ba2
@ -1761,6 +1761,23 @@ class ConfigTestCase(TestCase):
|
||||
'opaque': True}}, TestConf.serialize())
|
||||
self.assertIn('has too many properties', excinfo.exception.message)
|
||||
|
||||
class TestConf(schema.Schema):
|
||||
item = schema.DictItem(
|
||||
title='Poligon',
|
||||
description='Describe the Poligon',
|
||||
properties={
|
||||
'sides': schema.IntegerItem(required=True)
|
||||
},
|
||||
additional_properties=schema.OneOfItem(items=[schema.BooleanItem(),
|
||||
schema.StringItem()])
|
||||
)
|
||||
|
||||
with self.assertRaises(jsonschema.exceptions.ValidationError) as excinfo:
|
||||
jsonschema.validate({'item': {'color': 'blue',
|
||||
'rugged_surface': False,
|
||||
'opaque': True}}, TestConf.serialize())
|
||||
self.assertIn('\'sides\' is a required property', excinfo.exception.message)
|
||||
|
||||
def test_oneof_config(self):
|
||||
item = schema.OneOfItem(
|
||||
items=(schema.StringItem(title='Yes', enum=['yes']),
|
||||
|
Loading…
Reference in New Issue
Block a user