use openai_tools::models::request::Models;
#[tokio::test]
async fn test_list_models() {
let models = Models::new().expect("Should create Models client");
let response = models.list().await.expect("Should list models");
assert_eq!(response.object, "list");
assert!(!response.data.is_empty(), "Should have at least one model");
for model in &response.data {
assert!(!model.id.is_empty(), "Model ID should not be empty");
assert_eq!(model.object, "model");
assert!(model.created > 0, "Created timestamp should be positive");
assert!(!model.owned_by.is_empty(), "owned_by should not be empty");
}
println!("Found {} models", response.data.len());
}
#[tokio::test]
async fn test_retrieve_model() {
let models = Models::new().expect("Should create Models client");
let model = models.retrieve("gpt-4o-mini").await.expect("Should retrieve gpt-4o-mini");
assert_eq!(model.id, "gpt-4o-mini");
assert_eq!(model.object, "model");
assert!(model.created > 0);
assert!(!model.owned_by.is_empty());
println!("Retrieved model: {} (owned by {})", model.id, model.owned_by);
}
#[tokio::test]
async fn test_retrieve_multiple_models() {
let models = Models::new().expect("Should create Models client");
let model_ids = vec!["gpt-4o-mini", "text-embedding-3-small"];
for model_id in model_ids {
let model = models.retrieve(model_id).await.expect(&format!("Should retrieve {}", model_id));
assert_eq!(model.id, model_id);
println!("Retrieved: {} (created: {})", model.id, model.created);
}
}
#[tokio::test]
async fn test_retrieve_nonexistent_model() {
let models = Models::new().expect("Should create Models client");
let result = models.retrieve("nonexistent-model-12345").await;
assert!(result.is_err(), "Should fail for non-existent model");
}