Skip to content

Commit

Permalink
Merge 209ba62 into 9c0b289
Browse files Browse the repository at this point in the history
  • Loading branch information
viklund committed Apr 5, 2018
2 parents 9c0b289 + 209ba62 commit deffab2
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[run]
omit = /usr/local/*,/home/travis/virtualenv/*

[report]
omit = /usr/local/*,/home/travis/virtualenv/*
3 changes: 2 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ disable=print-statement,
keyword-arg-before-vararg,
arguments-differ,
line-too-long,
import-error
import-error,
no-self-use

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ before_install:
- test/travis_before_install.sh
install:
- pip install -r backend/requirements.txt
- pip install coverage coveralls
script:
- test/travis_script.sh
6 changes: 3 additions & 3 deletions Dockerfile-backend
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ RUN apt-get update && apt-get install -y \
libmysqlclient-dev

ADD . /code
WORKDIR /code/backend
WORKDIR /code

RUN pip3 install -r requirements.txt
RUN pip3 install -r backend/requirements.txt

CMD ["python3", "route.py", "--develop"]
CMD ["python3", "backend/route.py", "--develop"]
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
SweFreq - Swedish Frequency database
====================================
[![Travis Status][travis-badge]][travis-link]
[![Coverage Status][coveralls-badge]][coveralls-link]


Running on a production system
------------------------------
Expand Down Expand Up @@ -70,3 +73,8 @@ Quick development mode
```bash
$ docker-compose up
```

[travis-badge]: https://travis-ci.org/NBISweden/swefreq.svg?branch=develop
[travis-link]: https://travis-ci.org/NBISweden/swefreq
[coveralls-badge]: https://coveralls.io/repos/github/NBISweden/swefreq/badge.svg?branch=develop
[coveralls-link]: https://coveralls.io/github/NBISweden/swefreq?branch=develop
7 changes: 7 additions & 0 deletions backend/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import smtplib
import socket
import tornado.web
import tornado
import random
import string
import uuid
Expand Down Expand Up @@ -41,6 +42,12 @@ def build_dataset_structure(dataset_version, user=None, dataset=None):
return r


class QuitHandler(handlers.UnsafeHandler):
def get(self):
ioloop = tornado.ioloop.IOLoop.instance()
ioloop.stop()


class GetSchema(handlers.UnsafeHandler):
"""
Returns the schema.org, and bioschemas.org, annotation for a given
Expand Down
1 change: 1 addition & 0 deletions backend/route.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def __init__(self, settings):
## Adding developer login handler
if settings.get('develop', False):
self.declared_handlers.insert(-1, ("/developer/login", auth.DeveloperLoginHandler))
self.declared_handlers.insert(-1, ("/developer/quit", application.QuitHandler))

# google oauth key
self.oauth_key = tornado_settings["google_oauth"]["key"]
Expand Down
6 changes: 5 additions & 1 deletion backend/settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import json

json_settings_fh = open("../settings.json")
try:
json_settings_fh = open("settings.json")
except FileNotFoundError:
json_settings_fh = open("../settings.json")

json_settings = json.load(json_settings_fh)
json_settings_fh.close()

Expand Down
28 changes: 22 additions & 6 deletions test/travis_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,39 @@ mysql -u swefreq -h 127.0.0.1 -P 3366 swefreq_test < test/data/load_dummy_data.s


echo ">>> Test 3. Check that the backend starts"
cd backend

../test/01_daemon_starts.sh
(cd backend && ../test/01_daemon_starts.sh)


echo ">>> Test 4. the backend API"
python route.py --develop 1>http_log.txt 2>&1 &
coverage run backend/route.py --port=4000 --develop 1>http_log.txt 2>&1 &
BACKEND_PID=$!

function exit_handler() {
sleep 2 # Lets wait a little bit so the server has started

exit_handler() {
rv=$?
# Ignore errors in the exit handler
set +e
# We want to make sure the background process has stopped, otherwise the
# travis test will stall for a long time.
kill -9 $BACKEND_PID

echo "THE HTTP LOG WAS:"
cat http_log.txt
exit $rv
}

trap exit_handler EXIT

sleep 2 # Lets wait a little bit so the server has started
python test.py -v

python backend/test.py -v

# Quit the app
curl localhost:4000/developer/quit
sleep 2 # Lets wait a little bit so the server has stopped

if [ -f .coverage ]; then
coveralls
coverage report
fi

0 comments on commit deffab2

Please sign in to comment.