Update documentation to use the getter only once
This commit is contained in:
parent
1df2788a8f
commit
5575faad92
1 changed files with 5 additions and 3 deletions
|
|
@ -368,15 +368,17 @@ convenient:
|
||||||
|
|
||||||
@app.route('/api/auth')
|
@app.route('/api/auth')
|
||||||
def auth():
|
def auth():
|
||||||
email = request.get_json()['email']
|
json_data = request.get_json()
|
||||||
password = request.get_json()['password']
|
email = json_data['email']
|
||||||
|
password = json_data['password']
|
||||||
return jsonify(token=generate_token(email, password))
|
return jsonify(token=generate_token(email, password))
|
||||||
|
|
||||||
with app.test_client() as c:
|
with app.test_client() as c:
|
||||||
email = 'john@example.com'
|
email = 'john@example.com'
|
||||||
password = 'secret'
|
password = 'secret'
|
||||||
resp = c.post('/api/auth', json={'login': email, 'password': password})
|
resp = c.post('/api/auth', json={'login': email, 'password': password})
|
||||||
assert verify_token(email, resp.get_json()['token'])
|
json_data = resp.get_json()
|
||||||
|
assert verify_token(email, json_data['token'])
|
||||||
|
|
||||||
Note that if the ``json`` argument is provided then the test client will put
|
Note that if the ``json`` argument is provided then the test client will put
|
||||||
JSON-serialized data in the request body, and also set the
|
JSON-serialized data in the request body, and also set the
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue