from __future__ import annotations import json import unittest from daily_report.robot_service import create_reminder_payload, create_summary_payload class RobotServiceTest(unittest.TestCase): def test_creates_reminder_payload_with_submit_link(self) -> None: payload = create_reminder_payload("http://localhost:8787/submit", "每日工作汇报提醒") text = json.dumps(payload, ensure_ascii=False) self.assertEqual(payload["msg_type"], "interactive") self.assertIn("每日工作汇报提醒", text) self.assertIn("http://localhost:8787/submit", text) def test_creates_summary_payload_with_missing_employees(self) -> None: payload = create_summary_payload( "http://localhost:8787/manager", { "date": "2026-05-07", "expectedCount": 2, "submittedCount": 1, "missingCount": 1, "missing": [{"name": "Chen"}], }, ) text = json.dumps(payload, ensure_ascii=False) self.assertIn("2026-05-07", text) self.assertIn("1/2", text) self.assertIn("Chen", text) self.assertIn("http://localhost:8787/manager", text) if __name__ == "__main__": unittest.main()