def test_authoritative(basis_name_ver): ''' Compare the stored basis sets with the stored authoritative sources ''' basis_name, ver = os.path.splitext(basis_name_ver) ver = ver[1:] # remove starting '.' basis_meta = bs_metadata[basis_name] ref_path = auth_src_map[basis_name_ver] if basis_name not in bs_names: raise RuntimeError( "Source basis {} doesn't have a BSE basis".format(basis_name)) assert curate.compare_basis_against_file(basis_name, ref_path, version=ver, uncontract_general=True)
def test_add_basis(tmp_path): tmp_path = str(tmp_path) # Needed for python 3.5 for sf, refs in _source_data.items(): sf_path = os.path.join(auth_data_dir, sf) name = sf.split('.')[0] curate.add_basis(sf_path, tmp_path, 'test_subdir', 'test_' + name, 'test_basis_' + name, 'test_family', 'orbital', 'Test Basis Description: ' + name, '1', 'Test Basis Revision Description', 'Test Source', refs) md = api.get_metadata(tmp_path) assert len(md) == len(_source_data) # Re-read for sf in _source_data.keys(): name = name = sf.split('.')[0] name = 'test_basis_' + name bse_dict = api.get_basis(name, data_dir=tmp_path) assert bse_dict['family'] == 'test_family' # Compare against the file we created from sf_path = os.path.join(auth_data_dir, sf) assert curate.compare_basis_against_file(name, sf_path, data_dir=tmp_path) # Check that all the files exist and contain the right elements for fpath, elements in _expected_files.items(): fpath = os.path.join(tmp_path, fpath) assert os.path.isfile(fpath) fdata = fileio.read_json_basis(fpath) expect_elements = set(misc.expand_elements(elements, True)) assert set(fdata['elements'].keys()) == expect_elements # Validate the new data dir validator.validate_data_dir(tmp_path)