tests.conftest: use app_context on create_user call

This commit is contained in:
Luna 2019-10-25 08:57:45 -03:00
parent a3f793a211
commit 4d87256cc3
1 changed files with 6 additions and 7 deletions

View File

@ -76,9 +76,8 @@ async def _user_fixture_setup(app):
password = secrets.token_hex(6)
user_email = email()
user_id, pwd_hash = await create_user(
username, user_email, password, app.db, app.loop
)
async with app.app_context():
user_id, pwd_hash = await create_user(username, user_email, password)
# generate a token for api access
user_token = make_token(user_id, pwd_hash)
@ -125,8 +124,8 @@ async def test_cli_staff(test_cli):
# copied from manage.cmd.users.set_user_staff.
old_flags = await app.db.fetchval(
"""
SELECT flags FROM users WHERE id = $1
""",
SELECT flags FROM users WHERE id = $1
""",
user_id,
)
@ -134,8 +133,8 @@ async def test_cli_staff(test_cli):
await app.db.execute(
"""
UPDATE users SET flags = $1 WHERE id = $2
""",
UPDATE users SET flags = $1 WHERE id = $2
""",
new_flags,
user_id,
)