-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from PsychoinformaticsLab/enh/test
Move to Python 3.8, add tests
- Loading branch information
Showing
19 changed files
with
128 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM python:3.6-stretch | ||
FROM python:3.8-buster | ||
ARG DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN mkdir -p /usr/src/app | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from ..request_utils import decode_json | ||
|
||
|
||
def test_get_analyses(auth_client, ingest_neurosynth): | ||
# List of analyses | ||
resp = auth_client.get('/api/analyses/') | ||
assert resp.status_code == 200 | ||
analysis_list = decode_json(resp) | ||
assert type(analysis_list) == list | ||
|
||
assert len(analysis_list) == 1 | ||
|
||
# Check analysis keys | ||
analysis = analysis_list[0] | ||
keys = ['@context', '@id', '@type', 'condition', 'created_at', 'image', | ||
'name', 'point', 'study', 'weight'] | ||
for k in keys: | ||
assert k in analysis | ||
|
||
assert analysis['@context'] == {'@vocab': 'http://neurostuff.org/nimads/'} | ||
assert analysis['@type'] == 'Analysis' | ||
a_id = analysis['@id'].split('/')[-1] | ||
|
||
# Query specify analysis ID | ||
resp = auth_client.get(f"/api/analyses/{a_id}") | ||
assert resp.status_code == 200 | ||
assert decode_json(resp) == analysis | ||
|
||
assert decode_json(resp)['@id'] == \ | ||
f'http://neurostuff.org/api/analyses/{a_id}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
def test_get_conditions(auth_client, ingest_neurosynth): | ||
# Currently no conditions in db | ||
assert 1 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
|
||
def test_get_datasets(auth_client, ingest_neurosynth): | ||
# Currently no datasets in db | ||
assert 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from ..request_utils import decode_json | ||
|
||
|
||
def test_get_images(auth_client, ingest_neurosynth): | ||
# List of datasets | ||
resp = auth_client.get('/api/images/') | ||
assert resp.status_code == 200 | ||
images_list = decode_json(resp) | ||
|
||
assert type(images_list) == list | ||
|
||
assert len(images_list) == 0 | ||
|
||
# Add more tests for images with ingest_neurovault |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from ..request_utils import decode_json | ||
|
||
|
||
def test_get_points(auth_client, ingest_neurosynth): | ||
# Get an analysis | ||
resp = auth_client.get('/api/analyses/') | ||
analysis = decode_json(resp)[0] | ||
|
||
point_id = analysis['point'][0].split('/')[-1] | ||
|
||
# Get a point | ||
resp = auth_client.get(f'/api/points/{point_id}') | ||
point = decode_json(resp) | ||
|
||
# Test a few fields | ||
assert point['@id'] == f'http://neurostuff.org/api/points/{point_id}' | ||
assert point['coordinates'] == [-34.0, -68.0, -15.0] | ||
assert point['space'] == 'TAL' | ||
assert point['@type'] == 'Point' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from ..request_utils import decode_json | ||
|
||
|
||
def test_get_studies(auth_client, ingest_neurosynth): | ||
# List of studies | ||
resp = auth_client.get('/api/studies/') | ||
assert resp.status_code == 200 | ||
studies_list = decode_json(resp) | ||
|
||
assert type(studies_list) == list | ||
|
||
assert len(studies_list) == 1 | ||
|
||
# Check study keys | ||
study = studies_list[0] | ||
|
||
assert study['@context'] == {'@vocab': 'http://neurostuff.org/nimads/'} | ||
assert study['@type'] == 'Study' | ||
s_id = study['@id'].split('/')[-1] | ||
|
||
# Query specify analysis ID | ||
resp = auth_client.get(f"/api/studies/{s_id}") | ||
assert resp.status_code == 200 | ||
full_study = decode_json(resp) | ||
|
||
# Check extra keys | ||
for k in ['analysis', 'created_at', 'doi', 'name']: | ||
assert k in full_study | ||
|
||
assert full_study['doi'] == '10.1016/S0896-6273(00)80456-0' | ||
|
||
assert full_study['@id'] == \ | ||
f'http://neurostuff.org/api/studies/{s_id}' |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.