def test_valid_qcschema_slow(basis_name): basis_dict = api.get_basis(basis_name) qcs_str = api.get_basis(basis_name, fmt='qcschema') qcs_json = json.loads(qcs_str) el_list = [ lut.element_sym_from_Z(x, True) for x in basis_dict['elements'].keys() ] coords = [] for idx, el in enumerate(el_list): coords.extend((0.0, 0.0, float(idx))) qcs_json['atom_map'] = list(qcs_json['center_data'].keys()) assert len(qcs_json['atom_map']) == len(el_list) dummy_inp = { "schema_name": "qc_schema_input", "schema_version": 1, "keywords": {}, "molecule": { "schema_name": "qcschema_molecule", "schema_version": 2, "geometry": coords, "symbols": el_list }, 'driver': 'energy', 'model': { 'method': 'B3LYP', 'basis': qcs_json } } qcschema.validate(dummy_inp, 'input')
def test_simple_basis_input(version, testfile): example = test_helpers.get_test(testfile) if isinstance(version, int) and version < example["schema_version"]: with pytest.raises(jsonschema.exceptions.ValidationError): qcschema.validate(example, "input", version=version) else: qcschema.validate(example, "input", version=version)
def test_wavefunction_output(version, testfile, request): example = test_helpers.get_test(testfile) # temporary - dev:=2 doesn't pass, but dev:=qcel will if version == "dev" and ("water_output" in request.node.name): pytest.skip() # by chance, this validates with v1 instead of triggering pytest.raises below, so skip if version == 1 and ("water_output_v3" in request.node.name): pytest.skip() # a proper failure, where schema is not back-compatible, so xfail if version == "dev" and ("water_output]" in request.node.name): with pytest.raises(jsonschema.exceptions.ValidationError) as e: qcschema.validate(example, "output", version=version) assert "'restricted' is a required property" in str(e.value) pytest.xfail() # ordinary operation if isinstance(version, int) and version < example["schema_version"]: with pytest.raises(jsonschema.exceptions.ValidationError): qcschema.validate(example, "output", version=version) else: qcschema.validate(example, "output", version=version)
def test_simple_basis_input(version, testfile): example = test_helpers.get_test(testfile) qcschema.validate(example, "input")
def test_output_failures(version, testfile): example = test_helpers.get_test(testfile) with pytest.raises(jsonschema.exceptions.ValidationError): qcschema.validate(example, "output")
def test_wavefunction_output(version, testfile): example = test_helpers.get_test(testfile) qcschema.validate(example, "output")