Remnawave_python-sdk/tests/test_nodes_usage_history.py
Artem 950a7ffab3
Add Pydantic models for nodes usage history, subscriptions, and user management
- Implemented models for nodes usage history including NodeInfoDto, GetUserAccessibleNodesResponse, and usage statistics.
- Created subscription-related models such as UserSubscription, SubscriptionInfoData, and various response DTOs for subscription information.
- Developed models for subscription settings, templates, and system statistics, enhancing the API's capability to manage and retrieve subscription configurations.
- Introduced user management models including CreateUserRequestDto, UpdateUserRequestDto, and various response DTOs for user actions.
- Added bulk actions for user updates and statistics tracking, improving the efficiency of user management operations.
- Established a base controller for handling API requests and responses, along with decorators for HTTP methods to streamline API interactions.
- Included utility functions for serialization using orjson for better performance with Pydantic models.
2025-07-03 12:22:16 +02:00

41 lines
1.2 KiB
Python

from datetime import datetime, timedelta
import pytest
from remnawave.models import (
GetNodeUserUsageByRangeResponseDto,
GetNodesUsageByRangeResponseDto,
)
from tests.conftest import REMNAWAVE_USER_UUID
@pytest.mark.asyncio
async def test_nodes_usage_history(remnawave) -> None:
# Test get nodes usage by range
start_date = (datetime.now() - timedelta(days=7)).isoformat()
end_date = datetime.now().isoformat()
nodes_usage = await remnawave.nodes_usage_history.get_nodes_usage_by_range(
start=start_date,
end=end_date
)
assert isinstance(nodes_usage, GetNodesUsageByRangeResponseDto)
# Response should be a list now (RootModel)
assert isinstance(nodes_usage.root, list)
@pytest.mark.asyncio
async def test_nodes_user_usage_history(remnawave) -> None:
start_date = (datetime.now() - timedelta(days=7)).isoformat()
end_date = datetime.now().isoformat()
node_user_usage = await remnawave.nodes_user_usage_history.get_node_user_usage_by_range(
uuid=REMNAWAVE_USER_UUID,
start=start_date,
end=end_date
)
assert isinstance(node_user_usage, GetNodeUserUsageByRangeResponseDto)