mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 09:20:22 +08:00
feat: 统计数据优化 - 支持细粒度时间范围和多维度分析
- 新增 StatsHourly/StatsDaily 预聚合表,支持任意时区的精确统计 - 实现 UTC datetime 范围查询策略,边界数据实时聚合 - 新增统计 API:用户/API Key 维度、成本分析、性能百分位、错误分类 - 新增前端页面:成本分析、性能分析、用户统计 - 新增 TimeRangePicker 组件和统计可视化组件 - 优化 Dashboard 和 Usage 页面支持时间范围筛选 Close #135
This commit is contained in:
27
tests/services/usage/test_error_classifier.py
Normal file
27
tests/services/usage/test_error_classifier.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import pytest
|
||||
|
||||
from src.core.enums import ErrorCategory
|
||||
from src.services.usage.error_classifier import classify_error
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"status_code,error_message,status,expected",
|
||||
[
|
||||
(429, None, None, ErrorCategory.RATE_LIMIT),
|
||||
(401, None, None, ErrorCategory.AUTH),
|
||||
(404, None, None, ErrorCategory.NOT_FOUND),
|
||||
(None, "maximum context length exceeded", None, ErrorCategory.CONTEXT_LENGTH),
|
||||
(None, "content_filter triggered", None, ErrorCategory.CONTENT_FILTER),
|
||||
(None, "rate limit reached", None, ErrorCategory.RATE_LIMIT),
|
||||
(None, "request timeout", None, ErrorCategory.TIMEOUT),
|
||||
(None, "connection reset by peer", None, ErrorCategory.NETWORK),
|
||||
(500, None, None, ErrorCategory.SERVER_ERROR),
|
||||
(400, None, None, ErrorCategory.INVALID_REQUEST),
|
||||
(200, None, "cancelled", ErrorCategory.CANCELLED),
|
||||
(None, None, None, ErrorCategory.UNKNOWN),
|
||||
],
|
||||
)
|
||||
def test_classify_error(
|
||||
status_code: int | None, error_message: str | None, status: str | None, expected: ErrorCategory
|
||||
) -> None:
|
||||
assert classify_error(status_code, error_message, status) == expected
|
||||
Reference in New Issue
Block a user