feat(gateway): 补齐桌面端高级媒体直连接口
ci / verify (pull_request) Successful in 15m34s
ci / verify (pull_request) Successful in 15m34s
新增图片矢量化、视频超分、每日用量、计价与任务隔离能力,并通过环境变量解析平台凭据。 已通过 Go 全量门禁、迁移检查、镜像构建以及 Vectorizer 五格式和 Topaz 3 秒视频真实 DEV 验收。
This commit is contained in:
@@ -93,6 +93,64 @@ func TestVideoBillingEstimateProratesFiveSecondUnitsAndDynamicWeights(t *testing
|
||||
}
|
||||
}
|
||||
|
||||
func TestAdvancedMediaBillingUsesConversionAndTransitionMatrix(t *testing.T) {
|
||||
service := &Service{}
|
||||
vectorCandidate := store.RuntimeModelCandidate{ModelName: "easy-image-vectorizer-1", BaseBillingConfig: map[string]any{
|
||||
"image_vectorize": map[string]any{"basePrice": 200},
|
||||
}}
|
||||
vectorLine := firstBillingLine(t, service.billings(context.Background(), nil, "images.vectorize", map[string]any{"count": 1}, vectorCandidate, clients.Response{}, true))
|
||||
if vectorLine["resourceType"] != "image_vectorize" || vectorLine["unit"] != "conversion" || floatFromAny(vectorLine["amount"]) != 200 {
|
||||
t.Fatalf("unexpected vectorizer billing: %+v", vectorLine)
|
||||
}
|
||||
|
||||
topazCandidate := store.RuntimeModelCandidate{ModelName: "easy-proteus-standard-4", BaseBillingConfig: map[string]any{
|
||||
"video_enhance": map[string]any{
|
||||
"basePrice": 100,
|
||||
"dynamicWeight": map[string]any{
|
||||
"resolutionTransitions": map[string]any{"720p->1080p": 1.8},
|
||||
"frameRateTransitions": map[string]any{"24->60": 2.5},
|
||||
"markup": 1,
|
||||
},
|
||||
},
|
||||
}}
|
||||
topazLine := firstBillingLine(t, service.billings(context.Background(), nil, "videos.upscales", map[string]any{
|
||||
"count": 1, "duration": 5, "source_resolution": "720p", "target_resolution": "1080p",
|
||||
"source_frame_rate": 24, "target_frame_rate": 60, "slow_motion_rate": 2,
|
||||
"model": "easy-proteus-standard-4",
|
||||
}, topazCandidate, clients.Response{}, true))
|
||||
if got, want := floatFromAny(topazLine["amount"]), 900.0; got != want {
|
||||
t.Fatalf("video enhance amount=%v, want=%v, line=%+v", got, want, topazLine)
|
||||
}
|
||||
if topazLine["resolutionTransitionKey"] != "720p->1080p" || topazLine["frameRateTransitionKey"] != "24->60" {
|
||||
t.Fatalf("missing transition evidence: %+v", topazLine)
|
||||
}
|
||||
}
|
||||
|
||||
func TestVideoEnhancePricingFallbackUsesPixelsAndBaseline(t *testing.T) {
|
||||
amount, details := videoEnhanceAmount(map[string]any{"video_enhance": map[string]any{"dynamicWeight": map[string]any{}}}, videoEnhancePricingInputs{
|
||||
DurationSeconds: 5, DurationUnits: 1, SourceResolution: "720p", TargetResolution: "2160p",
|
||||
SourceFrameRate: 30, TargetFrameRate: 60, SlowMotionRate: 1,
|
||||
}, 1, 100)
|
||||
if amount != 2250 {
|
||||
t.Fatalf("fallback amount=%v, want=2250 details=%+v", amount, details)
|
||||
}
|
||||
}
|
||||
|
||||
func TestVideoEnhancePricingPrefersProbedDimensions(t *testing.T) {
|
||||
inputs := resolveVideoEnhancePricingInputs(map[string]any{
|
||||
"duration": 3,
|
||||
"source_resolution": "180p",
|
||||
"source_width": 320,
|
||||
"source_height": 180,
|
||||
"target_resolution": "720p",
|
||||
"output_width": 1280,
|
||||
"output_height": 720,
|
||||
}, clients.Response{})
|
||||
if inputs.SourceResolution != "480p" || inputs.TargetResolution != "720p" {
|
||||
t.Fatalf("dimension buckets = %s->%s, want 480p->720p", inputs.SourceResolution, inputs.TargetResolution)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMusicBillingUsesSongResourceAndOutputCount(t *testing.T) {
|
||||
service := &Service{}
|
||||
candidate := store.RuntimeModelCandidate{
|
||||
|
||||
Reference in New Issue
Block a user