本文整理匯總了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
示例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")
示例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
示例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
示例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
示例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()
示例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()
示例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
示例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
示例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()
示例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)
示例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()
示例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
示例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