Skip to content

Commit 0829791

Browse files
authored
manage users bugfix (#1008)
1 parent 5274894 commit 0829791

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/manage_users.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,9 @@ def prompt_loop(app, store, db, session): # pylint: disable=too-complex
227227

228228

229229
def start_user_management(app, store, db, session):
230-
# We expect flask-security to be initialized
231-
db.create_all()
232-
prompt_loop(app, store, db, session)
230+
with app.app_context():
231+
db.create_all()
232+
prompt_loop(app, store, db, session)
233233

234234

235235
def main():

src/test/unit/test_manage_users.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ def test_integration_try_actions(action_and_inputs, prompt):
8585
for action in action_and_inputs:
8686
prompt.input.send_text(f'{action}\n')
8787
test_app, store, db = _setup_frontend()
88-
with test_app.app_context():
89-
start_user_management(test_app, store, db, prompt.session)
88+
start_user_management(test_app, store, db, prompt.session)
9089

9190
# test will throw exception or stall if something is broken
9291
assert True, f'action sequence {action_and_inputs} caused error'
@@ -106,8 +105,7 @@ def test_add_role(prompt, capsys):
106105
for action in action_and_inputs:
107106
prompt.input.send_text(f'{action}\n')
108107
test_app, store, db = _setup_frontend()
109-
with test_app.app_context():
110-
start_user_management(test_app, store, db, prompt.session)
108+
start_user_management(test_app, store, db, prompt.session)
111109

112110
captured = capsys.readouterr()
113111
assert 'test_user (guest)' in captured.out
@@ -119,7 +117,7 @@ def test_password_is_hashed(prompt):
119117
for action in action_and_inputs:
120118
prompt.input.send_text(f'{action}\n')
121119
test_app, store, db = _setup_frontend()
120+
start_user_management(test_app, store, db, prompt.session)
122121
with test_app.app_context():
123-
start_user_management(test_app, store, db, prompt.session)
124122
user = store.find_user(email='test_user')
125123
assert user.password != 'mock_password'

0 commit comments

Comments
 (0)