feat: add feishu notification test command

This commit is contained in:
2026-06-07 22:14:51 +08:00
parent 1a1b3ee9d4
commit be7fbab0a0
2 changed files with 78 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
from dataclasses import dataclass
from io import StringIO
from django.core.management import call_command
from django.core.management.base import CommandError
import pytest
pytestmark = pytest.mark.django_db
@dataclass(frozen=True)
class FakeRecord:
send_status: str = "success"
target: str = "负责人"
error_message: str = ""
def test_send_test_feishu_notification_calls_dispatcher(monkeypatch, django_user_model):
user = django_user_model.objects.create_user(username="owner", password="pass")
calls = []
monkeypatch.setattr(
"review_agent.management.commands.send_test_feishu_notification.dispatch_workflow_notification",
lambda context: calls.append(context) or FakeRecord(),
)
output = StringIO()
call_command("send_test_feishu_notification", "--username", user.username, stdout=output)
assert calls
assert calls[0].workflow_type == "manual_test"
assert calls[0].trigger_user_id == user.pk
assert "send_status=success" in output.getvalue()
assert "target=负责人" in output.getvalue()
def test_send_test_feishu_notification_missing_user_raises():
with pytest.raises(CommandError):
call_command("send_test_feishu_notification", "--username", "missing")