當前位置: 首頁>>代碼示例>>Python>>正文


Python app.test_client方法代碼示例

本文整理匯總了Python中server.app.test_client方法的典型用法代碼示例。如果您正苦於以下問題:Python app.test_client方法的具體用法?Python app.test_client怎麽用?Python app.test_client使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在server.app的用法示例。


在下文中一共展示了app.test_client方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: setUp

# 需要導入模塊: from server import app [as 別名]
# 或者: from server.app import test_client [as 別名]
def setUp(self):
        """To do before every test"""

        self.client = app.test_client()
        app.config['SECRET_KEY'] = '123'
        app.config['TESTING'] = True

        # connect to test database
        connect_to_db(app, "postgresql:///testdb")

        """Creates tables and adds example data to testdb"""
        db.create_all()
        example_data()

        with self.client as c:
            with c.session_transaction() as sess:
                sess['user'] = 1 
開發者ID:kjlundsgaard,項目名稱:hb-final-project,代碼行數:19,代碼來源:tests.py

示例2: test_protected_authorized

# 需要導入模塊: from server import app [as 別名]
# 或者: from server.app import test_client [as 別名]
def test_protected_authorized(self):
        """
        access protected with logging
        :return:
        """
        print("=======================")
        response = app.test_client().get("/protected")
        print("=========================")
        # with app.test_client() as c:
        #     with c.session_transaction() as sess:
        #         user = self.get_user()
        #         db.session.add(user)
        #         db.session.commit()
        #         sess["entry"] = "test"
        #         sess["user_id"] = user.user_id
        #         result = protected_save()
        #         # response = self.client.get("/protected")
        #         print("test") 
開發者ID:paulx3,項目名稱:ohlife_replacement_server,代碼行數:20,代碼來源:test.py

示例3: setUp

# 需要導入模塊: from server import app [as 別名]
# 或者: from server.app import test_client [as 別名]
def setUp(self):
        """Stuff to do before every test."""

        # Get the Flask test client
        self.client = app.test_client()

        # Create secret key to access session
        app.secret_key = "TESTINGBOBAFETCH"

        # Connect to fake database
        connect_to_db(app, 'postgresql:///bobafetchfaker')

        app.config['TESTING'] = True
    
    #############################################################################
    # API tests 
開發者ID:AnliYang,項目名稱:bobafetch,代碼行數:18,代碼來源:tests.py

示例4: app

# 需要導入模塊: from server import app [as 別名]
# 或者: from server.app import test_client [as 別名]
def app():
    wireUpBlpapiImplementation(eventlet.import_patched("blpapi_simulator"))
    my_app.register_blueprint(dev.blueprint, url_prefix='/dev')
    app = my_app.test_client()
    app.testing = True 
    return app 
開發者ID:pricingmonkey,項目名稱:blpapi-web,代碼行數:8,代碼來源:test_latest.py

示例5: app

# 需要導入模塊: from server import app [as 別名]
# 或者: from server.app import test_client [as 別名]
def app():
    wireUpBlpapiImplementation(eventlet.import_patched("blpapi_simulator"))
    app = my_app.test_client()
    app.testing = True 
    return app 
開發者ID:pricingmonkey,項目名稱:blpapi-web,代碼行數:7,代碼來源:test_unsubscribe.py

示例6: setUp

# 需要導入模塊: from server import app [as 別名]
# 或者: from server.app import test_client [as 別名]
def setUp(self):
        """Stuff to do before every test."""

        # Get the Flask test client
        self.client = app.test_client()

        # Create secret key to access session
        app.secret_key = "ABC"

        # Connect to fake database
        connect_to_db(app, 'postgresql:///testdb')
        db.create_all()
        app.config['TESTING'] = True

        example_data() 
開發者ID:EmmaOnThursday,項目名稱:next-book,代碼行數:17,代碼來源:tests.py

示例7: setUp

