Skip to content
This repository has been archived by the owner on Feb 27, 2019. It is now read-only.

Commit

Permalink
Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bongi23 committed Nov 30, 2018
1 parent 5f47ca9 commit 4fee0ce
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 3 additions & 1 deletion flaskapp/tests/test_challenge.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"name_run_two": "test_run_two"
}


def test_run(client):
tested_app, app = client

Expand All @@ -75,7 +76,6 @@ def test_run(client):
reply = tested_app.get('/run/4')
assert reply.status_code == 500


m.get(CHALLENGESERVICE + '/challenges?user_id=1', json=challenge)
reply = tested_app.get('/challenges?user_id=1')
assert reply.status_code == 200
Expand All @@ -92,6 +92,8 @@ def test_run(client):
reply = tested_app.post('/challenges', json=user)
assert reply.status_code == 405

m.get(CHALLENGESERVICE + '/challenges/1?user_id=1', json=challenge)
assert tested_app.get('/challenges/1').status_code == 200


def test_challenge_not_found(client):
Expand Down
2 changes: 0 additions & 2 deletions flaskapp/tests/test_objective.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ def test_view_objectives(client):
# assert tested_app.get('/objectives', follow_redirects=True).status_code == 200




# retrieve the objective table
objectives = db.session.query(Objective)

Expand Down
3 changes: 2 additions & 1 deletion flaskapp/views/challenges.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ def challenge_details(id):
win_avg_speed = ""
challenge_reply = requests.get(url="%s/challenges/%s" % (CHAL_SERVICE_URL, id), params={'user_id': current_user.dataservice_user_id})

if challenge_reply.status_code is 404: # pragma: no cover
if challenge_reply.status_code is 404: # pragma: no cover
abort(404)
elif challenge_reply.status_code is not 200: # pragma: no cover
abort(500)

challenge = challenge_reply.json()
print(challenge)

run_one_reply = requests.get(url="%s/runs/%s" % (DATA_SERVICE_URL, challenge["run_one"]), params={'user_id': current_user.dataservice_user_id})
run_two_reply = requests.get(url="%s/runs/%s" % (DATA_SERVICE_URL, challenge["run_two"]), params={'user_id': current_user.dataservice_user_id})
Expand Down

0 comments on commit 4fee0ce

Please sign in to comment.