use openai_tools::batch::request::Batches;
#[tokio::test]
async fn test_list_batches() {
let batches = Batches::new().expect("Failed to create Batches client");
let response = batches.list(Some(10), None).await;
assert!(response.is_ok(), "Failed to list batches: {:?}", response.err());
let list = response.unwrap();
assert_eq!(list.object, "list");
println!("Found {} batches", list.data.len());
}
#[tokio::test]
async fn test_list_batches_with_pagination() {
let batches = Batches::new().expect("Failed to create Batches client");
let response = batches.list(Some(5), None).await;
assert!(response.is_ok(), "Failed to list batches: {:?}", response.err());
let first_page = response.unwrap();
println!("First page: {} batches, has_more: {}", first_page.data.len(), first_page.has_more);
if first_page.has_more {
if let Some(last_id) = &first_page.last_id {
let second_page = batches.list(Some(5), Some(last_id)).await;
assert!(second_page.is_ok(), "Failed to get second page: {:?}", second_page.err());
println!("Second page: {} batches", second_page.unwrap().data.len());
}
}
}
#[tokio::test]
async fn test_retrieve_nonexistent_batch() {
let batches = Batches::new().expect("Failed to create Batches client");
let result = batches.retrieve("batch_nonexistent123").await;
assert!(result.is_err(), "Expected error for non-existent batch");
}