Skip to content

Commit

Permalink
tests: Fixed issue where tests stopped in the middle
Browse files Browse the repository at this point in the history
When running the gunicorn server, the terminal did not start the test scripts
and waited for the process to complete. So I moved the server process to background
and killed it after the tests ran. Should work now in Travis-CI

Will have to look into services like "supervisor" as the current solution is
just a hack.
  • Loading branch information
tasdikrahman committed May 16, 2016
1 parent bcdc071 commit 37a323d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# ignore the virtualenv folder
test_emails/
venv
nohup.out
# logfiles/ ## commenting it out as it caused an error when running on heroku

# Byte-compiled / optimized / DLL files
Expand Down
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ python:

before_script:
- "pip install -r requirements.txt"
- "make run" # run gunicorn server
- "make run-background" # run gunicorn server
- sleep 5 # # give Web server some time to bind to sockets, etc

script: make test-api

after_script:
- "pkill gunicorn"

notifications:
webhooks:
on_success: change # options: [always|never|change] default: always
Expand Down
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ clean:
-find . -name '*.pyc' -delete
-find . -name '__pycache__' -delete

run: clean
run-background: clean
# to be used when testing locally
nohup gunicorn --pythonpath plino app:app &

run: clean
gunicorn --pythonpath plino app:app

test-api: clean
test-api: clean run-background
# for testing api responses (test_plino_app_api_response.py)
python tests/test_plino_app_api_response.py
nosetests

deploy: clean
# deploys app to heroku as well pushes the latest commits to the github
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ Flask-Cache==0.13.1
# production server
gunicorn==19.4.5

# Additional requirements
# testing requirements
requests == 2.10.0
nose==1.3.7

0 comments on commit 37a323d

Please sign in to comment.