示例#1
0
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)
import pytest
from basis_set_exchange import api

# Find the dir with all the bse files
_my_dir = os.path.dirname(os.path.abspath(__file__))
_hist_data_dir = os.path.join(_my_dir, 'basis_set_exchange-historical')
_bse_data_dir = os.path.join(_hist_data_dir, 'bse-formatted')
_hist_testfile = os.path.join(_hist_data_dir, '.is_historical')
_hist_testfile_exists = os.path.isfile(_hist_testfile)

# Skip everying in this file if the submodule isn't checked out
pytestmark = pytest.mark.skipif(_hist_testfile_exists is not True, reason="Historical basis data not downloaded")

# Load all the metadata once
_bs_metadata = api.get_metadata()
_bs_formats = list(api.get_formats().keys())
_bs_formats.remove('json') # Don't need to test json (nothing to compare to)
_true_false = [ True, False ]

# Only the names with a version zero
_bs_names_only_v0 = [x for x,y in _bs_metadata.items() if '0' in y['versions']]

# Read the mapping of new BSE names to old BSE files
with open(os.path.join(_my_dir, 'bse_v0_map.txt'), 'r') as handle:
    _bse_v0_map = dict(re.split('\t+', x.strip()) for x in handle.readlines())

# Mapping of old->new symbols    
_sym_replace_map = { 'Uun': 'Ds', 'UUN': 'DS',
                     'Uuu': 'Rg', 'UUU': 'RG',
                     'Uub': 'Cn', 'UUB': 'CN',
def test_get_metadata():
    '''Test the get_metadata function in the API'''

    api.get_metadata(data_dir)
示例#4
0
def test_get_metadata():
    api.get_metadata()