当前位置: 首页>>代码示例>>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;未经允许,请勿转载。