Ejemplo n.º 1
0
def test_get_expired_token():
    now = datetime.datetime.utcnow()
    user = User()
    t1 = user.get_token()
    user.token_expires = now - datetime.timedelta(seconds=1)
    t2 = user.get_token()
    assert t1 != t2
    assert t2 == user.token
Ejemplo n.º 2
0
def test_get_user_from_expired_token(session):
    now = datetime.datetime.utcnow()

    user = User()
    user.get_token()
    user.token_expires = now - datetime.timedelta(seconds=1)
    session.add(user)
    session.commit()

    assert get_user_from_token(session, user.token) is None