-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathtests.py
More file actions
34 lines (27 loc) · 1.09 KB
/
tests.py
File metadata and controls
34 lines (27 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import glob
import json
import jsonschema
import pytest
import requests
schema_url = "https://raw.githubusercontent.com/SpikeInterface/probeinterface/main/src/probeinterface/schema/probe.json.schema"
response = requests.get(schema_url)
response.raise_for_status()
files = glob.glob("*/*/*.json")
@pytest.mark.parametrize("file", files)
def test_valid_probe_dict(file):
with open(file) as f:
data = json.load(f)
jsonschema.validate(data, response.json())
@pytest.mark.parametrize("file", files)
def test_naming_convention(file):
"""Check that model_name and manufacturer are lowercase. and they correspond to the path."""
with open(file) as f:
data = json.load(f)
probe_annotations = data["probes"][0]["annotations"]
model_name = probe_annotations["model_name"]
manufacturer = probe_annotations["manufacturer"]
assert manufacturer == manufacturer.lower()
path_parts = file.split("/")
assert model_name == path_parts[-1].replace(".json", "")
assert model_name == path_parts[-2]
assert manufacturer == path_parts[-3]