Skip to content

Commit

Permalink
add tests for nodes multi group
Browse files Browse the repository at this point in the history
  • Loading branch information
asanin-epfl committed Jul 21, 2020
1 parent aa97ba5 commit 4fcd102
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tests/data/circuit_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"nodes": [
{
"nodes_file": "$NETWORK_DIR/nodes.h5",
"node_types_file": null
"node_types_file": "$NETWORK_DIR/node_types.csv"
}
],
"edges": [
Expand Down
2 changes: 2 additions & 0 deletions tests/data/node_types.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_type_id model_processing
1 perisomatic
Binary file modified tests/data/nodes.h5
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/test_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_all():
circuit.config['networks']['nodes'][0] ==
{
'nodes_file': str(TEST_DATA_DIR / 'nodes.h5'),
'node_types_file': None,
'node_types_file': str(TEST_DATA_DIR / 'node_types.csv'),
}
)
assert isinstance(circuit.nodes, dict)
Expand Down
17 changes: 17 additions & 0 deletions tests/test_circuit_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ def test_ok_circuit():
errors = test_module.validate(str(TEST_DATA_DIR / 'circuit_config.json'))
assert errors == []

with copy_circuit() as (_, config_copy_path):
with edit_config(config_copy_path) as config:
config['networks']['nodes'][0]['node_types_file'] = None
errors = test_module.validate(config_copy_path)
assert errors == []


def test_no_config_components():
with copy_circuit() as (_, config_copy_path):
Expand Down Expand Up @@ -163,6 +169,17 @@ def test_no_required_node_multi_group_datasets():
format(nodes_file, [ds]))]


def test_nodes_multi_group_wrong_group_id():
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:
h5f.copy('nodes/default/0', 'nodes/default/1')
h5f['nodes/default/node_group_id'][-1] = 2
errors = test_module.validate(str(config_copy_path))
assert errors == [Error(Error.FATAL, 'Population /nodes/default of {} misses group(s): {}'.
format(nodes_file, {2}))]


def test_no_required_node_group_datasets():
required_datasets = ['model_template', 'model_type']
with copy_circuit() as (circuit_copy_path, config_copy_path):
Expand Down

0 comments on commit 4fcd102

Please sign in to comment.