test_16_content_live.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. """内容运营 — 真实联调(仅查询类;群发写入默认跳过)"""
  2. import pytest
  3. pytestmark = [pytest.mark.integration, pytest.mark.qiwei_live]
  4. def test_live_proxy_send_group_msg_status_shape(api, live_guid):
  5. """
  6. 仅验证 QiWe 群发状态接口可达(使用占位 groupMsgId,预期业务错误而非 Token 错误)。
  7. 不向真实群发送消息。
  8. """
  9. resp = api.post(
  10. "/qiwei/proxy",
  11. json={
  12. "method": "/msg/sendGroupMsgStatus",
  13. "params": {
  14. "guid": live_guid,
  15. "groupMsgId": "live-test-placeholder-not-real",
  16. "endDetailId": 2,
  17. },
  18. },
  19. )
  20. body = api.parse_json(resp)
  21. # 成功或 QiWe 业务错误均可,说明 Token+guid 已打通
  22. if body.get("success"):
  23. assert isinstance(body.get("data"), dict)
  24. else:
  25. err = body.get("error") or {}
  26. assert err.get("code") in ("QIWEI_API_ERROR", "INTERNAL_ERROR")
  27. assert "QIWEI_TOKEN_MISSING" not in str(err.get("code", ""))
  28. def test_live_create_broadcast(api, live_guid, live_room_id, live_rooms_seeded):
  29. from load_env import load_backend_env
  30. if load_backend_env().get("QIWEI_LIVE_ALLOW_BROADCAST", "").strip() != "1":
  31. pytest.skip(
  32. "未开启真实群发:在 backend/.env 设置 QIWEI_LIVE_ALLOW_BROADCAST=1 "
  33. "(会向 QIWEI_ROOM_IDS 中的群发送测试文案)"
  34. )
  35. """若需自动化群发联调,去掉 skip 并确认 toIdList 为测试群"""
  36. api.assert_success(
  37. api.post(
  38. "/content/broadcasts",
  39. json={
  40. "guid": live_guid,
  41. "sendType": 1,
  42. "toIdList": [live_room_id],
  43. "msgList": [{"type": 0, "msgData": {"content": "自动化联调测试"}}],
  44. },
  45. ),
  46. status=201,
  47. )