We are testing a Python Flask application using flask.app.test_client
like explained here
Our application works with JWT tokens for authentication purpose, so all API call's must have the token specified. Is there way to provide JWT as header to app.tests_client
?
Below is the testing code snippet,
from app import app # our flask application
import unittest
class AppTests(unittest.TestCase):
def setUp(self):
self.app = app.app.test_client()
def tearDown(self):
pass
def test_info_page(self):
info_rs = self.app.get('/info') ## --> this request should go with header JWT token.
self.assertEqual(info_rs.status_code, 200)