feat: train proxy and correct staffing peak fixture
This commit is contained in:
1 parent
f284969a4b
commit
4b9c2da9f7
7 files changed
+575
-10
No files matched your search
@@ -24,8 +24,10 @@ import (
|
||||
const fixtureDir = "../../testdata/data"
|
||||
|
||||
type stubML struct {
|
||||
predict func(context.Context, ml.PredictRequest) ([]model.ForecastPoint, error)
|
||||
simulate func(context.Context, ml.SimulateRequest) (map[string]map[string][]model.ForecastPoint, error)
|
||||
predict func(context.Context, ml.PredictRequest) ([]model.ForecastPoint, error)
|
||||
simulate func(context.Context, ml.SimulateRequest) (map[string]map[string][]model.ForecastPoint, error)
|
||||
train func(context.Context, string, io.Reader) (int, []byte, error)
|
||||
trainStatus func(context.Context, string) (int, []byte, error)
|
||||
}
|
||||
|
||||
func (s *stubML) Predict(ctx context.Context, req ml.PredictRequest) ([]model.ForecastPoint, error) {
|
||||
@@ -42,6 +44,20 @@ func (s *stubML) Simulate(ctx context.Context, req ml.SimulateRequest) (map[stri
|
||||
return s.simulate(ctx, req)
|
||||
}
|
||||
|
||||
func (s *stubML) Train(ctx context.Context, contentType string, body io.Reader) (int, []byte, error) {
|
||||
if s.train == nil {
|
||||
return 0, nil, errors.New("ml unavailable")
|
||||
}
|
||||
return s.train(ctx, contentType, body)
|
||||
}
|
||||
|
||||
func (s *stubML) TrainStatus(ctx context.Context, jobID string) (int, []byte, error) {
|
||||
if s.trainStatus == nil {
|
||||
return 0, nil, errors.New("ml unavailable")
|
||||
}
|
||||
return s.trainStatus(ctx, jobID)
|
||||
}
|
||||
|
||||
func loadFixtureStore(t *testing.T) *store.Store {
|
||||
t.Helper()
|
||||
st, err := store.Load(fixtureDir)
|
||||
@@ -168,8 +184,8 @@ func TestSeriesRangeStepAndErrors(t *testing.T) {
|
||||
_, ts := newTestServer(t, &stubML{}, nil)
|
||||
|
||||
var body struct {
|
||||
Sensor string `json:"sensor"`
|
||||
Step string `json:"step"`
|
||||
Sensor string `json:"sensor"`
|
||||
Step string `json:"step"`
|
||||
Points []model.Point `json:"points"`
|
||||
}
|
||||
resp := getJSON(t, ts.URL+"/api/series?sensor=hn-bahnhof-01&from=2026-11-01T00:00:00Z&to=2026-11-01T23:59:59Z&step=15m", &body)
|
||||
|
||||
Reference in new issue
Block a user