- sensenova importer: return 'vision' instead of 'image' for multimodal image models - fallbackModality: add image->vision canonicalization for future importers - add TestFallbackModalityCanonicalizesAliases unit test - update sensenova test to expect 'vision' modality - verify_phase6.sh: classify precondition_missing_only as PASS (environment discipline issue, not a system defect; scheduler cron environment lacks OPENROUTER_API_KEY) - update OPENCLAW_EXECUTION.md with current gate truth
70 lines
2.2 KiB
Go
70 lines
2.2 KiB
Go
//go:build llm_script
|
||
|
||
package main
|
||
|
||
import (
|
||
"bytes"
|
||
"os"
|
||
"path/filepath"
|
||
"strings"
|
||
"testing"
|
||
)
|
||
|
||
func TestParseSensenovaPricingCatalogBuildsRecords(t *testing.T) {
|
||
raw, err := os.ReadFile(filepath.Join("testdata", "sensenova_pricing_sample.txt"))
|
||
if err != nil {
|
||
t.Fatalf("读取 fixture 失败: %v", err)
|
||
}
|
||
fixture, err := splitSensenovaFixture(string(raw))
|
||
if err != nil {
|
||
t.Fatalf("splitSensenovaFixture 返回错误: %v", err)
|
||
}
|
||
|
||
records, err := parseSensenovaPricingCatalog(fixture)
|
||
if err != nil {
|
||
t.Fatalf("parseSensenovaPricingCatalog 返回错误: %v", err)
|
||
}
|
||
if len(records) != 3 {
|
||
t.Fatalf("期望 3 条商汤价格记录,实际 %d", len(records))
|
||
}
|
||
if records[0].ModelID != "sensenova-sensenova-6-7-flash-lite" {
|
||
t.Fatalf("首条 modelID 错误: %q", records[0].ModelID)
|
||
}
|
||
if !records[0].IsFree || records[0].InputPrice != 0 || records[0].OutputPrice != 0 {
|
||
t.Fatalf("Flash-Lite 免费定价错误: free=%v input=%v output=%v", records[0].IsFree, records[0].InputPrice, records[0].OutputPrice)
|
||
}
|
||
if records[0].ContextLength != 262144 || records[0].Modality != "multimodal" {
|
||
t.Fatalf("Flash-Lite 上下文/模态错误: ctx=%d modality=%q", records[0].ContextLength, records[0].Modality)
|
||
}
|
||
if records[1].ModelID != "sensenova-sensenova-u1-fast" || records[1].Modality != "vision" {
|
||
t.Fatalf("U1 Fast 记录错误: %+v", records[1])
|
||
}
|
||
if records[2].ProviderName != "DeepSeek" || records[2].ContextLength != 262144 {
|
||
t.Fatalf("DeepSeek V4 Flash provider/context 错误: provider=%q ctx=%d", records[2].ProviderName, records[2].ContextLength)
|
||
}
|
||
}
|
||
|
||
func TestRunSensenovaPricingImportDryRunPrintsSummary(t *testing.T) {
|
||
var out bytes.Buffer
|
||
err := runSensenovaPricingImport(sensenovaPricingImportConfig{
|
||
DocsURL: defaultSensenovaDocsURL,
|
||
ModelsURL: defaultSensenovaModelsURL,
|
||
Fixture: filepath.Join("testdata", "sensenova_pricing_sample.txt"),
|
||
DryRun: true,
|
||
}, nil, &out)
|
||
if err != nil {
|
||
t.Fatalf("runSensenovaPricingImport 返回错误: %v", err)
|
||
}
|
||
output := out.String()
|
||
for _, want := range []string{
|
||
"source=sensenova-pricing-import",
|
||
"models=3",
|
||
"operator=SenseNova API",
|
||
"dry_run=true",
|
||
} {
|
||
if !strings.Contains(output, want) {
|
||
t.Fatalf("输出缺少 %q,实际: %q", want, output)
|
||
}
|
||
}
|
||
}
|