|
|
|
|
@ -548,7 +548,19 @@ async fn generate_returns_202_with_job_id() {
|
|
|
|
|
.create_authenticated_user("synth-gen@example.com")
|
|
|
|
|
.await;
|
|
|
|
|
|
|
|
|
|
let body = serde_json::json!({});
|
|
|
|
|
// Create a theme first
|
|
|
|
|
let theme_body = serde_json::json!({
|
|
|
|
|
"name": "Test Theme",
|
|
|
|
|
"theme": "Test Topic",
|
|
|
|
|
"categories": ["Test Category"]
|
|
|
|
|
});
|
|
|
|
|
let (theme_status, theme_resp) = app
|
|
|
|
|
.post_with_session("/api/v1/themes", &theme_body, &session)
|
|
|
|
|
.await;
|
|
|
|
|
assert_eq!(theme_status.as_u16(), 201, "Theme creation should succeed");
|
|
|
|
|
let theme_id = theme_resp["id"].as_str().expect("Theme should have an id");
|
|
|
|
|
|
|
|
|
|
let body = serde_json::json!({ "theme_id": theme_id });
|
|
|
|
|
let (status, resp) = app
|
|
|
|
|
.post_with_session("/api/v1/syntheses/generate", &body, &session)
|
|
|
|
|
.await;
|
|
|
|
|
@ -582,7 +594,17 @@ async fn generate_twice_returns_error_for_second() {
|
|
|
|
|
.create_authenticated_user("synth-gen-dup@example.com")
|
|
|
|
|
.await;
|
|
|
|
|
|
|
|
|
|
let body = serde_json::json!({});
|
|
|
|
|
let theme_body = serde_json::json!({
|
|
|
|
|
"name": "Dup Test Theme",
|
|
|
|
|
"theme": "Dup Topic",
|
|
|
|
|
"categories": ["Cat"]
|
|
|
|
|
});
|
|
|
|
|
let (_, theme_resp) = app
|
|
|
|
|
.post_with_session("/api/v1/themes", &theme_body, &session)
|
|
|
|
|
.await;
|
|
|
|
|
let theme_id = theme_resp["id"].as_str().unwrap();
|
|
|
|
|
|
|
|
|
|
let body = serde_json::json!({ "theme_id": theme_id });
|
|
|
|
|
|
|
|
|
|
// First call should succeed with 202
|
|
|
|
|
let (status1, resp1) = app
|
|
|
|
|
@ -624,19 +646,14 @@ async fn generate_pipeline_resolves_model_from_admin_config() {
|
|
|
|
|
.create_authenticated_user("synth-model-resolve@example.com")
|
|
|
|
|
.await;
|
|
|
|
|
|
|
|
|
|
// Configure user settings with provider and categories
|
|
|
|
|
// Configure user settings with provider
|
|
|
|
|
let settings = serde_json::json!({
|
|
|
|
|
"theme": "Intelligence Artificielle",
|
|
|
|
|
"max_age_days": 7,
|
|
|
|
|
"categories": ["Test Category"],
|
|
|
|
|
"max_items_per_category": 4,
|
|
|
|
|
"max_articles_per_source": 3,
|
|
|
|
|
"max_links_per_source": 8,
|
|
|
|
|
|
|
|
|
|
"use_brave_search": false,
|
|
|
|
|
"article_history_days": 90,
|
|
|
|
|
"batch_size": 5,
|
|
|
|
|
"summary_length": 3,
|
|
|
|
|
"source_extraction_window": 3,
|
|
|
|
|
"search_agent_behavior": "",
|
|
|
|
|
"ai_provider": "openai",
|
|
|
|
|
@ -650,6 +667,21 @@ async fn generate_pipeline_resolves_model_from_admin_config() {
|
|
|
|
|
.await;
|
|
|
|
|
assert_eq!(settings_status, StatusCode::OK, "Settings save should succeed");
|
|
|
|
|
|
|
|
|
|
// Create a theme with the content settings
|
|
|
|
|
let theme_body = serde_json::json!({
|
|
|
|
|
"name": "Test Theme",
|
|
|
|
|
"theme": "Intelligence Artificielle",
|
|
|
|
|
"categories": ["Test Category"],
|
|
|
|
|
"max_items_per_category": 4,
|
|
|
|
|
"max_age_days": 7,
|
|
|
|
|
"summary_length": 3
|
|
|
|
|
});
|
|
|
|
|
let (theme_status, theme_resp) = app
|
|
|
|
|
.post_with_session("/api/v1/themes", &theme_body, &session)
|
|
|
|
|
.await;
|
|
|
|
|
assert_eq!(theme_status.as_u16(), 201, "Theme creation should succeed");
|
|
|
|
|
let theme_id = theme_resp["id"].as_str().expect("Theme should have an id");
|
|
|
|
|
|
|
|
|
|
// Store a fake API key — we don't need a real one, just need to get past
|
|
|
|
|
// model resolution and into the LLM call
|
|
|
|
|
let key_body = serde_json::json!({
|
|
|
|
|
@ -664,7 +696,8 @@ async fn generate_pipeline_resolves_model_from_admin_config() {
|
|
|
|
|
// Add a source so the pipeline has something to work with
|
|
|
|
|
let source_body = serde_json::json!({
|
|
|
|
|
"title": "Test Source",
|
|
|
|
|
"url": "https://example.com"
|
|
|
|
|
"url": "https://example.com",
|
|
|
|
|
"theme_id": theme_id
|
|
|
|
|
});
|
|
|
|
|
let (source_status, _) = app
|
|
|
|
|
.post_with_session("/api/v1/sources", &source_body, &session)
|
|
|
|
|
@ -675,7 +708,7 @@ async fn generate_pipeline_resolves_model_from_admin_config() {
|
|
|
|
|
// the HTTP trigger returns 202 (not 500) and the async job doesn't crash
|
|
|
|
|
// on a database error. It will fail at the LLM API call (fake key), which
|
|
|
|
|
// is expected and fine — the model resolution path was exercised.
|
|
|
|
|
let gen_body = serde_json::json!({});
|
|
|
|
|
let gen_body = serde_json::json!({ "theme_id": theme_id });
|
|
|
|
|
let (gen_status, gen_resp) = app
|
|
|
|
|
.post_with_session("/api/v1/syntheses/generate", &gen_body, &session)
|
|
|
|
|
.await;
|
|
|
|
|
|