Skip to content

Commit

Permalink
cov
Browse files Browse the repository at this point in the history
  • Loading branch information
mavaylon1 committed Mar 14, 2024
1 parent 3228671 commit 2d32acf
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 66 deletions.
2 changes: 1 addition & 1 deletion src/hdmf/term_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def load_termset_config(self,config_path):
"""
try:
import yaml
except ImportError:
except ImportError: # pragma: no cover
msg = "Install yaml."
raise ValueError(msg)

Expand Down
13 changes: 13 additions & 0 deletions tests/unit/hdmf_config2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespaces:
hdmf-common:
version: 3.12.2
data_types:
Data:
description: example_test_term_set.yaml
EnumData:
description: example_test_term_set.yaml
namespace2:
version: 0
data_types:
MythicData:
description: example_test_term_set.yaml
57 changes: 55 additions & 2 deletions tests/unit/test_term_set.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os

from hdmf.term_set import TermSet, TermSetWrapper
from hdmf.term_set import TermSet, TermSetWrapper, TermSetConfigurator
from hdmf.testing import TestCase, remove_test_file
from hdmf.common import VectorData
from hdmf.common import VectorData, unload_termset_config
import numpy as np


Expand Down Expand Up @@ -215,3 +215,56 @@ def test_wrapper_extend_error(self):
data_obj = VectorData(name='species', description='...', data=self.wrapped_list)
with self.assertRaises(ValueError):
data_obj.extend(['bad_data'])

class TestTermSetConfig(TestCase):
def setUp(self):
if not REQUIREMENTS_INSTALLED:
self.skipTest("optional LinkML module is not installed")

def tearDown(self):
unload_termset_config()

def test_config_path(self):
path = 'tests/unit/hdmf_config.yaml'
tc = TermSetConfigurator(path=path)
self.assertEqual(tc.path, [path])

def test_get_config(self):
path = 'tests/unit/hdmf_config.yaml'
tc = TermSetConfigurator(path=path)
self.assertEqual(tc.get_config('VectorData', 'hdmf-common'),
{'description': 'example_test_term_set.yaml'})

def test_get_config_namespace_error(self):
path = 'tests/unit/hdmf_config.yaml'
tc = TermSetConfigurator(path=path)
with self.assertRaises(ValueError):
tc.get_config('VectorData', 'hdmf-common11')

def test_get_config_container_error(self):
path = 'tests/unit/hdmf_config.yaml'
tc = TermSetConfigurator(path=path)
with self.assertRaises(ValueError):
tc.get_config('VectorData11', 'hdmf-common')

def test_already_loaded_path_error(self):
path = 'tests/unit/hdmf_config.yaml'
tc = TermSetConfigurator(path=path)
with self.assertRaises(ValueError):
tc.load_termset_config(config_path=path)

def test_load_two_unique_configs(self):
path = 'tests/unit/hdmf_config.yaml'
path2 = 'tests/unit/hdmf_config2.yaml'
tc = TermSetConfigurator(path=path)
tc.load_termset_config(config_path=path2)
self.assertEqual(tc.path, [path, path2])

# def test_append_namespace(self):
# pass
#
# def test_replace_config(self):
# pass
#
# def test_append_config(self):
# pass
63 changes: 0 additions & 63 deletions tests/unit/test_termset_config.py

This file was deleted.

0 comments on commit 2d32acf

Please sign in to comment.