feat: rank growth events with grounded evidence
This commit is contained in:
@@ -3,12 +3,13 @@ package eventcatalog
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestImpactfulBusinessCatalogIsValidAndIndustryPersonalized(t *testing.T) {
|
||||
data, err := os.ReadFile("../../catalogs/impactful-business-events-1405-v1.json")
|
||||
data, err := os.ReadFile("../../catalogs/impactful-business-events-1405-v2.json")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -42,3 +43,77 @@ func TestImpactfulBusinessCatalogIsValidAndIndustryPersonalized(t *testing.T) {
|
||||
t.Fatalf("catalog must provide year-round candidate coverage; got %d events across %d months", len(input.Events), len(months))
|
||||
}
|
||||
}
|
||||
|
||||
func TestImpactfulBusinessCatalogLinksExactHistoricalOccurrences(t *testing.T) {
|
||||
data, err := os.ReadFile("../../catalogs/impactful-business-events-1405-v2.json")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var input Import
|
||||
if err := json.Unmarshal(data, &input); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
required := []struct {
|
||||
occasionKey string
|
||||
variant string
|
||||
}{
|
||||
{"education-enrollment", "CAMPAIGN_WINDOW"},
|
||||
{"black-friday", "PRIMARY"},
|
||||
{"cyber-monday", "PRIMARY"},
|
||||
{"yalda", "CAMPAIGN_WINDOW"},
|
||||
{"nowruz", "CAMPAIGN_WINDOW"},
|
||||
{"nowruz", "OPERATIONAL_WINDOW"},
|
||||
}
|
||||
for _, identity := range required {
|
||||
years := make(map[int]bool)
|
||||
for _, event := range input.Events {
|
||||
if event.OccasionKey == identity.occasionKey && event.Variant == identity.variant {
|
||||
years[event.JalaliYear] = true
|
||||
}
|
||||
}
|
||||
for year := 1402; year <= 1405; year++ {
|
||||
if !years[year] {
|
||||
t.Errorf("%s/%s lacks occurrence for %d", identity.occasionKey, identity.variant, year)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestImpactfulBusinessCatalogDoesNotMislabelGregorian2027AsJalali1406(t *testing.T) {
|
||||
data, err := os.ReadFile("../../catalogs/impactful-business-events-1405-v2.json")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var input Import
|
||||
if err := json.Unmarshal(data, &input); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, event := range input.Events {
|
||||
if (event.OccasionKey == "ramadan" || event.OccasionKey == "eid-al-fitr") && event.JalaliYear == 1406 {
|
||||
t.Errorf("%s is before Nowruz 1406 and must not be labeled as Jalali 1406", event.ID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestImpactfulBusinessCatalogAttributesCustomWindowsToInternalPolicy(t *testing.T) {
|
||||
data, err := os.ReadFile("../../catalogs/impactful-business-events-1405-v2.json")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var input Import
|
||||
if err := json.Unmarshal(data, &input); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
customWindows := map[string]bool{
|
||||
"education-enrollment": true,
|
||||
"yalda": true,
|
||||
"nowruz": true,
|
||||
"ramadan": true,
|
||||
}
|
||||
for _, event := range input.Events {
|
||||
if event.Variant == "CAMPAIGN_WINDOW" && customWindows[event.OccasionKey] && !strings.HasPrefix(event.SourceURI, "urn:zarinpal:event-window-policy:") {
|
||||
t.Errorf("%s custom window must cite the internal derivation policy, got %q", event.ID, event.SourceURI)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user