Remnawave_python-sdk/tests/utils.py
Artem f47cda9378
feat: Add models for subscriptions, users, and system statistics
- Implemented TemplateResponseDto and UpdateTemplateRequestDto for subscription templates.
- Created models for system statistics including CPU, memory, and bandwidth.
- Developed user models for user creation, updates, and responses.
- Added bulk actions for user updates and statistics tracking.
- Introduced tests for authentication, bandwidth statistics, hosts, inbounds, key generation, nodes, subscriptions, and user management.
- Enhanced utility functions for generating random strings, emails, and date ranges for testing.
2025-04-21 20:44:27 +02:00

24 lines
749 B
Python

import random
import string
from datetime import datetime, timedelta
from typing import Tuple
def generate_random_string(length: int = 8, chars: str = string.ascii_letters) -> str:
return "".join(random.choices(chars, k=length))
def generate_password(length: int) -> str:
return generate_random_string(
length=length, chars=string.ascii_letters + string.digits
)
def generate_email(length: int, chars: str = string.ascii_letters) -> str:
return generate_random_string(length=length, chars=chars) + "@mail.com"
def generate_isoformat_range() -> Tuple[str, str]:
start = (datetime.now() - timedelta(days=7)).isoformat(timespec="seconds")
end = datetime.now().isoformat(timespec="seconds")
return start, end