remove unused test
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
use crate::editor_agent::utils::{ImageId, ImageMetadata};
|
||||
use crate::editor_generation_config::EditorGenerationPricingConfig;
|
||||
use crate::http_error::AppError;
|
||||
use crate::openai_image_generation::GPT_IMAGE_2_MODEL;
|
||||
use axum::http::StatusCode;
|
||||
use module_editor_agent::agent::tool::Tool;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
use axum::http::StatusCode;
|
||||
use serde_json::json;
|
||||
use crate::http_error::AppError;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
||||
pub struct EditorToolContext {
|
||||
pub images: HashMap<ImageId, ImageMetadata>,
|
||||
}
|
||||
@@ -53,4 +53,4 @@ pub fn image_not_found(image_id: &ImageId) -> AppError {
|
||||
"provider": "editor-agent",
|
||||
"message": format!("asset {image_id} not found in context"),
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,11 @@
|
||||
use crate::editor_agent::editor_tools::common::{
|
||||
EditorAgentPricedTool, EditorToolContext, editor_agent_image_mud_points,
|
||||
editor_agent_image_mud_points, EditorAgentPricedTool, EditorToolContext,
|
||||
};
|
||||
use crate::editor_agent::utils::ImageId;
|
||||
use crate::editor_generation_config::EditorGenerationPricingConfig;
|
||||
use crate::editor_project::{
|
||||
EditorGenerationCaller, EditorImageGenerationRequest, generate_editor_image_for_owner,
|
||||
};
|
||||
use crate::http_error::AppError;
|
||||
use crate::request_context::RequestContext;
|
||||
use crate::state::AppState;
|
||||
use axum::http::StatusCode;
|
||||
use module_editor_agent::agent::tool::{Tool, ToolFailure, ToolFailureKind};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{Value, json};
|
||||
use shared_contracts::api::ApiSuccessEnvelope;
|
||||
use shared_contracts::assets::EditorCanvasGenerationCompletionPayload;
|
||||
use serde_json::{json, Value};
|
||||
use std::error::Error;
|
||||
use std::fmt::Display;
|
||||
|
||||
@@ -181,72 +172,3 @@ impl GenerateImageTool {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::collections::HashMap;
|
||||
|
||||
fn tool() -> GenerateImageTool {
|
||||
let image_id = ImageId::from_data_key("reference.png");
|
||||
GenerateImageTool {
|
||||
context: EditorToolContext {
|
||||
images: HashMap::from([(
|
||||
image_id,
|
||||
crate::editor_agent::utils::ImageMetadata {
|
||||
tag: String::new(),
|
||||
data_key: "reference.png".to_string(),
|
||||
},
|
||||
)]),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn proposal_accepts_prompt_and_known_references() {
|
||||
let output = tool()
|
||||
.call(GenerateImageToolArgs {
|
||||
prompt: "雨夜的霓虹街道".to_string(),
|
||||
reference_image_ids: vec![ImageId::from_data_key("reference.png")],
|
||||
aspect_ratio: Some("16:9".to_string()),
|
||||
image_size: Some("2K".to_string()),
|
||||
})
|
||||
.await
|
||||
.expect("proposal should be valid");
|
||||
|
||||
assert!(output.message.contains("pending user confirmation"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn proposal_rejects_missing_prompt_and_unknown_reference() {
|
||||
let prompt_error = tool()
|
||||
.call(GenerateImageToolArgs {
|
||||
prompt: " ".to_string(),
|
||||
reference_image_ids: Vec::new(),
|
||||
aspect_ratio: None,
|
||||
image_size: None,
|
||||
})
|
||||
.await
|
||||
.expect_err("blank prompt must fail");
|
||||
assert!(matches!(
|
||||
prompt_error,
|
||||
GenerateImageError::PromptNotProvided
|
||||
));
|
||||
|
||||
let reference_error = tool()
|
||||
.call(GenerateImageToolArgs {
|
||||
prompt: "一棵树".to_string(),
|
||||
reference_image_ids: vec![ImageId {
|
||||
id: "missing.png".to_string(),
|
||||
}],
|
||||
aspect_ratio: None,
|
||||
image_size: None,
|
||||
})
|
||||
.await
|
||||
.expect_err("unknown reference must fail");
|
||||
assert!(matches!(
|
||||
reference_error,
|
||||
GenerateImageError::AssetNotFound(_)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user