def test_draft3_validator_is_chosen(self):
     schema = {"$schema" : "http://json-schema.org/draft-03/schema#"}
     with mock.patch.object(Draft3Validator, "check_schema") as chk_schema:
         validate({}, schema)
         chk_schema.assert_called_once_with(schema)
     # Make sure it works without the empty fragment
     schema = {"$schema" : "http://json-schema.org/draft-03/schema"}
     with mock.patch.object(Draft3Validator, "check_schema") as chk_schema:
         validate({}, schema)
         chk_schema.assert_called_once_with(schema)
예제 #2
0
 def test_draft3_validator_is_chosen(self):
     schema = {"$schema": "http://json-schema.org/draft-03/schema#"}
     with mock.patch.object(Draft3Validator, "check_schema") as chk_schema:
         validate({}, schema)
         chk_schema.assert_called_once_with(schema)
     # Make sure it works without the empty fragment
     schema = {"$schema": "http://json-schema.org/draft-03/schema"}
     with mock.patch.object(Draft3Validator, "check_schema") as chk_schema:
         validate({}, schema)
         chk_schema.assert_called_once_with(schema)
 def test_draft4_validator_is_the_default(self):
     with mock.patch.object(Draft4Validator, "check_schema") as chk_schema:
         validate({}, {})
         chk_schema.assert_called_once_with({})
 def test_draft4_validator_is_chosen(self):
     schema = {"$schema" : "http://json-schema.org/draft-04/schema#"}
     with mock.patch.object(Draft4Validator, "check_schema") as chk_schema:
         validate({}, schema)
         chk_schema.assert_called_once_with(schema)
 def test_non_existent_properties_are_ignored(self):
     instance, my_property, my_value = mock.Mock(), mock.Mock(), mock.Mock()
     validate(instance=instance, schema={my_property : my_value})
 def message_for(self, instance, schema, *args, **kwargs):
     kwargs.setdefault("cls", Draft3Validator)
     with self.assertRaises(ValidationError) as e:
         validate(instance, schema, *args, **kwargs)
     return e.exception.message
예제 #7
0
 def test_draft4_validator_is_the_default(self):
     with mock.patch.object(Draft4Validator, "check_schema") as chk_schema:
         validate({}, {})
         chk_schema.assert_called_once_with({})
예제 #8
0
 def test_draft4_validator_is_chosen(self):
     schema = {"$schema": "http://json-schema.org/draft-04/schema#"}
     with mock.patch.object(Draft4Validator, "check_schema") as chk_schema:
         validate({}, schema)
         chk_schema.assert_called_once_with(schema)
예제 #9
0
 def test_non_existent_properties_are_ignored(self):
     instance, my_property, my_value = mock.Mock(), mock.Mock(), mock.Mock()
     validate(instance=instance, schema={my_property: my_value})
예제 #10
0
 def message_for(self, instance, schema, *args, **kwargs):
     kwargs.setdefault("cls", Draft3Validator)
     with self.assertRaises(ValidationError) as e:
         validate(instance, schema, *args, **kwargs)
     return e.exception.message