Ejemplo n.º 1
0
def test_get_user_from_wrong_token(session):
    user = User()
    user.get_token()
    session.add(user)
    session.commit()

    assert get_user_from_token(session, "foo") is None
Ejemplo n.º 2
0
def test_get_user_from_token(session):
    user = User()
    user.get_token()
    session.add(user)
    session.commit()

    assert get_user_from_token(session, user.token) == user
Ejemplo n.º 3
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.º 4
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
Ejemplo n.º 5
0
def test_get_token():
    user = User()
    user.get_token()
    assert user.token is not None
    assert user.token_expires is not None