Skip to content

Commit ce8f0b7

Browse files
authored
assign user to annotation_analyses (#738)
1 parent feda937 commit ce8f0b7

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

store/neurostore/resources/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ def update_annotations(self, annotations):
8484
sa.select(
8585
Annotation.id,
8686
Annotation.note_keys,
87+
Annotation.user_id,
8788
AnnotationAnalysis.analysis_id.label("annotation_analysis_id"),
8889
AnnotationAnalysis.annotation_id.label("annotation_id"),
8990
AnnotationAnalysis.note,
@@ -120,6 +121,7 @@ def update_annotations(self, annotations):
120121
"analysis_id": result.analysis_id,
121122
"annotation_id": result.id,
122123
"note": result.note or {},
124+
"user_id": result.user_id,
123125
"study_id": result.study_id,
124126
"studyset_id": result.studyset_id,
125127
}

store/neurostore/tests/api/test_annotations.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from ...models import Studyset, User
1+
from ...models import Studyset, Annotation, User
22

33

44
def test_post_blank_annotation(auth_client, ingest_neurosynth, session):
@@ -13,6 +13,9 @@ def test_post_blank_annotation(auth_client, ingest_neurosynth, session):
1313
assert len(resp.json()["notes"]) == len(
1414
[a for study in dset.studies for a in study.analyses]
1515
)
16+
annot = Annotation.query.filter_by(id=resp.json()["id"]).one()
17+
18+
assert annot.annotation_analyses[0].user_id == annot.user_id
1619

1720

1821
def test_post_annotation(auth_client, ingest_neurosynth, session):
@@ -31,6 +34,9 @@ def test_post_annotation(auth_client, ingest_neurosynth, session):
3134
}
3235
resp = auth_client.post("/api/annotations/", data=payload)
3336
assert resp.status_code == 200
37+
annot = Annotation.query.filter_by(id=resp.json()["id"]).one()
38+
39+
assert annot.annotation_analyses[0].user_id == annot.user_id
3440

3541

3642
def test_get_annotations(auth_client, ingest_neurosynth, session):

0 commit comments

Comments
 (0)