mirror of
https://github.com/p2p-ld/nwb-linkml.git
synced 2024-11-10 00:34:29 +00:00
fixing tests by using temp directory and changing random prior commit hash from nwb core schema
This commit is contained in:
parent
c69cbdfb38
commit
095d0bc6a9
5 changed files with 17 additions and 6 deletions
|
@ -37,6 +37,7 @@ class Config(BaseSettings):
|
|||
@field_validator('cache_dir', mode='before')
|
||||
@classmethod
|
||||
def folder_exists(cls, v: Path, info: FieldValidationInfo) -> Path:
|
||||
v = Path(v)
|
||||
v.mkdir(exist_ok=True)
|
||||
assert v.exists()
|
||||
return v
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
from nwb_linkml.io import schema as io
|
||||
from nwb_linkml.adapters.namespaces import NamespacesAdapter
|
||||
|
@ -14,9 +15,15 @@ def tmp_output_dir() -> Path:
|
|||
|
||||
return path
|
||||
|
||||
@pytest.fixture(autouse=True, scope='session')
|
||||
def set_config_vars(tmp_output_dir):
|
||||
os.environ['NWB_LINKML_CACHE_DIR'] = str(tmp_output_dir)
|
||||
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def nwb_core_fixture() -> NamespacesAdapter:
|
||||
nwb_core = io.load_nwb_core()
|
||||
nwb_core.populate_imports()
|
||||
return nwb_core
|
||||
return nwb_core
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import pytest
|
|||
from pathlib import Path
|
||||
|
||||
from nwb_linkml.io.hdf5 import HDF5IO
|
||||
|
||||
@pytest.mark.skip()
|
||||
def test_hdf_read():
|
||||
NWBFILE = Path('/Users/jonny/Dropbox/lab/p2p_ld/data/nwb/sub-738651046_ses-760693773.nwb')
|
||||
if not NWBFILE.exists():
|
||||
|
|
|
@ -8,7 +8,7 @@ from nwb_schema_language import Namespaces
|
|||
@pytest.mark.parametrize(
|
||||
['source', 'commit'],
|
||||
[
|
||||
(NWB_CORE_REPO, 'b4f8838cbfbb7f8a117bd7e0aad19133d26868b4'),
|
||||
(NWB_CORE_REPO, '761a0d7838304864643f8bc3ab88c93bfd437f2a'),
|
||||
(HDMF_COMMON_REPO, '660b6ac0780dd9d2cb1e56fea8b62c671ca5e2c8')
|
||||
]
|
||||
)
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import pdb
|
||||
import shutil
|
||||
import os
|
||||
|
||||
from typing import Optional, Union, List
|
||||
from ..fixtures import tmp_output_dir
|
||||
from ..fixtures import tmp_output_dir, set_config_vars
|
||||
|
||||
import pytest
|
||||
|
||||
|
@ -63,6 +64,10 @@ def test_linkml_provider(tmp_output_dir, repo_version, schema_version, schema_di
|
|||
)
|
||||
def test_pydantic_provider(tmp_output_dir, class_name, test_fields):
|
||||
provider = PydanticProvider(path=tmp_output_dir)
|
||||
# clear any prior output
|
||||
assert provider.path.parent == tmp_output_dir
|
||||
shutil.rmtree(provider.path, ignore_errors=True)
|
||||
assert not provider.path.exists()
|
||||
|
||||
core = provider.get('core')
|
||||
|
||||
|
@ -76,5 +81,3 @@ def test_pydantic_provider(tmp_output_dir, class_name, test_fields):
|
|||
assert test_class.model_fields[k].annotation == v
|
||||
|
||||
|
||||
pdb.set_trace()
|
||||
|
||||
|
|
Loading…
Reference in a new issue