-4
print of debug des not print
asked 15 hours ago by @qa-l8tdrfv0ugvfpll8onpi 0 rep · 85 views
i made unit tests of route. Here is the tests
def test_get_all_user(db_session):
response, status_code = requests.get("http://127.0.0.1:5000/api/users", headers={"token": "eyJhbGciOiJIU"})
assert status_code == 401
assert response.get_json() == {
"error": "le token est non valide."
}
I executed this test : pytest -s test_users.py
the error is
def test_get_all_user(db_session):
> response, status_code = requests.get("http://127.0.0.1:5000/api/users", headers={"token": "eyJhbGciOiJIU"})
^^^^^^^^^^^^^^^^^^^^^
E ValueError: not enough values to unpack (expected 2, got 1)
while it ncalls
@users_bp.route('/users', methods=["GET"])
def getListOfUsers():
print("ca passe1")
token = request.headers.get("token", "0")
try:
print("ca passe2")
payload = jwt.decode(token, os.getenv("JWT_SECRET"), algorithms=["HS256"])
print("ca passe3")
except jwt.exceptions.InvalidTokenError:
print("ca passe4")
return jsonify({"error": "le token est non valide."}), 401
print("ca passe5")
and nothing is printed. could you help me