fixes
This commit is contained in:
1 parent
c347d2418f
commit
1ad180a052
49 files changed
+6339
-89
No files matched your search
@@ -0,0 +1,49 @@
|
||||
package processing
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// Supplier feeds without categories (pilot: Koopman, Trbovc Excel) must keep their
|
||||
// own specs; the model may refine those keys but not invent new ones.
|
||||
func TestRunSteps_uncategorizedKeepsSupplierSpecs(t *testing.T) {
|
||||
t.Parallel()
|
||||
e := &Engine{
|
||||
Completer: stubCompleter{fn: func(system, user string) (Completion, error) {
|
||||
return Completion{
|
||||
Text: `{"name":"Advent wreath gold 41 cm","description":"<p>Gold wreath.</p>","attrs":{"volume_in_m3":"0.882","color":"gold","battery_life":"200 h"}}`,
|
||||
TotalTokens: 5,
|
||||
}, nil
|
||||
}},
|
||||
Vector: NoopVectorCategorizer{},
|
||||
}
|
||||
in := ProductInput{
|
||||
GTIN: "8721461009242",
|
||||
Name: "WREATH ADVENT 41CM GOLD",
|
||||
Mapped: map[string]any{
|
||||
"name": "WREATH ADVENT 41CM GOLD",
|
||||
"specifications": map[string]any{"Volume in m3": "0.882", "Statistic no": "06049099"},
|
||||
},
|
||||
// Production job cache: taxonomy keys exist, but this product has no category.
|
||||
CategoryAttrKeys: map[string]map[string]struct{}{},
|
||||
}
|
||||
out, err := e.RunSteps(context.Background(), "co", in, "full", nil, StepPolicy{AllowAI: true})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if out.Category != "" {
|
||||
t.Fatalf("Category=%q want empty", out.Category)
|
||||
}
|
||||
for _, want := range []string{"volume_in_m3", "statistic_no", "color"} {
|
||||
if _, ok := out.Attributes[want]; !ok {
|
||||
t.Fatalf("missing %q in %v", want, out.Attributes)
|
||||
}
|
||||
}
|
||||
if _, ok := out.Attributes["battery_life"]; ok {
|
||||
t.Fatalf("model-invented key persisted: %v", out.Attributes)
|
||||
}
|
||||
if got := persistAllowedAttrKeys(map[string]map[string]struct{}{}, ""); got != nil {
|
||||
t.Fatalf("persist allowlist for uncategorized = %v want nil (already constrained)", got)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user