add async with all functions
This commit is contained in:
+13
-13
@@ -7,12 +7,12 @@ from sqlalchemy.exc import IntegrityError
|
||||
from tests.helpers import create_chat, create_user
|
||||
|
||||
|
||||
def test_duplicate_username_is_rejected_by_database(client, db_engine):
|
||||
create_user(client, username="unique_name")
|
||||
async def test_duplicate_username_is_rejected_by_database(client, db_engine):
|
||||
await create_user(client, username="unique_name")
|
||||
|
||||
with pytest.raises(IntegrityError):
|
||||
with db_engine.begin() as connection:
|
||||
connection.execute(
|
||||
async with db_engine.begin() as connection:
|
||||
await connection.execute(
|
||||
text(
|
||||
"INSERT INTO users (id, username, display_name, password_hash) "
|
||||
"VALUES (gen_random_uuid(), 'unique_name', 'Other', 'hash')"
|
||||
@@ -20,12 +20,12 @@ def test_duplicate_username_is_rejected_by_database(client, db_engine):
|
||||
)
|
||||
|
||||
|
||||
def test_message_requires_existing_chat(client, db_engine):
|
||||
alice = create_user(client)
|
||||
async def test_message_requires_existing_chat(client, db_engine):
|
||||
alice = await create_user(client)
|
||||
|
||||
with pytest.raises(IntegrityError):
|
||||
with db_engine.begin() as connection:
|
||||
connection.execute(
|
||||
async with db_engine.begin() as connection:
|
||||
await connection.execute(
|
||||
text(
|
||||
"INSERT INTO messages (id, chat_id, sender_id, text) "
|
||||
"VALUES (gen_random_uuid(), gen_random_uuid(), :sender, 'x')"
|
||||
@@ -34,13 +34,13 @@ def test_message_requires_existing_chat(client, db_engine):
|
||||
)
|
||||
|
||||
|
||||
def test_duplicate_membership_is_rejected_by_database(client, db_engine):
|
||||
alice = create_user(client)
|
||||
chat = create_chat(client, alice)
|
||||
async def test_duplicate_membership_is_rejected_by_database(client, db_engine):
|
||||
alice = await create_user(client)
|
||||
chat = await create_chat(client, alice)
|
||||
|
||||
with pytest.raises(IntegrityError):
|
||||
with db_engine.begin() as connection:
|
||||
connection.execute(
|
||||
async with db_engine.begin() as connection:
|
||||
await connection.execute(
|
||||
text("INSERT INTO chat_members (chat_id, user_id) VALUES (:c, :u)"),
|
||||
{"c": chat["id"], "u": alice["id"]},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user