mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-01 07:58:23 +00:00
failing cost test
This commit is contained in:
1 parent
fa6f49ee05
commit
953feb83c6
1 file changed
+65
+65
@@ -221,6 +221,9 @@ mod tests {
|
||||
// -- Cross-check with Kinovi via builder --
|
||||
|
||||
mod cross_check_with_kinovi {
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
|
||||
use crate::api::video_list_ref::VideoListRef;
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
@@ -268,6 +271,68 @@ mod tests {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Same combos as above, but with a reference video attached. Kinovi
|
||||
/// charges a per-second surcharge for video references, and the artcraft
|
||||
/// user price must still cover the provider cost.
|
||||
#[test]
|
||||
fn artcraft_price_covers_kinovi_cost_all_combos_with_video_reference() {
|
||||
let resolutions = [
|
||||
Some(RouterResolution::TenEightyP),
|
||||
Some(RouterResolution::FourEightyP),
|
||||
// NB: Still underpriced even at 231 credits/$1
|
||||
// (e.g. 5s: kinovi 87¢ vs user price 80¢).
|
||||
//Some(RouterResolution::SevenTwentyP),
|
||||
//None,
|
||||
];
|
||||
let durations: [u16; 4] = [15, 10, 5, 4];
|
||||
let batches: [u16; 3] = [1, 2, 4];
|
||||
|
||||
for res in &resolutions {
|
||||
for dur in &durations {
|
||||
for batch in &batches {
|
||||
let artcraft = GenerateVideoRequestBuilder {
|
||||
provider: RouterProvider::Artcraft,
|
||||
resolution: *res,
|
||||
duration_seconds: Some(*dur),
|
||||
video_batch_count: Some(*batch),
|
||||
// The artcraft provider only accepts media file tokens.
|
||||
reference_videos: Some(VideoListRef::MediaFileTokens(vec![
|
||||
MediaFileToken::new("mf_ref_video".to_string()),
|
||||
])),
|
||||
..Default::default()
|
||||
};
|
||||
let artcraft_cost = artcraft.build2()
|
||||
.expect("artcraft build2")
|
||||
.estimate_cost()
|
||||
.expect("artcraft estimate_cost");
|
||||
|
||||
let kinovi = GenerateVideoRequestBuilder {
|
||||
provider: RouterProvider::Seedance2Pro,
|
||||
resolution: *res,
|
||||
duration_seconds: Some(*dur),
|
||||
video_batch_count: Some(*batch),
|
||||
reference_videos: Some(VideoListRef::Urls(vec![
|
||||
"https://example.com/ref.mp4".to_string(),
|
||||
])),
|
||||
..Default::default()
|
||||
};
|
||||
let kinovi_cost = kinovi.build2()
|
||||
.expect("kinovi build2")
|
||||
.estimate_cost()
|
||||
.expect("kinovi estimate_cost");
|
||||
|
||||
let artcraft_cents = artcraft_cost.cost_in_usd_cents.expect("artcraft cents");
|
||||
let kinovi_cents = kinovi_cost.cost_in_usd_cents.expect("kinovi cents");
|
||||
assert!(
|
||||
kinovi_cents <= artcraft_cents + 1,
|
||||
"kinovi cost exceeds artcraft price: res={:?} dur={}s batch={} (artcraft={}, kinovi={})",
|
||||
res, dur, batch, artcraft_cents, kinovi_cents,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -- Helpers --
|
||||
|
||||
Reference in new issue
Block a user