test_09_koc.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. """§9 KOC 与意向客户"""
  2. import pytest
  3. pytestmark = pytest.mark.integration
  4. def test_channels_and_intent(api, uid):
  5. ch = api.assert_success(
  6. api.post(
  7. "/channels",
  8. json={
  9. "name": f"渠道{uid}",
  10. "code": f"ch-{uid}",
  11. "type": "offline",
  12. "remark": "pytest",
  13. },
  14. ),
  15. status=201,
  16. )
  17. ch_id = ch["id"]
  18. channels = api.assert_success(api.get("/channels"))
  19. assert any(c["id"] == ch_id for c in channels)
  20. detect = api.assert_success(
  21. api.post(
  22. "/intent-leads/detect",
  23. json={
  24. "userId": f"user-{uid}",
  25. "roomId": f"room-{uid}",
  26. "content": "这个方案多少钱?能约量房吗?",
  27. },
  28. )
  29. )
  30. assert isinstance(detect, dict)
  31. leads = api.assert_success(api.get("/intent-leads"))
  32. assert isinstance(leads, list)
  33. tasks = api.assert_success(api.get("/intent-tasks"))
  34. assert isinstance(tasks, list)
  35. candidates = api.assert_success(api.get("/koc/candidates"))
  36. assert isinstance(candidates, list)
  37. api.assert_success(api.delete(f"/channels/{ch_id}"))