escape user

This commit is contained in:
dni ⚡
2024-10-10 09:08:38 +02:00
parent e2eb07285f
commit de1a780f6d
7 changed files with 70 additions and 86 deletions
+1
View File
@@ -126,6 +126,7 @@ async def from_user():
@pytest_asyncio.fixture(scope="session")
async def from_wallet(from_user):
user = from_user
wallet = await create_wallet(user_id=user.id, wallet_name="test_wallet_from")
await update_wallet_balance(
wallet_id=wallet.id,
+1
View File
@@ -26,6 +26,7 @@ class DbTestModel2(BaseModel):
class DbTestModel3(BaseModel):
id: int
user: str
child: DbTestModel2
active: bool = False
+7 -5
View File
@@ -12,6 +12,7 @@ from tests.helpers import DbTestModel, DbTestModel2, DbTestModel3
test_data = DbTestModel3(
id=1,
user="userid",
child=DbTestModel2(
id=2,
label="test",
@@ -26,8 +27,8 @@ test_data = DbTestModel3(
async def test_helpers_insert_query():
q = insert_query("test_helpers_query", test_data)
assert q == (
"INSERT INTO test_helpers_query (id, child, active) "
"VALUES (:id, :child, :active)"
"""INSERT INTO test_helpers_query ("id", "user", "child", "active") """
"VALUES (:id, :user, :child, :active)"
)
@@ -35,8 +36,8 @@ async def test_helpers_insert_query():
async def test_helpers_update_query():
q = update_query("test_helpers_query", test_data)
assert q == (
"UPDATE test_helpers_query "
"SET id = :id, child = :child, active = :active WHERE id = :id"
"""UPDATE test_helpers_query SET "id" = :id, "user" = """
""":user, "child" = :child, "active" = :active WHERE id = :id"""
)
@@ -48,7 +49,7 @@ child_json = json.dumps(
"child": {"id": 3, "name": "myname", "value": "myvalue"},
}
)
test_dict = {"id": 1, "child": child_json, "active": True}
test_dict = {"id": 1, "user": "userid", "child": child_json, "active": True}
@pytest.mark.asyncio
@@ -57,6 +58,7 @@ async def test_helpers_model_to_dict():
assert d.get("id") == test_data.id
assert d.get("active") == test_data.active
assert d.get("child") == child_json
assert d.get("user") == test_data.user
assert d == test_dict