Files
llm-intelligence/scripts/import_qwen_pricing_test.go
phamnazage-jpg 6c3569fb65
Some checks failed
CI / go-test (push) Has been cancelled
CI / frontend-build (push) Has been cancelled
CI / docker-build (push) Has been cancelled
feat(pricing): add qwen hunyuan and huawei maas payg importers
2026-05-22 12:13:54 +08:00

62 lines
1.6 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//go:build llm_script
package main
import (
"bytes"
"os"
"path/filepath"
"strings"
"testing"
)
func TestParseQwenPricingCatalogBuildsRecords(t *testing.T) {
raw, err := os.ReadFile(filepath.Join("testdata", "qwen_pricing_sample.txt"))
if err != nil {
t.Fatalf("读取 fixture 失败: %v", err)
}
records, err := parseQwenPricingCatalog(string(raw))
if err != nil {
t.Fatalf("parseQwenPricingCatalog 返回错误: %v", err)
}
if len(records) != 4 {
t.Fatalf("期望 4 条通义千问价格记录,实际 %d", len(records))
}
if records[0].ModelID != "qwen-qwen-max" {
t.Fatalf("首条 modelID 错误: %q", records[0].ModelID)
}
if records[1].InputPrice != 0.8 || records[1].OutputPrice != 2 {
t.Fatalf("qwen-plus 定价错误: %v / %v", records[1].InputPrice, records[1].OutputPrice)
}
if records[2].Modality != "multimodal" {
t.Fatalf("qwen-vl-max modality 错误: %q", records[2].Modality)
}
if records[3].ProviderName != "Qwen" {
t.Fatalf("provider 错误: %q", records[3].ProviderName)
}
}
func TestRunQwenPricingImportDryRunPrintsSummary(t *testing.T) {
var out bytes.Buffer
err := runQwenPricingImport(qwenPricingImportConfig{
URL: defaultQwenPricingURL,
Fixture: filepath.Join("testdata", "qwen_pricing_sample.txt"),
DryRun: true,
}, nil, &out)
if err != nil {
t.Fatalf("runQwenPricingImport 返回错误: %v", err)
}
output := out.String()
for _, want := range []string{
"source=qwen-pricing-import",
"models=4",
"operator=DashScope",
"dry_run=true",
} {
if !strings.Contains(output, want) {
t.Fatalf("输出缺少 %q实际: %q", want, output)
}
}
}