Skip to content

Commit

Permalink
Add a test to validate a missing morphology,model_template file in @l…
Browse files Browse the repository at this point in the history
…ibrary/morphology (#74)
  • Loading branch information
asanin-epfl committed Jul 9, 2020
1 parent 29a957c commit addfb54
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/test_circuit_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,25 @@ def test_no_morph_files():
nodes_file))]


@patch('bluepysnap.circuit_validation.MAX_MISSING_FILES_DISPLAY', 1)
def test_no_morph_library_files():
with copy_circuit() as (circuit_copy_path, config_copy_path):
nodes_file = circuit_copy_path / 'nodes.h5'
with h5py.File(nodes_file, 'r+') as h5f:
grp = h5f['nodes/default/0']
str_dtype = h5py.special_dtype(vlen=str)
grp.create_dataset('@library/morphology', shape=(1,), dtype=str_dtype)
grp['@library/morphology'][:] = u'noname'
shape = grp['morphology'].shape
del grp['morphology']
grp.create_dataset('morphology', shape=shape, fillvalue=0)
errors = test_module.validate(str(config_copy_path))
assert errors == [Error(
Error.WARNING,
'missing 1 files in group morphology: default/0[{}]:\n\tnoname.swc\n'.format(
nodes_file))]


def test_no_template_files():
with copy_circuit() as (circuit_copy_path, config_copy_path):
nodes_file = circuit_copy_path / 'nodes.h5'
Expand All @@ -258,6 +277,25 @@ def test_no_template_files():
.format(nodes_file))]


@patch('bluepysnap.circuit_validation.MAX_MISSING_FILES_DISPLAY', 1)
def test_no_template_library_files():
with copy_circuit() as (circuit_copy_path, config_copy_path):
nodes_file = circuit_copy_path / 'nodes.h5'
with h5py.File(nodes_file, 'r+') as h5f:
grp = h5f['nodes/default/0']
str_dtype = h5py.special_dtype(vlen=str)
grp.create_dataset('@library/model_template', shape=(1,), dtype=str_dtype)
grp['@library/model_template'][:] = u'hoc:noname'
shape = grp['model_template'].shape
del grp['model_template']
grp.create_dataset('model_template', shape=shape, fillvalue=0)
errors = test_module.validate(str(config_copy_path))
assert errors == [Error(
Error.WARNING,
'missing 1 files in group model_template: default/0[{}]:\n\tnoname.hoc\n'.format(
nodes_file))]


def test_no_edges_h5():
with copy_circuit() as (circuit_copy_path, config_copy_path):
edges_file = circuit_copy_path / 'edges.h5'
Expand Down

0 comments on commit addfb54

Please sign in to comment.