Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] studyset nested #530

Merged
merged 3 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions store/neurostore/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@


class EndPointsCache(Cache):
# def __init__(*args, **kwargs):
# super().__init__(*args, **kwargs)
nested_endpoint_dict = {}
endpoint_dict = {}

Expand Down
30 changes: 0 additions & 30 deletions store/neurostore/schemas/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,21 +552,6 @@ def dump(self, studyset):
"space": p.space,
"image": p.image,
"label_id": p.label_id,
"entities": [
{
"id": e.id,
"created_at": self._serialize_dt(
e.created_at
),
"updated_at": self._serialize_dt(
e.updated_at
),
"level": e.level,
"label": e.label,
"analysis": a.id,
}
for e in p.entities
],
"values": [
{
"kind": v.kind,
Expand All @@ -585,21 +570,6 @@ def dump(self, studyset):
"user": i.user_id,
"analysis": a.id,
"analysis_name": a.name,
"entities": [
{
"id": i.id,
"created_at": self._serialize_dt(
i.created_at
),
"updated_at": self._serialize_dt(
i.updated_at
),
"level": e.level,
"label": e.label,
"analysis": a.id,
}
for e in i.entities
],
"url": i.url,
"space": i.space,
"value_type": i.value_type,
Expand Down
12 changes: 12 additions & 0 deletions store/neurostore/tests/api/test_studysets.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from neurostore.models import Studyset


def test_post_and_get_studysets(auth_client, ingest_neurosynth):
# create a studyset
payload = auth_client.get("/api/studies/").json
Expand Down Expand Up @@ -33,3 +36,12 @@ def test_add_study_to_studyset(auth_client, ingest_neurosynth):

put_resp = auth_client.put(f"/api/studysets/{dset_id}", data={"studies": study_ids})
assert put_resp.status_code == 200


def test_get_nested_nonnested_studysets(auth_client, ingest_neurosynth):
studyset_id = Studyset.query.first().id
non_nested = auth_client.get(f"/api/studysets/{studyset_id}?nested=false")
nested = auth_client.get(f"/api/studysets/{studyset_id}?nested=true")

assert isinstance(non_nested.json['studies'][0], str)
assert isinstance(nested.json['studies'][0], dict)
Loading