# 需要導入模塊: from server import app [as 別名]
# 或者: from server.app import test_client [as 別名]
def setUp(self):
        """Before tests."""

        self.client = app.test_client()
        app.config['TESTING'] = True
        # Connect to test database
        connect_to_db(app, "postgresql:///testdb")

        # Create tables and add sample data
        db.create_all()
        example_data() 
開發者ID:Gerdie,項目名稱:farm-to-front-door,代碼行數:13,代碼來源:tests.py

示例8: setUp

# 需要導入模塊: from server import app [as 別名]
# 或者: from server.app import test_client [as 別名]
def setUp(self):
        """Flask tests that test the routes/html pages."""
        app.config['TESTING'] = True
        app.config['SECRET_KEY'] = 'key'
        self.client = app.test_client()

        with self.client as c:
            with c.session_transaction() as sess:
                sess['user_id'] = 1234 
開發者ID:vivianhoang,項目名稱:Fork-Spoon,代碼行數:11,代碼來源:tests.py

示例9: setUp

# 需要導入模塊: from server import app [as 別名]
# 或者: from server.app import test_client [as 別名]
def setUp(self):
        """Stuff to do before every test."""

        # Get the Flask test client
        self.client = app.test_client()

        # Show Flask errors that happen during tests
        app.config['TESTING'] = True 
開發者ID:catliaw,項目名稱:playlist_project,代碼行數:10,代碼來源:test.py

示例10: setUp

# 需要導入模塊: from server import app [as 別名]
# 或者: from server.app import test_client [as 別名]
def setUp(self):
        self.client = app.test_client()
        app.config['TESTING'] = True

        #Connect to test db
        connect_to_db(app, 'postgresql:///testdb')

        #Create tables & add sample data
        db.create_all()
        example_data() 
開發者ID:k-wiz,項目名稱:insomnia-app,代碼行數:12,代碼來源:tests.py

示例11: test_dashboard

# 需要導入模塊: from server import app [as 別名]
# 或者: from server.app import test_client [as 別名]
def test_dashboard(self):
        """Test dashboard route."""

        test_client = server.app.test_client()
        result = test_client.post('/dashboard', data={'hours_sleep': '1', 
                                                        'insom_severity': '1',
                                                        'bedtime': '23:00',
                                                        'stress_level': '1',
                                                        'activity_level': '1'})
        self.assertIn('<div class="panel">', result.data) 
開發者ID:k-wiz,項目名稱:insomnia-app,代碼行數:12,代碼來源:tests.py

示例12: setUp

# 需要導入模塊: from server import app [as 別名]
# 或者: from server.app import test_client [as 別名]
def setUp(self):
        """ Stuff to do before every test """

        app.config['TESTING'] = True
        app.config['SECRET_KEY'] = 'key123'
        self.client = app.test_client()

        # Connect to test database (uncomment when testing database)
        connect_to_db(app, "postgresql:///testdb")

        # Create tables and add sample data (uncomment when testing database)
        db.create_all()
        example_data() 
開發者ID:emilydowgialo,項目名稱:Spent,代碼行數:15,代碼來源:tests.py

示例13: setUp

# 需要導入模塊: from server import app [as 別名]
# 或者: from server.app import test_client [as 別名]
def setUp(self):
        # instantiate a flask test client
        app.config["TESTING"] = True
        app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://'
        app.config['LOGIN_DISABLED'] = True
        self.client = app.test_client()
        # create the database objects
        app.app_context().push()
        db.create_all()
        # add some fixtures to the database
        self.user = self.get_user()
        db.session.add(self.user)
        db.session.commit()

    # this method is run after each test 
開發者ID:paulx3,項目名稱:ohlife_replacement_server,代碼行數:17,代碼來源:test.py

示例14: setUp

# 需要導入模塊: from server import app [as 別名]
# 或者: from server.app import test_client [as 別名]
def setUp(self):
        self.client = app.test_client()
        app.config['TESTING'] = True 
開發者ID:maheskett,項目名稱:Calendar-Analytics,代碼行數:5,代碼來源:tests.py


注:本文中的server.app.test_client方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。