feat(bloomberg): enrich article content for summaries (#36)
This commit is contained in:
@ -24,19 +24,20 @@ func TestTicket28GenerationAggregatesAllAssetsBeforeSelectionAndFailsClosed(t *t
|
||||
calls++
|
||||
var body struct {
|
||||
States []struct {
|
||||
Indices []map[string]string
|
||||
Title, Content string
|
||||
Indices []map[string]string
|
||||
Title, Content string
|
||||
ContentTruncated bool `json:"content_truncated"`
|
||||
}
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if len(body.States) != 2 {
|
||||
t.Error("expected both articles")
|
||||
t.Error("expected full two-state batch")
|
||||
}
|
||||
for _, state := range body.States {
|
||||
if len(state.Indices) != 1 || state.Content != content {
|
||||
t.Error("asset grouping or exact content lost")
|
||||
if len(state.Indices) != 1 || state.Content == "" || !strings.HasPrefix(content, state.Content) || !state.ContentTruncated {
|
||||
t.Error("asset grouping or explicit excerpt lost")
|
||||
}
|
||||
}
|
||||
if calls == 2 && failure == "http" {
|
||||
@ -64,7 +65,7 @@ func TestTicket28GenerationAggregatesAllAssetsBeforeSelectionAndFailsClosed(t *t
|
||||
model, key := "model", models.SourceYahooFinance
|
||||
feed := &ticket17HTTPScraper{articles: []scraper.Article{{Title: "first", URL: "https://fixture.invalid/first", Content: content}, {Title: "second", URL: "https://fixture.invalid/second", Content: content}}}
|
||||
summary := &ticket17HTTPSummary{}
|
||||
repo := &ticket17HTTPRepo{input: generation.UserInput{SummaryModelID: &model, Language: "fr", RankingMode: "title_content", GlobalLimit: 1, Assets: []models.UserAsset{{Name: "A", Symbol: "A"}, {Name: "B", Symbol: "B"}}, Sources: []models.Source{{ID: "source", SourceKey: &key, Enabled: true, ArticleLimit: 2}}}}
|
||||
repo := &ticket17HTTPRepo{input: generation.UserInput{SummaryModelID: &model, Language: "fr", RankingMode: "title_content", GlobalLimit: 1, Assets: []models.UserAsset{{Name: strings.Repeat("A", 400), Symbol: "A"}, {Name: strings.Repeat("B", 400), Symbol: "B"}}, Sources: []models.Source{{ID: "source", SourceKey: &key, Enabled: true, ArticleLimit: 2}}}}
|
||||
uc := generation.NewUseCase(generation.Dependencies{Repository: repo, SummaryResolver: &ticket17HTTPResolver{provider: summary}, LayaRanker: ranker, Scrapers: map[string]scraper.Scraper{key: feed}})
|
||||
result, err := uc.Generate(context.Background(), "owner")
|
||||
if err != nil || calls != 2 || feed.calls != 1 {
|
||||
@ -74,7 +75,7 @@ func TestTicket28GenerationAggregatesAllAssetsBeforeSelectionAndFailsClosed(t *t
|
||||
if result.Summary != nil || summary.calls != 0 || result.Outcome.Status != "failed" || result.Outcome.FailureCode != "ranking_failed" || repo.saved.Summary != nil {
|
||||
t.Fatal("partial summary after group failure")
|
||||
}
|
||||
} else if summary.calls != 1 || len(summary.candidates) != 1 || summary.candidates[0].Article.Title != "second" || result.Outcome.Status != "succeeded" {
|
||||
} else if summary.calls != 1 || len(summary.candidates) != 1 || summary.candidates[0].Article.Title != "second" || summary.candidates[0].Article.Content != content || result.Outcome.Status != "succeeded" {
|
||||
t.Fatal("selection happened before all groups", fmt.Sprint(result.Outcome))
|
||||
}
|
||||
saved, _ := json.Marshal(repo.saved.Outcome)
|
||||
|
||||
Reference in New Issue
Block a user