Remnawave_python-sdk/tests/test_hwid.py
Artem 41389d4205
Refactor SDK for Remnawave API v2.0.0 compatibility
- Updated models and response structures to align with API v2.0.0 specifications.
- Enhanced response handling to support both wrapped and unwrapped API responses.
- Added new controllers for ConfigProfiles, InternalSquads, InfraBilling, and NodesUsageHistory.
- Implemented RootModel patterns for list responses, allowing direct iteration and indexing.
- Updated tests to validate new models and endpoints, ensuring 20 out of 21 tests pass with real API integration.
- Fixed various bugs related to response handling and model validation.
- Documented migration path and breaking changes for users upgrading from v1.x to v2.0.0.
2025-07-01 15:06:07 +02:00

47 lines
1.5 KiB
Python

import random
import uuid
import pytest
from remnawave_api.models import (
CreateUserHwidDeviceRequestDto,
DeleteUserHwidDeviceRequestDto,
CreateUserHwidDeviceResponseDto,
DeleteUserHwidDeviceResponseDto,
GetUserHwidDevicesResponseDto,
)
from tests.conftest import REMNAWAVE_USER_UUID
new_hwid = str(uuid.uuid4())
@pytest.mark.asyncio
async def test_get_hwid_user(remnawave):
hwid = await remnawave.hwid.get_hwid_user(uuid=REMNAWAVE_USER_UUID)
assert isinstance(hwid, GetUserHwidDevicesResponseDto)
assert hwid.devices is not None
@pytest.mark.asyncio
async def test_add_hwid_to_user(remnawave):
create_request = CreateUserHwidDeviceRequestDto(
hwid=new_hwid,
user_uuid=REMNAWAVE_USER_UUID,
platform="Windows",
os_version="10.0.19042",
deviceModel="Surface Pro",
userAgent="Mozilla/5.0"
)
response = await remnawave.hwid.add_hwid_to_users(body=create_request)
assert isinstance(response, CreateUserHwidDeviceResponseDto)
assert any(item.hwid == new_hwid for item in response.devices)
@pytest.mark.asyncio
async def test_delete_hwid_user(remnawave):
delete_request = DeleteUserHwidDeviceRequestDto(
hwid=new_hwid,
user_uuid=REMNAWAVE_USER_UUID
)
response = await remnawave.hwid.delete_hwid_to_user(body=delete_request)
assert isinstance(response, DeleteUserHwidDeviceResponseDto)
assert not any(item.hwid == new_hwid for item in response.devices)