test_dataset.json 4.77 KB
{
  "version": "1.0.0",
  "agent": "youtube-crawler",
  "description": "YouTube 爬虫测试数据集 - 包含边缘情况和异常场景",
  "generated_at": "2026-04-01T00:00:00Z",
  "total_cases": 12,
  "cases": [
    {
      "id": "TEST_001",
      "type": "edge_case",
      "category": "empty_result",
      "description": "空结果处理 - 无效分类 ID",
      "input": {
        "regionCode": "US",
        "videoCategoryId": "999"
      },
      "expected": {
        "items_count": 0,
        "handled_gracefully": true,
        "no_exception": true
      }
    },
    {
      "id": "TEST_002",
      "type": "edge_case",
      "category": "special_characters",
      "description": "特殊字符标题处理",
      "input": {
        "test_titles": [
          "Title with \"quotes\"",
          "Title with 'apostrophes'",
          "Title with 🎵 emoji",
          "Title with, comma",
          "Title with\nnewline"
        ]
      },
      "expected": {
        "csv_export_safe": true,
        "no_truncation": true
      }
    },
    {
      "id": "TEST_003",
      "type": "edge_case",
      "category": "large_numbers",
      "description": "超大 viewCount 数值处理",
      "input": {
        "view_counts": [
          "9223372036854775807",
          "9999999999999"
        ]
      },
      "expected": {
        "parsed_correctly": true,
        "no_overflow": true,
        "type": "integer"
      }
    },
    {
      "id": "TEST_004",
      "type": "edge_case",
      "category": "missing_fields",
      "description": "缺失可选字段处理",
      "input": {
        "video_data": {
          "id": "abc123",
          "snippet": { "title": "Test" },
          "statistics": {}
        }
      },
      "expected": {
        "default_values": {
          "viewCount": 0,
          "likeCount": null,
          "commentCount": null
        },
        "no_crash": true
      }
    },
    {
      "id": "TEST_005",
      "type": "edge_case",
      "category": "private_deleted",
      "description": "私密/删除视频处理",
      "input": {
        "video_ids": ["deleted123", "private456"]
      },
      "expected": {
        "skipped": true,
        "continued_processing": true
      }
    },
    {
      "id": "TEST_006",
      "type": "error_case",
      "category": "quota_exceeded",
      "description": "配额耗尽场景",
      "input": {
        "quota_remaining": 0,
        "request": {
          "regionCode": "US"
        }
      },
      "expected": {
        "fallback_to_ytdlp": true,
        "data_returned": true,
        "warning_logged": true
      }
    },
    {
      "id": "TEST_007",
      "type": "error_case",
      "category": "network_timeout",
      "description": "网络超时处理",
      "input": {
        "timeout": 30,
        "retry_attempts": 3
      },
      "expected": {
        "retried": true,
        "max_retries": 3,
        "final_error_clear": true
      }
    },
    {
      "id": "TEST_008",
      "type": "error_case",
      "category": "malformed_response",
      "description": "异常响应格式处理",
      "input": {
        "response": "not valid json",
        "status": 200
      },
      "expected": {
        "parse_error_handled": true,
        "no_crash": true
      }
    },
    {
      "id": "TEST_009",
      "type": "integration",
      "category": "full_workflow",
      "description": "完整工作流测试 - API 方案",
      "input": {
        "regions": ["US", "JP"],
        "categories": ["10", "20"],
        "output_format": "json"
      },
      "expected": {
        "all_regions_success": true,
        "all_categories_success": true,
        "output_valid": true,
        "min_total_items": 100
      }
    },
    {
      "id": "TEST_010",
      "type": "integration",
      "category": "fallback_workflow",
      "description": "降级工作流测试 - API 失败转 yt-dlp",
      "input": {
        "force_api_failure": true,
        "fallback_enabled": true
      },
      "expected": {
        "api_failed": true,
        "fallback_triggered": true,
        "ytdlp_succeeded": true,
        "data_returned": true
      }
    },
    {
      "id": "TEST_011",
      "type": "integration",
      "category": "multi_format_export",
      "description": "多格式同时导出",
      "input": {
        "regionCode": "US",
        "export_formats": ["json", "csv"]
      },
      "expected": {
        "json_exported": true,
        "csv_exported": true,
        "data_consistent": true
      }
    },
    {
      "id": "TEST_012",
      "type": "integration",
      "category": "cache_efficiency",
      "description": "缓存效率验证",
      "input": {
        "same_request_times": 5,
        "cache_ttl": 900
      },
      "expected": {
        "api_calls_made": 1,
        "cache_hits": 4,
        "quota_saved": 4
      }
    }
  ]
}