Skip to content

Commit

Permalink
require run.electrodes_file if any report is of type lfp
Browse files Browse the repository at this point in the history
  • Loading branch information
Joni Herttuainen committed Dec 8, 2023
1 parent f386af4 commit 6d70bae
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
17 changes: 17 additions & 0 deletions bluepysnap/schemas/simulation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,23 @@ properties:
type: object
beta_features:
type: object
# require "run: electrodes_file" if any of the reports is of type "lfp"
if:
# need to require reports here, otherwise 'electrodes_file' is required if no reports defined
required:
- reports
properties:
reports:
patternProperties:
"":
properties:
type:
const: "lfp"
then:
properties:
run:
required:
- electrodes_file
$simulation_defs:
non_negative_integer:
type: integer
Expand Down
13 changes: 13 additions & 0 deletions tests/test_schema_validation_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@ def test_reports():
)
assert _validate(config) == []

config["reports"]["fake"]["type"] = "lfp"
config["run"]["electrodes_file"] = "fake_file"

assert _validate(config) == []

config["reports"]["fake"]["sections"] = "fail_0"
config["reports"]["fake"]["scaling"] = "fail_1"
config["reports"]["fake"]["compartments"] = "fail_2"
Expand All @@ -306,6 +311,14 @@ def test_reports():
assert "scaling: 'fail_1' is not one of ['area', 'none']" in res[0].message
assert "compartments: 'fail_2' is not one of ['all', 'center']" in res[0].message

# Sanity check to make sure that required properties aren't overwritten but extended
del config["run"]["dt"]

del config["run"]["electrodes_file"]
res = _validate(config)
assert "run: 'electrodes_file' is a required property" in res[0].message
assert "run: 'dt' is a required property" in res[0].message


def test_inputs():
input_properties = {
Expand Down

0 comments on commit 6d70bae

Please sign in to comment.