def test_validate_schema_exception_handling(self): """Ensure validate_schema covers basic exception reporting.""" property_schema = PropertySchema() property_schema.required = 'UNDEFINED' schema_instance = SchemaType() schema_instance.some_attr = property_schema self.assertRaisesRegexp( ValidationException, r"""The value for "required" is not """ r"""of type "<type 'bool'>": UNDEFINED""", schema_type.validate_schema, schema_instance) expected_errors_list = [ """The value for "required" is not of type "<type 'bool'>": UNDEFINED""" ] try: schema_type.validate_schema(schema_instance) self.fail('A ValidationException should have been thrown.') except ValidationException as ve: self.assertListEqual(expected_errors_list, ve.validation_errors) errors = schema_type.validate_schema(schema_instance, raise_validation_exception=False) self.assertListEqual(expected_errors_list, errors)
def test_validate_schema_exception_handling(self): """Ensure validate_schema covers basic exception reporting.""" property_schema = PropertySchema() property_schema.required = 'UNDEFINED' schema_instance = SchemaType() schema_instance.some_attr = property_schema self.assertRaisesRegexp( ValidationException, r"""The value for "required" is not """ r"""of type "<type 'bool'>": UNDEFINED""", schema_type.validate_schema, schema_instance) expected_errors_list = [ """The value for "required" is not of type "<type 'bool'>": UNDEFINED"""] try: schema_type.validate_schema(schema_instance) self.fail('A ValidationException should have been thrown.') except ValidationException as ve: self.assertListEqual(expected_errors_list, ve.validation_errors) errors = schema_type.validate_schema( schema_instance, raise_validation_exception=False) self.assertListEqual(expected_errors_list, errors)
def test_validate_schema(self): """Valid schema testing of validate_schema.""" schema = SchemaType({'some_property': {'type': 'int'}}) # Dict test schema_type.validate_schema(schema) # OnticType test base_type_schema = SchemaType(schema) schema_type.validate_schema(base_type_schema) # SchemaType test schema_type_schema = SchemaType(schema) schema_type.validate_schema(schema_type_schema)