-
Notifications
You must be signed in to change notification settings - Fork 11
/
test_synapse_reference_schema.py
89 lines (63 loc) · 2.43 KB
/
test_synapse_reference_schema.py
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import pytest
from emannotationschemas.schemas.postsynaptic_compartment import PostsynapticCompartment
from emannotationschemas.schemas.presynaptic_bouton_type import PresynapticBoutonType
from marshmallow import ValidationError
synapse_id = 1
good_bouton = {"bouton_type": "basmati", "target_id": synapse_id}
bad_bouton = {"bouton_type": "some_nonsense", "target_id": synapse_id}
good_compartment = {"compartment": "soma", "target_id": synapse_id}
rich_compartment = {
"compartment": "dendrite",
"on_spine": True,
"dendrite_class": "apical",
"target_id": synapse_id,
}
bad_compartment = {"compartment": "some_nonsense", "target_id": synapse_id}
def test_bad_bouton_type():
with pytest.raises(Exception):
assert check_bad_bouton_type()
def test_good_bouton_type():
with pytest.raises(Exception):
assert check_good_bouton_type()
def check_bad_bouton_type():
schema = PresynapticBoutonType()
try:
result = schema.load(bad_bouton)
except ValidationError as err:
raise Exception(f"Wrong type {err}")
def check_good_bouton_type():
schema = PresynapticBoutonType()
try:
result = schema.load(good_bouton)
except ValidationError as err:
raise Exception(f"Wrong type {err}")
def test_good_postsynaptic_compartment():
with pytest.raises(Exception):
assert check_good_postsynaptic_compartment()
def test_bad_postsynaptic_compartment():
with pytest.raises(Exception):
assert check_bad_postsynaptic_compartment()
def test_rich_postsynaptic_compartment():
with pytest.raises(Exception):
assert check_rich_postsynaptic_compartment()
def check_good_postsynaptic_compartment():
schema = PostsynapticCompartment()
try:
result = schema.load(good_compartment)
assert result["compartment"] == "soma"
except ValidationError as err:
raise Exception(f"Wrong compartment type {err}")
def check_bad_postsynaptic_compartment():
schema = PostsynapticCompartment()
try:
result = schema.load(bad_compartment)
assert result["compartment"] == "soma"
except ValidationError as err:
raise Exception(f"Wrong compartment type {err}")
def check_rich_postsynaptic_compartment():
schema = PostsynapticCompartment()
try:
result = schema.load(rich_compartment)
assert result["on_spine"]
except ValidationError as err:
raise Exception(f"Wrong compartment type {err}")