2023-09-06 04:53:16 +00:00
|
|
|
import os
|
2023-09-06 04:47:41 +00:00
|
|
|
import tempfile
|
2024-07-02 04:44:35 +00:00
|
|
|
from pathlib import Path
|
|
|
|
|
2023-09-06 04:47:41 +00:00
|
|
|
import yaml
|
|
|
|
from yaml import CDumper as Dumper
|
2024-07-02 04:44:35 +00:00
|
|
|
|
2024-07-20 04:28:24 +00:00
|
|
|
from nwb_linkml.io.yaml import load_yaml
|
2023-09-06 04:47:41 +00:00
|
|
|
|
2024-07-02 04:23:31 +00:00
|
|
|
|
2023-09-06 04:47:41 +00:00
|
|
|
def test_preload_maps():
|
|
|
|
hdmf_style_naming = {
|
2024-07-02 04:23:31 +00:00
|
|
|
"groups": [
|
2023-09-06 04:47:41 +00:00
|
|
|
{
|
2024-07-02 04:23:31 +00:00
|
|
|
"data_type_def": "Container",
|
|
|
|
"data_type_inc": "MainClass",
|
|
|
|
"doc": "Demo group",
|
|
|
|
"datasets": [{"data_type_inc": "Data"}],
|
2023-09-06 04:47:41 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2024-07-02 04:23:31 +00:00
|
|
|
temp, temp_name = tempfile.mkstemp(suffix=".yaml")
|
2023-09-06 04:47:41 +00:00
|
|
|
|
2024-07-02 04:23:31 +00:00
|
|
|
with open(temp_name, "w") as temp_f:
|
2023-09-06 04:47:41 +00:00
|
|
|
yaml.dump(hdmf_style_naming, temp_f, Dumper=Dumper)
|
|
|
|
loaded = load_yaml(Path(temp_name))
|
|
|
|
|
2024-07-02 06:05:47 +00:00
|
|
|
assert "neurodata_type_def" in loaded["groups"][0]
|
|
|
|
assert "data_type_def" not in loaded["groups"][0]
|
|
|
|
assert "neurodata_type_inc" in loaded["groups"][0]
|
|
|
|
assert "data_type_inc" not in loaded["groups"][0]
|
|
|
|
assert "neurodata_type_inc" in loaded["groups"][0]["datasets"][0]
|
|
|
|
assert "data_type_inc" not in loaded["groups"][0]["datasets"][0]
|
2023-09-06 04:47:41 +00:00
|
|
|
|
2023-09-06 04:53:16 +00:00
|
|
|
os.remove(temp_name)
|