Skip to content
Snippets Groups Projects
Commit 63a27be8 authored by Ambrus Simon's avatar Ambrus Simon
Browse files

Rename test/ references to tests/

parent 84d26c02
No related branches found
No related tags found
No related merge requests found
...@@ -9,10 +9,10 @@ env: ...@@ -9,10 +9,10 @@ env:
install: install:
- bin/install-ubuntu.sh - bin/install-ubuntu.sh
- test/bin/setup-integration-tests-ubuntu.sh - tests/bin/setup-integration-tests-ubuntu.sh
script: script:
- SCITRAN_PERSISTENT_DB_PORT=27017 test/bin/run-tests-ubuntu.sh - SCITRAN_PERSISTENT_DB_PORT=27017 tests/bin/run-tests-ubuntu.sh
after_success: after_success:
- if [ "$TRAVIS_BRANCH" == "master" -o "$TRAVIS_EVENT_TYPE" == "pull_request" ]; then - if [ "$TRAVIS_BRANCH" == "master" -o "$TRAVIS_EVENT_TYPE" == "pull_request" ]; then
......
...@@ -77,8 +77,8 @@ RUN pip install --upgrade pip wheel setuptools \ ...@@ -77,8 +77,8 @@ RUN pip install --upgrade pip wheel setuptools \
&& pip install -r /var/scitran/code/api/requirements-docker.txt \ && pip install -r /var/scitran/code/api/requirements-docker.txt \
&& pip install -r /var/scitran/code/api/requirements.txt && pip install -r /var/scitran/code/api/requirements.txt
COPY test /var/scitran/code/api/test/ COPY tests /var/scitran/code/api/tests/
RUN bash -e -x /var/scitran/code/api/test/bin/setup-integration-tests-ubuntu.sh RUN bash -e -x /var/scitran/code/api/tests/bin/setup-integration-tests-ubuntu.sh
# Copy full repo # Copy full repo
......
...@@ -19,7 +19,7 @@ See [py.test usage](https://docs.pytest.org/en/latest/usage.html) for more. ...@@ -19,7 +19,7 @@ See [py.test usage](https://docs.pytest.org/en/latest/usage.html) for more.
### Docker ### Docker
Build scitran-core image and run automated tests in a docker container: Build scitran-core image and run automated tests in a docker container:
``` ```
./test/bin/run-tests-docker.sh ./tests/bin/run-tests-docker.sh
``` ```
* To skip building the image, use `--no-build` (`-B`) * To skip building the image, use `--no-build` (`-B`)
* To pass any arguments to `run-tests-ubuntu.sh`, use `-- TEST_ARGS` * To pass any arguments to `run-tests-ubuntu.sh`, use `-- TEST_ARGS`
...@@ -27,7 +27,7 @@ Build scitran-core image and run automated tests in a docker container: ...@@ -27,7 +27,7 @@ Build scitran-core image and run automated tests in a docker container:
#### Example #### Example
Without rebuilding the image, run only integration tests matching `foo`, use the highest verbosity level for test output and jump into a python debugger session in case an assertion fails: Without rebuilding the image, run only integration tests matching `foo`, use the highest verbosity level for test output and jump into a python debugger session in case an assertion fails:
``` ```
./test/bin/run-tests-docker.sh -B -- -L -U -A -- -k foo -vvv --pdb ./tests/bin/run-tests-docker.sh -B -- -L -U -A -- -k foo -vvv --pdb
``` ```
### Tools ### Tools
...@@ -36,4 +36,4 @@ Without rebuilding the image, run only integration tests matching `foo`, use the ...@@ -36,4 +36,4 @@ Without rebuilding the image, run only integration tests matching `foo`, use the
### Testing API against RAML with Abao ### Testing API against RAML with Abao
Abao is one of the testing tools run during our TravisCI build. It tests the API implementation against what’s defined in the RAML spec. Adding a new resource / url to the RAML spec will cause Abao to verify that resource during integration tests. Sometimes abao cannot properly test a resource (file field uploads) or a test may require chaining variable. Abao has before and after hooks for tests, written in javascript. These can be used to skip a test, inject variables into the request, or make extra assertions about the response. See tests/integration/abao in the repo for the hooks file. See [abao github readme](https://github.com/cybertk/abao/blob/master/README.md) for more information on how to use hooks. Abao is one of the testing tools run during our TravisCI build. It tests the API implementation against what’s defined in the RAML spec. Adding a new resource / url to the RAML spec will cause Abao to verify that resource during integration tests. Sometimes abao cannot properly test a resource (file field uploads) or a test may require chaining variable. Abao has before and after hooks for tests, written in javascript. These can be used to skip a test, inject variables into the request, or make extra assertions about the response. See tests/integration/abao in the repo for the hooks file. See [abao github readme](https://github.com/cybertk/abao/blob/master/README.md) for more information on how to use hooks.
Abao tests can depend on specific resources (eg. group, project, session, etc.) pre-existing in the DB. That resource loading should be maintained within `test/integration_tests/abao/load_fixture.py` and is executed automatically via the integration test scripts at `test/bin`. Abao tests can depend on specific resources (eg. group, project, session, etc.) pre-existing in the DB. That resource loading should be maintained within `tests/integration_tests/abao/load_fixture.py` and is executed automatically via the integration test scripts at `test/bin`.
...@@ -14,7 +14,7 @@ Usage: ...@@ -14,7 +14,7 @@ Usage:
Options: Options:
-B, --no-build Skip docker build -B, --no-build Skip docker build
-h, --help Print this help and exit -h, --help Print this help and exit
-- TEST_ARGS Arguments passed to test/bin/run-tests-ubuntu.sh -- TEST_ARGS Arguments passed to tests/bin/run-tests-ubuntu.sh
EOF EOF
} }
...@@ -58,7 +58,7 @@ function main() { ...@@ -58,7 +58,7 @@ function main() {
-v $(pwd):/var/scitran/code/api \ -v $(pwd):/var/scitran/code/api \
--entrypoint bash \ --entrypoint bash \
scitran-core:run-tests \ scitran-core:run-tests \
/var/scitran/code/api/test/bin/run-tests-ubuntu.sh \ /var/scitran/code/api/tests/bin/run-tests-ubuntu.sh \
$TEST_ARGS $TEST_ARGS
} }
......
...@@ -65,8 +65,8 @@ function main() { ...@@ -65,8 +65,8 @@ function main() {
# Remove __pycache__ directories for issue with __file__ attribute due to # Remove __pycache__ directories for issue with __file__ attribute due to
# running the tests on the host creating bytecode files hich have a # running the tests on the host creating bytecode files hich have a
# mismatched __file__ attribute when loaded in docker container # mismatched __file__ attribute when loaded in docker container
rm -rf test/unit_tests/python/__pycache__ rm -rf tests/unit_tests/python/__pycache__
rm -rf test/integration_tests/python/__pycache__ rm -rf tests/integration_tests/python/__pycache__
export PYTHONPATH="$(pwd)" export PYTHONPATH="$(pwd)"
export SCITRAN_SITE_API_URL="http://localhost:8081/api" export SCITRAN_SITE_API_URL="http://localhost:8081/api"
...@@ -90,7 +90,7 @@ function main() { ...@@ -90,7 +90,7 @@ function main() {
if ${RUN_UNIT}; then if ${RUN_UNIT}; then
echo "Running unit tests ..." echo "Running unit tests ..."
rm -f .coverage rm -f .coverage
py.test --cov=api --cov-report= test/unit_tests/python $PYTEST_ARGS py.test --cov=api --cov-report= tests/unit_tests/python $PYTEST_ARGS
fi fi
if ${RUN_INTEG} || ${RUN_ABAO}; then if ${RUN_INTEG} || ${RUN_ABAO}; then
...@@ -120,20 +120,20 @@ function main() { ...@@ -120,20 +120,20 @@ function main() {
if ${RUN_INTEG}; then if ${RUN_INTEG}; then
echo "Running integration tests ..." echo "Running integration tests ..."
py.test test/integration_tests/python $PYTEST_ARGS py.test tests/integration_tests/python $PYTEST_ARGS
fi fi
if ${RUN_ABAO}; then if ${RUN_ABAO}; then
echo "Running abao tests ..." echo "Running abao tests ..."
# Create resources that Abao relies on # Create resources that Abao relies on
python test/integration_tests/abao/load_fixture.py python tests/integration_tests/abao/load_fixture.py
# If no VIRTUAL_ENV, make sure /usr/local/bin is in the path # If no VIRTUAL_ENV, make sure /usr/local/bin is in the path
if [[ -z "${VIRTUAL_ENV:-}" ]]; then if [[ -z "${VIRTUAL_ENV:-}" ]]; then
PATH="/usr/local/bin:$PATH" PATH="/usr/local/bin:$PATH"
npm install test/integration_tests npm install tests/integration_tests
else else
npm install --global test/integration_tests npm install --global tests/integration_tests
fi fi
PATH="$(npm bin):$PATH" PATH="$(npm bin):$PATH"
...@@ -145,7 +145,7 @@ function main() { ...@@ -145,7 +145,7 @@ function main() {
# Have to change into definitions directory to resolve # Have to change into definitions directory to resolve
# relative $ref's in the jsonschema's # relative $ref's in the jsonschema's
pushd raml/schemas/definitions pushd raml/schemas/definitions
NODE_PATH="$integration_test_node_modules" abao ../../api.raml "--server=$SCITRAN_SITE_API_URL" "--hookfiles=../../../test/integration_tests/abao/abao_test_hooks.js" NODE_PATH="$integration_test_node_modules" abao ../../api.raml "--server=$SCITRAN_SITE_API_URL" "--hookfiles=../../../tests/integration_tests/abao/abao_test_hooks.js"
popd popd
fi fi
} }
......
set -e #!/usr/bin/env bash
set -eu
unset CDPATH unset CDPATH
cd "$( dirname "${BASH_SOURCE[0]}" )/../.." cd "$( dirname "${BASH_SOURCE[0]}" )/../.."
sudo pip install -U -r "test/integration_tests/requirements-integration-test.txt" sudo pip install -U -r "tests/integration_tests/requirements-integration-test.txt"
NODE_URL="https://nodejs.org/dist/v6.4.0/node-v6.4.0-linux-x64.tar.gz" NODE_URL="https://nodejs.org/dist/v6.4.0/node-v6.4.0-linux-x64.tar.gz"
if [ -z "$VIRTUAL_ENV" ]; then if [[ -z "${VIRTUAL_ENV:-}" ]]; then
curl $NODE_URL | sudo tar xz -C /usr/local --strip-components 1 curl $NODE_URL | sudo tar xz -C /usr/local --strip-components 1
else else
curl $NODE_URL | tar xz -C $VIRTUAL_ENV --strip-components 1 curl $NODE_URL | tar xz -C $VIRTUAL_ENV --strip-components 1
......
...@@ -59,7 +59,7 @@ def main(): ...@@ -59,7 +59,7 @@ def main():
# upload file to test-project-1/test-session-1/test-acquisition-1 # upload file to test-project-1/test-session-1/test-acquisition-1
# depends on 'create test-group' # depends on 'create test-group'
r = as_root.post('/upload/label', files={ r = as_root.post('/upload/label', files={
'file': ('test-1.dcm', open('test/integration_tests/abao/test_files/test-1.dcm', 'rb')), 'file': ('test-1.dcm', open('tests/integration_tests/abao/test_files/test-1.dcm', 'rb')),
'metadata': ('', json.dumps({ 'metadata': ('', json.dumps({
'group': { '_id': 'test-group' }, 'group': { '_id': 'test-group' },
'project': { 'project': {
...@@ -157,7 +157,7 @@ def main(): ...@@ -157,7 +157,7 @@ def main():
# upload file to test-collection-1 # upload file to test-collection-1
# depends on 'create test-collection-1' # depends on 'create test-collection-1'
r = as_root.post('/collections/' + test_collection['_id'] + '/files', files={ r = as_root.post('/collections/' + test_collection['_id'] + '/files', files={
'file': ('notes.txt', open('test/integration_tests/abao/test_files/notes.txt', 'rb')) 'file': ('notes.txt', open('tests/integration_tests/abao/test_files/notes.txt', 'rb'))
}) })
assert r.ok assert r.ok
...@@ -170,14 +170,14 @@ def main(): ...@@ -170,14 +170,14 @@ def main():
# upload file to test-project-1 # upload file to test-project-1
# depends on 'upload file to test-project-1/test-session-1/test-acquisition-1' # depends on 'upload file to test-project-1/test-session-1/test-acquisition-1'
r = as_root.post('/projects/' + test_project['_id'] + '/files', files={ r = as_root.post('/projects/' + test_project['_id'] + '/files', files={
'file': ('notes.txt', open('test/integration_tests/abao/test_files/notes.txt', 'rb')) 'file': ('notes.txt', open('tests/integration_tests/abao/test_files/notes.txt', 'rb'))
}) })
assert r.ok assert r.ok
# upload file to test-session-1 # upload file to test-session-1
# depends on 'upload file to test-project-1/test-session-1/test-acquisition-1' # depends on 'upload file to test-project-1/test-session-1/test-acquisition-1'
r = as_root.post('/sessions/' + test_session['_id'] + '/files', files={ r = as_root.post('/sessions/' + test_session['_id'] + '/files', files={
'file': ('notes.txt', open('test/integration_tests/abao/test_files/notes.txt', 'rb')) 'file': ('notes.txt', open('tests/integration_tests/abao/test_files/notes.txt', 'rb'))
}) })
assert r.ok assert r.ok
...@@ -232,7 +232,7 @@ def main(): ...@@ -232,7 +232,7 @@ def main():
# create session 1 test-analysis (file upload) # create session 1 test-analysis (file upload)
# depends on 'upload file to test-project-1/test-session-1/test-acquisition-1' # depends on 'upload file to test-project-1/test-session-1/test-acquisition-1'
r = as_root.post('/sessions/' + test_session['_id'] + '/analyses', files={ r = as_root.post('/sessions/' + test_session['_id'] + '/analyses', files={
'file': ('test-1.dcm', open('test/integration_tests/abao/test_files/test-1.dcm', 'rb')), 'file': ('test-1.dcm', open('tests/integration_tests/abao/test_files/test-1.dcm', 'rb')),
'metadata': ('', json.dumps({ 'metadata': ('', json.dumps({
'label': 'test analysis', 'label': 'test analysis',
'inputs': [ { 'name': 'test-1.dcm' } ] 'inputs': [ { 'name': 'test-1.dcm' } ]
...@@ -249,7 +249,7 @@ def main(): ...@@ -249,7 +249,7 @@ def main():
# create acquisition 1 test-analysis (file upload) # create acquisition 1 test-analysis (file upload)
# depends on 'upload file to test-project-1/test-session-1/test-acquisition-1' # depends on 'upload file to test-project-1/test-session-1/test-acquisition-1'
r = as_root.post('/acquisitions/' + test_acquisition['_id'] + '/analyses', files={ r = as_root.post('/acquisitions/' + test_acquisition['_id'] + '/analyses', files={
'file': ('test-1.dcm', open('test/integration_tests/abao/test_files/test-1.dcm', 'rb')), 'file': ('test-1.dcm', open('tests/integration_tests/abao/test_files/test-1.dcm', 'rb')),
'metadata': ('', json.dumps({ 'metadata': ('', json.dumps({
'label': 'test analysis', 'label': 'test analysis',
'inputs': [ { 'name': 'test-1.dcm' } ] 'inputs': [ { 'name': 'test-1.dcm' } ]
...@@ -261,7 +261,7 @@ def main(): ...@@ -261,7 +261,7 @@ def main():
# create acquisition 1 test-analysis 2 (file upload) # create acquisition 1 test-analysis 2 (file upload)
# depends on 'upload file to test-project-1/test-session-1/test-acquisition-1' # depends on 'upload file to test-project-1/test-session-1/test-acquisition-1'
r = as_root.post('/acquisitions/' + test_acquisition['_id'] + '/analyses', files={ r = as_root.post('/acquisitions/' + test_acquisition['_id'] + '/analyses', files={
'file': ('test-1.dcm', open('test/integration_tests/abao/test_files/test-1.dcm', 'rb')), 'file': ('test-1.dcm', open('tests/integration_tests/abao/test_files/test-1.dcm', 'rb')),
'metadata': ('', json.dumps({ 'metadata': ('', json.dumps({
'label': 'test analysis', 'label': 'test analysis',
'inputs': [ { 'name': 'test-1.dcm' } ] 'inputs': [ { 'name': 'test-1.dcm' } ]
...@@ -272,7 +272,7 @@ def main(): ...@@ -272,7 +272,7 @@ def main():
# create collection 1 test-analysis (file upload) # create collection 1 test-analysis (file upload)
# depends on 'create test-collection-1' # depends on 'create test-collection-1'
r = as_root.post('/collections/' + test_collection['_id'] + '/analyses', files={ r = as_root.post('/collections/' + test_collection['_id'] + '/analyses', files={
'file': ('test-1.dcm', open('test/integration_tests/abao/test_files/test-1.dcm', 'rb')), 'file': ('test-1.dcm', open('tests/integration_tests/abao/test_files/test-1.dcm', 'rb')),
'metadata': ('', json.dumps({ 'metadata': ('', json.dumps({
'label': 'test analysis', 'label': 'test analysis',
'inputs': [ { 'name': 'test-1.dcm' } ] 'inputs': [ { 'name': 'test-1.dcm' } ]
...@@ -284,7 +284,7 @@ def main(): ...@@ -284,7 +284,7 @@ def main():
# create collection 1 test-analysis 2 (file upload) # create collection 1 test-analysis 2 (file upload)
# depends on 'create test-collection-1' # depends on 'create test-collection-1'
r = as_root.post('/collections/' + test_collection['_id'] + '/analyses', files={ r = as_root.post('/collections/' + test_collection['_id'] + '/analyses', files={
'file': ('test-1.dcm', open('test/integration_tests/abao/test_files/test-1.dcm', 'rb')), 'file': ('test-1.dcm', open('tests/integration_tests/abao/test_files/test-1.dcm', 'rb')),
'metadata': ('', json.dumps({ 'metadata': ('', json.dumps({
'label': 'test analysis 2', 'label': 'test analysis 2',
'inputs': [ { 'name': 'test-1.dcm' } ] 'inputs': [ { 'name': 'test-1.dcm' } ]
...@@ -295,7 +295,7 @@ def main(): ...@@ -295,7 +295,7 @@ def main():
# create project 1 test-analysis (file upload) # create project 1 test-analysis (file upload)
# depends on 'upload file to test-project-1/test-session-1/test-acquisition-1' # depends on 'upload file to test-project-1/test-session-1/test-acquisition-1'
r = as_root.post('/projects/' + test_project['_id'] + '/analyses', files={ r = as_root.post('/projects/' + test_project['_id'] + '/analyses', files={
'file': ('test-1.dcm', open('test/integration_tests/abao/test_files/test-1.dcm', 'rb')), 'file': ('test-1.dcm', open('tests/integration_tests/abao/test_files/test-1.dcm', 'rb')),
'metadata': ('', json.dumps({ 'metadata': ('', json.dumps({
'label': 'test analysis', 'label': 'test analysis',
'inputs': [ { 'name': 'test-1.dcm' } ] 'inputs': [ { 'name': 'test-1.dcm' } ]
...@@ -307,7 +307,7 @@ def main(): ...@@ -307,7 +307,7 @@ def main():
# create project 1 test-analysis 2 (file upload) # create project 1 test-analysis 2 (file upload)
# depends on 'upload file to test-project-1/test-session-1/test-acquisition-1' # depends on 'upload file to test-project-1/test-session-1/test-acquisition-1'
r = as_root.post('/projects/' + test_project['_id'] + '/analyses', files={ r = as_root.post('/projects/' + test_project['_id'] + '/analyses', files={
'file': ('test-1.dcm', open('test/integration_tests/abao/test_files/test-1.dcm', 'rb')), 'file': ('test-1.dcm', open('tests/integration_tests/abao/test_files/test-1.dcm', 'rb')),
'metadata': ('', json.dumps({ 'metadata': ('', json.dumps({
'label': 'test analysis', 'label': 'test analysis',
'inputs': [ { 'name': 'test-1.dcm' } ] 'inputs': [ { 'name': 'test-1.dcm' } ]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment