Пример #1
0
def test_get_schema_from_url_fails(caplog, mocker):
    mocker.patch(
        "spidermon.contrib.validation.jsonschema.tools.get_contents",
        return_value={'"schema":'},
    )
    schema_tools.get_schema_from("https://something.org/schema.json")
    assert ("Could not parse schema from 'https://something.org/schema.json'"
            in caplog.record_tuples[0][2])
Пример #2
0
 def _load_jsonschema_validator(cls, schema):
     if isinstance(schema, six.string_types):
         schema = get_schema_from(schema)
     if not isinstance(schema, dict):
         raise NotConfigured(
             "Invalid schema, jsonschemas must be defined as:\n"
             "- a python dict.\n"
             "- an object path to a python dict.\n"
             "- an object path to a JSON string.\n"
             "- a path to a JSON file.")
     return JSONSchemaValidator(schema)
Пример #3
0
def test_get_schema_from_file_fails(caplog, mocker):
    path = "tests/fixtures/bad_schema.json"
    schema_tools.get_schema_from("tests/fixtures/bad_schema.json")
    assert ("Could not parse schema in 'tests/fixtures/bad_schema.json'"
            in caplog.record_tuples[0][2])