def testSchemaShouldFindExactMatch(self): schema_id = 'http://json-schema.org/draft-04/schema#' sut = SchemaProxy() self.assertEquals(sut.get_schema(schema_id)['id'], schema_id)
def _schemas(self): return SchemaProxy()
def testGetSchemas(self): schema_id = 'http://json-schema.org/draft-04/schema#' sut = SchemaProxy() self.assertIn(schema_id, sut.get_schemas())
def testSchemaShouldRaiseErrorForUnknownSchema(self): schema_id = 'https://example.com/schema#' sut = SchemaProxy() with self.assertRaises(SchemaNotFound): sut.get_schema(schema_id)
def testSchemaShouldFindMatchWithRemovedFragment(self): schema_id = 'http://json-schema.org/draft-04/schema' sut = SchemaProxy() self.assertEquals(sut.get_schema(schema_id)['id'], 'http://json-schema.org/draft-04/schema#')
def testValidateWithFailure(self): validator = Validator(self.PassThroughRewriter(), SchemaProxy()) data = {} with self.assertRaises(ValidationError): validator.validate(data, SCHEMA)
def testValidate(self): validator = Validator(self.PassThroughRewriter(), SchemaProxy()) data = { 'fruit_name': 'Apple', } validator.validate(data, SCHEMA)