| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- import pytest
- from aigc_push_registry.registry import normalize_manual_record, parse_datetime
- def test_normalize_manual_record_accepts_only_real_pushes():
- record = normalize_manual_record(
- {
- "push_record_id": "aigc_push_run_001",
- "run_id": "run_001",
- "platform": "douyin",
- "pushed_at": "2026-06-26T05:05:09+00:00",
- "push_status": "pushed",
- "plans": [
- {
- "plan_part": "1",
- "produce_plan_id": "produce_001",
- "crawler_plan_id": "crawler_001",
- "video_ids": ["aweme_001", "aweme_002"],
- }
- ],
- }
- )
- assert record["push_status"] == "pushed"
- assert record["plans"][0]["content_count"] == 2
- assert record["plans"][0]["items"] == [
- {"platform_content_id": "aweme_001"},
- {"platform_content_id": "aweme_002"},
- ]
- def test_normalize_manual_record_rejects_dry_run():
- with pytest.raises(ValueError, match="dry-run"):
- normalize_manual_record(
- {
- "push_record_id": "aigc_push_run_001",
- "run_id": "run_001",
- "platform": "douyin",
- "pushed_at": "2026-06-26T05:05:09+00:00",
- "push_status": "dry_run",
- "plans": [
- {
- "plan_part": "1",
- "produce_plan_id": "produce_001",
- "crawler_plan_id": "crawler_001",
- "video_ids": ["aweme_001"],
- }
- ],
- }
- )
- def test_parse_datetime_converts_offset_to_utc_naive():
- parsed = parse_datetime("2026-06-26T13:05:09+08:00")
- assert parsed.isoformat() == "2026-06-26T05:05:09"
|