Created
February 12, 2017 16:00
-
-
Save pgjones/0bd192d3fae7f6dfadead178dbac0e1e to your computer and use it in GitHub Desktop.
Example of how to use the Flask `test_request_context` with a cookie set
At a guess request.form['user']
should be request.form['name']
given {'name':'demo','password':'demo123'}
. I'm not really sure what you are doing here though - I've not seen a Flask route invoked by calling it in a test context before.
It did work!!! Thanks a lot.
from views import application, autocomplete
ctx = application.test_request_context(path='/login',method='POST', data={'user':'demo','password':'demo123'})
ctx.push()
application.preprocess_request()
query = 'ttll'
autocomplete.autocomplete(query,'gene').json
2020-07-12 13:11:44,523 INFO sqlalchemy.engine.base.Engine SELECT users."user" AS users_user, users.argon_password AS users_argon_password
FROM users
WHERE users."user" = %(user_1)s
2020-07-12 13:11:44,523 INFO sqlalchemy.engine.base.Engine {'user_1': 'demo'}
[D 200712 13:11:44 autocomplete:15] Autocomplete query 'ttll' and query type 'gene'
Out[5]:
['TTLL5',
'ARPC4-TTLL3',
'TTLL2',
'TTLL7-IT1',
'TTLL1',
'TTLL10',
'TTLL3',
'TTLL6',
'TTLL10-AS1',
'TTLL4',
'TTLL11',
'TTLL13P',
'TTLL12',
'TTLL11-IT1',
'TTLL8',
'TTLL9',
'TTLL7']
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, I'm trying to login, using a terminal, for testing and debug reasons. All works in a browser but I need to replicate some functions in a terminal (iPython), so I'm doing:
but that fails with: