Flask request cookie testing 2017-02-12

The Stet.io website exlcuding the editor is often termed the backend. The backend of Stet.io is written in Python3 using the Flask framework. The backend and editor communicate via AJAX requests, sending JSON formatted data. These requests include a authentication token stored on the cookie, which can be hard to test using the Flask framework.

The issue comes down to the use of the test_request_context alongside cookies. Using a Flask test-client is easy, via the set_cookie method. To use the test_request_context, set the cookie as below,

Back to blog