示例#1
0
def test_open_session(app):
    with app.app_context():
        s = get_session()
        assert isinstance(s, sqlalchemy.orm.Session)
        s2 = get_session()
        assert isinstance(s2, sqlalchemy.orm.Session)
        assert s is not s2
def user(app):
    with app.app_context():
        session = get_session()
        user = User(u"eunchongyu", u"유은총", (u"*****@*****.**",), status=UserStatus.active)
        session.add(user)
        session.commit()
        return user.get_id()
def oauth2_client(app):
    with app.app_context():
        session = get_session()
        client = auth.Client(u"Test sample", [redirect_uri], description=u"This is test.")
        session.add(client)
        session.commit()
        assert isinstance(client.client_id, bytes)
        assert isinstance(client.client_secret, basestring)
        return client.client_id, client.client_secret
示例#4
0
def user(app):
    with app.app_context():
        session = get_session()
        user = User(u'eunchongyu',
                    u'유은총', (u'*****@*****.**', ),
                    status=UserStatus.active)
        session.add(user)
        session.commit()
        return user.get_id()
示例#5
0
def oauth2_client(app):
    with app.app_context():
        session = get_session()
        client = auth.Client(u'Test sample', [redirect_uri],
                             description=u'This is test.')
        session.add(client)
        session.commit()
        assert isinstance(client.client_id, bytes)
        assert isinstance(client.client_secret, basestring)
        return client.client_id, client.client_secret
示例#6
0
def test_close_session_after_appcontext(app):
    closed = [False]
    with app.app_context():
        s = get_session()
        old_close = s.close
        def close():
            closed[0] = True
            old_close()
        s.close = close
        assert not closed[0]
    assert closed[0]