Пример #1
0
def run():
    parser = create_parser()
    args = parser.parse_args()

    try:
        args.func(args)
    except (jsonschema.ValidationError, JsonschemaCliException) as e:
        print(e)
        sys.exit(1)
Пример #2
0
def test_load_json_schema_file(mocker: MockFixture, success_arguments: tuple):
    schema, instance = success_arguments

    mock_isfile = mocker.patch("os.path.isfile")
    mock_isfile.side_effect = lambda x: x.name == "schema.json"

    mock_load_file = mocker.patch("jsonschema_cli.args.load_file", mocker.MagicMock(return_value=schema))
    args = create_parser().parse_args(["validate", "schema.json", json.dumps(instance)])
    args.func(args)
Пример #3
0
def test_load_empty_instance_fails(success_arguments):
    schema, instance = success_arguments

    args = create_parser().parse_args(["validate", json.dumps(schema), ""])
    args.func(args)
Пример #4
0
def test_failed_load_json_schema_yaml_instance(fail_validation_arguments):
    schema, instance = fail_validation_arguments

    args = create_parser().parse_args(["validate", json.dumps(schema), yaml.dump(instance)])
    args.func(args)
Пример #5
0
def test_load_json_schema_yaml_instance(success_arguments):
    schema, instance = success_arguments

    args = create_parser().parse_args(["validate", json.dumps(schema), yaml.dump(instance)])
    args.func(args)
Пример #6
0
def test_load_yaml_string(success_arguments):
    schema, instance = success_arguments

    args = create_parser().parse_args(["validate", yaml.dump(schema), yaml.dump(instance)])
    args.func(args)