Remnawave_python-sdk/tests/test_system.py
Artem 3f0b5af2cf
Refactor tests for HWID, subscriptions, system, and users; add subscription request history functionality
- Restructured HWID tests into classes for better organization and clarity.
- Enhanced subscription tests to cover additional scenarios and improved assertions.
- Introduced new tests for system statistics and monitoring.
- Implemented CRUD operations for user management with comprehensive test coverage.
- Added new controllers and models for handling subscription request history.
- Created tests for subscription request history, including pagination and statistics.
- Improved error handling in tests to skip when exceptions occur.
2025-10-02 01:46:17 +02:00

66 lines
2.7 KiB
Python

import pytest
from remnawave.models import (
GetBandwidthStatsResponseDto,
GetNodesStatisticsResponseDto,
GetStatsResponseDto,
GetNodesMetricsResponseDto,
GetRemnawaveHealthResponseDto,
)
class TestSystemStatistics:
"""Тесты для получения статистики системы"""
@pytest.mark.asyncio
async def test_get_stats(self, remnawave):
"""Тест получения общей статистики"""
stats = await remnawave.system.get_stats()
assert isinstance(stats, GetStatsResponseDto)
assert hasattr(stats, 'timestamp')
assert hasattr(stats, 'uptime')
@pytest.mark.asyncio
async def test_get_bandwidth_stats(self, remnawave):
"""Тест получения статистики по полосе пропускания"""
bandwidth_stats = await remnawave.system.get_bandwidth_stats()
assert isinstance(bandwidth_stats, GetBandwidthStatsResponseDto)
assert hasattr(bandwidth_stats, 'current_year')
@pytest.mark.asyncio
async def test_get_nodes_statistics(self, remnawave):
"""Тест получения статистики по нодам"""
nodes_statistics = await remnawave.system.get_nodes_statistics()
assert isinstance(nodes_statistics, GetNodesStatisticsResponseDto)
assert hasattr(nodes_statistics, 'last_seven_days')
class TestSystemMonitoring:
"""Тесты для мониторинга системы"""
@pytest.mark.asyncio
async def test_get_nodes_metrics(self, remnawave):
"""Тест получения метрик нод"""
nodes_metrics = await remnawave.system.get_nodes_metrics()
assert isinstance(nodes_metrics, GetNodesMetricsResponseDto)
assert hasattr(nodes_metrics, 'nodes')
assert isinstance(nodes_metrics.nodes, list)
if nodes_metrics.nodes: # Если список не пустой
node = nodes_metrics.nodes[0]
assert hasattr(node, 'uuid')
assert hasattr(node, 'name')
assert hasattr(node, 'cpu_usage')
assert hasattr(node, 'memory_usage')
assert hasattr(node, 'network_upload')
assert hasattr(node, 'network_download')
assert hasattr(node, 'uptime')
assert hasattr(node, 'last_seen')
assert hasattr(node, 'connected_users')
@pytest.mark.asyncio
async def test_get_health(self, remnawave):
"""Тест получения состояния здоровья системы"""
health = await remnawave.system.get_health()
assert isinstance(health, GetRemnawaveHealthResponseDto)
assert hasattr(health, 'pm2_stats')