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

Commit

Permalink
tests fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
bongi23 committed Nov 29, 2018
1 parent 7ba0a57 commit a6c49ea
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion flaskapp/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def do_method(method, url, **kwds):
data = {}
if 'data' in kwds:
data = kwds['data']

return FUNCTIONS[method](URL + url, params=params, json=data)

@staticmethod
Expand Down
5 changes: 4 additions & 1 deletion flaskapp/tests/test_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
DATASERVICE = os.environ['DATA_SERVICE']



def test_create_user(client):
tested_app, app = client

Expand Down Expand Up @@ -86,7 +87,9 @@ def test_delete_user(client):
assert reply.status_code == 401

# post correct password and checking that the user has been deleted
reply = tested_app.post('/delete_user', data=dict(password='123456'), follow_redirects=True)
with requests_mock.mock() as m:
m.delete(DATASERVICE + '/users/1')
reply = tested_app.post('/delete_user', data=dict(password='123456'), follow_redirects=True)
assert reply.status_code == 200

# TODO add after relavant parts are implemented
Expand Down
4 changes: 1 addition & 3 deletions flaskapp/views/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
from flaskapp.services import DataService

import os
import requests


auth = Blueprint('auth', __name__)

Expand All @@ -32,7 +30,7 @@ def _strava_auth(): # pragma: no cover

# print('uise: ', access_token)

if 'access_token' in access_token: # compatibility with stravalib 10
if 'access_token' in access_token: # compatibility with stravalib 0.10
access_token = access_token['access_token']

reply = DataService().post('/users/%s'%str(user_id), data={'strava_token': access_token})
Expand Down
1 change: 0 additions & 1 deletion flaskapp/views/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
run = Blueprint('run', __name__)



@run.route('/run/<id>', methods=['GET'])
@login_required
def get_run(id):
Expand Down
4 changes: 3 additions & 1 deletion flaskapp/views/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ def delete_user():
if request.method == 'POST':
if form.validate_on_submit():
if current_user.authenticate(form.password.data) and hasattr(current_user, 'dataservice_user_id'):
reply = requests.delete(DATASERVICE + '/users/' + str(current_user.dataservice_user_id))

reply = DataService.delete(url="/users/%s" % current_user.dataservice_user_id, params={})

if reply.status_code == 200:
db.session.delete(current_user)
db.session.commit()
Expand Down

0 comments on commit a6c49ea

Please sign in to comment.