realpython / flask-jwt-auth

just testing some jwts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Encode Token test_user_model.py test couldn't pass

elsagong opened this issue · comments

Hi, thank you so much for your great tutorial, I just learned "Encode Token", I found that I couldn't pass "test_encode_auth_token" only if I change below code of line 20 self.assertTrue(isinstance(auth_token, bytes)) to self.assertFalse(isinstance(auth_token, bytes)), then they all passed, I don't know the reason why about it. Could you please help me with this issue? Thank you in advance.

Best regards,
Elsa

# project/tests/test_user_model.py

import unittest

from project.server import db
from project.server.models import User
from project.tests.base import BaseTestCase


class TestUserModel(BaseTestCase):

    def test_encode_auth_token(self):
        user = User(
            email='test@test.com',
            password='test'
        )
        db.session.add(user)
        db.session.commit()
        auth_token = user.encode_auth_token(user.id)
        self.assertTrue(isinstance(auth_token, bytes))

if __name__ == '__main__':
    unittest.main()