|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# |
| 3 | +# This file is part of HEPData. |
| 4 | +# Copyright (C) 2016 CERN. |
| 5 | +# |
| 6 | +# HEPData is free software; you can redistribute it |
| 7 | +# and/or modify it under the terms of the GNU General Public License as |
| 8 | +# published by the Free Software Foundation; either version 2 of the |
| 9 | +# License, or (at your option) any later version. |
| 10 | +# |
| 11 | +# HEPData is distributed in the hope that it will be |
| 12 | +# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | +# General Public License for more details. |
| 15 | +# |
| 16 | +# You should have received a copy of the GNU General Public License |
| 17 | +# along with HEPData; if not, write to the |
| 18 | +# Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 19 | +# MA 02111-1307, USA. |
| 20 | +# |
| 21 | +# In applying this license, CERN does not |
| 22 | +# waive the privileges and immunities granted to it by virtue of its status |
| 23 | +# as an Intergovernmental Organization or submit itself to any jurisdiction. |
| 24 | +import json |
| 25 | +import jsonschema |
| 26 | + |
| 27 | +def test_analysis_json_schema(): |
| 28 | + schema_file_name = "../hepdata/templates/analysis_schema.json" |
| 29 | + test_file_name = "test_data/analysis_example.json" |
| 30 | + |
| 31 | + with open(schema_file_name) as f: |
| 32 | + schema = json.load(f) |
| 33 | + with open(test_file_name) as f: |
| 34 | + test = json.load(f) |
| 35 | + |
| 36 | + jsonschema.validate(instance=test, schema=schema) |
| 37 | + |
| 38 | +if __name__ == "__main__": |
| 39 | + test_analysis_json_schema() |
0 commit comments