mirror of
https://github.com/wassname/flask-security.git
synced 2026-06-27 16:10:11 +08:00
Turn on testing flag for test app
This commit is contained in:
@@ -10,10 +10,12 @@ from werkzeug.local import LocalProxy
|
||||
|
||||
ds = LocalProxy(lambda: current_app.extensions['security'].datastore)
|
||||
|
||||
|
||||
def create_app(config):
|
||||
app = Flask(__name__)
|
||||
app.debug = True
|
||||
app.config['SECRET_KEY'] = 'secret'
|
||||
app.config['TESTING'] = True
|
||||
|
||||
for key, value in config.items():
|
||||
app.config[key] = value
|
||||
@@ -113,11 +115,13 @@ def create_app(config):
|
||||
|
||||
return app
|
||||
|
||||
|
||||
def create_roles():
|
||||
for role in ('admin', 'editor', 'author'):
|
||||
ds.create_role(name=role)
|
||||
ds.commit()
|
||||
|
||||
|
||||
def create_users(count=None):
|
||||
users = [('matt@lp.com', 'password', ['admin'], True),
|
||||
('joe@lp.com', 'password', ['editor'], True),
|
||||
@@ -132,10 +136,12 @@ def create_users(count=None):
|
||||
roles=u[2], active=u[3])
|
||||
ds.commit()
|
||||
|
||||
|
||||
def populate_data(user_count=None):
|
||||
create_roles()
|
||||
create_users(user_count)
|
||||
|
||||
|
||||
def add_context_processors(s):
|
||||
@s.context_processor
|
||||
def for_all():
|
||||
|
||||
Reference in New Issue
Block a user