Skip to content

Commit

Permalink
assign user to annotation_analyses (#738)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdkent authored Mar 13, 2024
1 parent feda937 commit ce8f0b7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions store/neurostore/resources/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def update_annotations(self, annotations):
sa.select(
Annotation.id,
Annotation.note_keys,
Annotation.user_id,
AnnotationAnalysis.analysis_id.label("annotation_analysis_id"),
AnnotationAnalysis.annotation_id.label("annotation_id"),
AnnotationAnalysis.note,
Expand Down Expand Up @@ -120,6 +121,7 @@ def update_annotations(self, annotations):
"analysis_id": result.analysis_id,
"annotation_id": result.id,
"note": result.note or {},
"user_id": result.user_id,
"study_id": result.study_id,
"studyset_id": result.studyset_id,
}
Expand Down
8 changes: 7 additions & 1 deletion store/neurostore/tests/api/test_annotations.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ...models import Studyset, User
from ...models import Studyset, Annotation, User


def test_post_blank_annotation(auth_client, ingest_neurosynth, session):
Expand All @@ -13,6 +13,9 @@ def test_post_blank_annotation(auth_client, ingest_neurosynth, session):
assert len(resp.json()["notes"]) == len(
[a for study in dset.studies for a in study.analyses]
)
annot = Annotation.query.filter_by(id=resp.json()["id"]).one()

assert annot.annotation_analyses[0].user_id == annot.user_id


def test_post_annotation(auth_client, ingest_neurosynth, session):
Expand All @@ -31,6 +34,9 @@ def test_post_annotation(auth_client, ingest_neurosynth, session):
}
resp = auth_client.post("/api/annotations/", data=payload)
assert resp.status_code == 200
annot = Annotation.query.filter_by(id=resp.json()["id"]).one()

assert annot.annotation_analyses[0].user_id == annot.user_id


def test_get_annotations(auth_client, ingest_neurosynth, session):
Expand Down

0 comments on commit ce8f0b7

Please sign in to comment.