Add a validation test for DictItem required attribute validation

This commit is contained in:
Pedro Algarvio 2015-08-17 13:58:22 +01:00
parent f74cc21d70
commit fa826c9ba2

View File

@ -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']),