init
This commit is contained in:
1 parent
c7fccf99c7
commit
8471f368eb
33 files changed
+444
-2095
No files matched your search
@@ -2,6 +2,7 @@
|
||||
import json
|
||||
|
||||
import pytest
|
||||
from unittest.mock import AsyncMock, patch
|
||||
from httpx import AsyncClient
|
||||
|
||||
from tests.conftest import auth_header
|
||||
@@ -194,13 +195,15 @@ async def test_delete_notification_channel(client: AsyncClient, admin_token: str
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_notification_test_endpoint(client: AsyncClient, admin_token: str):
|
||||
@patch("app.services.notification_sender.NotificationSender.send", new_callable=AsyncMock)
|
||||
async def test_notification_test_endpoint(mock_send, client: AsyncClient, admin_token: str):
|
||||
mock_send.return_value = {"success": True, "message": "钉钉测试消息发送成功"}
|
||||
create = await client.post(
|
||||
"/api/v1/notifications",
|
||||
json={
|
||||
"name": "钉钉测试",
|
||||
"channel_type": "dingtalk",
|
||||
"config": {"webhook_url": "https://oapi.dingtalk.com/robot/send?access_token=test"},
|
||||
"config": {"webhook_url": "https://oapi.dingtalk.com/robot/send?access_token=***"},
|
||||
"is_enabled": True,
|
||||
},
|
||||
headers=auth_header(admin_token),
|
||||
@@ -365,9 +368,8 @@ async def test_ldap_test_connection(client: AsyncClient, admin_token: str):
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
data = resp.json()
|
||||
# Mock mode should return success
|
||||
assert data["success"] is True
|
||||
assert "Mock" in data["message"]
|
||||
# 测试环境无真实 LDAP 服务器,应返回失败
|
||||
assert data["success"] is False
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
Reference in new issue
Block a user