This commit is contained in:
2026-04-22 18:34:13 +03:00
parent 3992121397
commit ce7a1f70b2
60 changed files with 10243 additions and 3443 deletions

61
tests/helpers.py Normal file
View File

@@ -0,0 +1,61 @@
from __future__ import annotations
from datetime import datetime, timedelta, timezone
from app.schemas.remnawave import RemnawaveUser
def make_remote_user(
*,
user_uuid: str,
user_id: int,
short_uuid: str,
username: str,
telegram_id: int | None,
expire_at: datetime | None = None,
traffic_limit_bytes: int = 0,
) -> RemnawaveUser:
now = datetime.now(timezone.utc).replace(microsecond=0)
expire = expire_at or (now + timedelta(days=30))
return RemnawaveUser.model_validate(
{
"uuid": user_uuid,
"id": user_id,
"shortUuid": short_uuid,
"username": username,
"status": "ACTIVE",
"trafficLimitBytes": traffic_limit_bytes,
"expireAt": expire.isoformat().replace("+00:00", "Z"),
"telegramId": telegram_id,
"email": None,
"description": None,
"tag": "BOT",
"hwidDeviceLimit": None,
"externalSquadUuid": None,
"trojanPassword": f"trojan-{user_id}",
"vlessUuid": f"00000000-0000-0000-0000-{user_id:012d}",
"ssPassword": f"ss-{user_id}",
"lastTriggeredThreshold": 0,
"subRevokedAt": None,
"subLastUserAgent": None,
"subLastOpenedAt": None,
"lastTrafficResetAt": None,
"createdAt": now.isoformat().replace("+00:00", "Z"),
"updatedAt": now.isoformat().replace("+00:00", "Z"),
"subscriptionUrl": f"https://example.com/sub/{short_uuid}",
"activeInternalSquads": [
{
"uuid": "11111111-1111-1111-1111-111111111111",
"name": "VPN",
}
],
"userTraffic": {
"usedTrafficBytes": 0,
"lifetimeUsedTrafficBytes": 0,
"onlineAt": None,
"firstConnectedAt": None,
"lastConnectedNodeUuid": None,
},
}
)