test_aigc_push_registry.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import pytest
  2. from aigc_push_registry.registry import normalize_manual_record, parse_datetime
  3. def test_normalize_manual_record_accepts_only_real_pushes():
  4. record = normalize_manual_record(
  5. {
  6. "push_record_id": "aigc_push_run_001",
  7. "run_id": "run_001",
  8. "platform": "douyin",
  9. "pushed_at": "2026-06-26T05:05:09+00:00",
  10. "push_status": "pushed",
  11. "plans": [
  12. {
  13. "plan_part": "1",
  14. "produce_plan_id": "produce_001",
  15. "crawler_plan_id": "crawler_001",
  16. "video_ids": ["aweme_001", "aweme_002"],
  17. }
  18. ],
  19. }
  20. )
  21. assert record["push_status"] == "pushed"
  22. assert record["plans"][0]["content_count"] == 2
  23. assert record["plans"][0]["items"] == [
  24. {"platform_content_id": "aweme_001"},
  25. {"platform_content_id": "aweme_002"},
  26. ]
  27. def test_normalize_manual_record_rejects_dry_run():
  28. with pytest.raises(ValueError, match="dry-run"):
  29. normalize_manual_record(
  30. {
  31. "push_record_id": "aigc_push_run_001",
  32. "run_id": "run_001",
  33. "platform": "douyin",
  34. "pushed_at": "2026-06-26T05:05:09+00:00",
  35. "push_status": "dry_run",
  36. "plans": [
  37. {
  38. "plan_part": "1",
  39. "produce_plan_id": "produce_001",
  40. "crawler_plan_id": "crawler_001",
  41. "video_ids": ["aweme_001"],
  42. }
  43. ],
  44. }
  45. )
  46. def test_parse_datetime_converts_offset_to_utc_naive():
  47. parsed = parse_datetime("2026-06-26T13:05:09+08:00")
  48. assert parsed.isoformat() == "2026-06-26T05:05:09"