Skip to content

Commit c3d8f68

Browse files
fix: delete all users test
1 parent ee62dca commit c3d8f68

File tree

1 file changed

+2
-27
lines changed

1 file changed

+2
-27
lines changed

tests/api/test_a_admin.py

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,6 @@
1-
import asyncio
2-
31
from fastapi import status
42

5-
from app.db.models import Group
6-
from tests.api import TestSession, client
7-
8-
9-
async def _create_group_record(name: str) -> int:
10-
async with TestSession() as session:
11-
group = Group(name=name, inbounds=[], is_disabled=False)
12-
session.add(group)
13-
await session.commit()
14-
await session.refresh(group)
15-
return group.id
16-
17-
18-
async def _delete_group_record(group_id: int):
19-
async with TestSession() as session:
20-
group = await session.get(Group, group_id)
21-
if group:
22-
await session.delete(group)
23-
await session.commit()
3+
from tests.api import client
244

255

266
def test_admin_login():
@@ -134,8 +114,6 @@ def test_admin_delete_all_users_endpoint(access_token):
134114
)
135115
assert response.status_code == status.HTTP_201_CREATED
136116

137-
group_id = asyncio.run(_create_group_record(f"{admin_username}_group"))
138-
139117
created_users = []
140118
for idx in range(2):
141119
user_name = f"{admin_username}_user_{idx}"
@@ -145,7 +123,6 @@ def test_admin_delete_all_users_endpoint(access_token):
145123
json={
146124
"username": user_name,
147125
"proxy_settings": {},
148-
"group_ids": [group_id],
149126
"data_limit": 1024,
150127
"data_limit_reset_strategy": "no_reset",
151128
"status": "active",
@@ -167,7 +144,7 @@ def test_admin_delete_all_users_endpoint(access_token):
167144
headers={"Authorization": f"Bearer {access_token}"},
168145
)
169146
assert response.status_code == status.HTTP_200_OK
170-
assert response.json()["deleted"] == len(created_users)
147+
assert str(len(created_users)) in response.json()["detail"]
171148

172149
for username in created_users:
173150
user_check = client.get(
@@ -184,8 +161,6 @@ def test_admin_delete_all_users_endpoint(access_token):
184161
)
185162
assert cleanup.status_code == status.HTTP_204_NO_CONTENT
186163

187-
asyncio.run(_delete_group_record(group_id))
188-
189164

190165
def test_admin_delete(access_token):
191166
"""Test that the admin delete route is accessible."""

0 commit comments

Comments
 (0)