Добавил поиск метаданных по каталогам
This commit is contained in:
@@ -155,17 +155,71 @@ func TestConsistencyWarnings(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecide_AlwaysReview(t *testing.T) {
|
||||
p := Plan{Type: MediaMovie, Title: "X", Files: []PlanFile{{Role: RoleMain}}}
|
||||
d := decide(p, PreParse{})
|
||||
func TestDecide_MetadataDisabled(t *testing.T) {
|
||||
p := Plan{Type: MediaMovie, Title: "X", Confidence: 0.99, Files: []PlanFile{{Role: RoleMain}}}
|
||||
d := decide(p, PreParse{}, nil, false, 0.85)
|
||||
if d.Auto {
|
||||
t.Error("Ф2 decision must never be auto")
|
||||
t.Error("без метабаз авто недопустимо")
|
||||
}
|
||||
if len(d.Reasons) == 0 || !strings.Contains(d.Reasons[0], "метабазы отключены") {
|
||||
t.Errorf("first reason should be DB match, got %v", d.Reasons)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecide_NoMatch(t *testing.T) {
|
||||
p := Plan{Type: MediaMovie, Title: "X", Confidence: 0.99, Files: []PlanFile{{Role: RoleMain}}}
|
||||
d := decide(p, PreParse{}, nil, true, 0.85)
|
||||
if d.Auto || !strings.Contains(d.Reasons[0], "не найдено в базе") {
|
||||
t.Errorf("reasons = %v", d.Reasons)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecide_AutoMovie(t *testing.T) {
|
||||
p := Plan{Type: MediaMovie, Title: "The Matrix", Year: 1999, Confidence: 0.95,
|
||||
Files: []PlanFile{{Role: RoleMain}, {Role: RoleSample}}}
|
||||
match := &Match{Provider: "tmdb", ProviderID: "603", Title: "The Matrix", Year: 1999}
|
||||
d := decide(p, PreParse{Year: 1999}, match, true, 0.85)
|
||||
if !d.Auto {
|
||||
t.Errorf("clean movie with match must be auto, reasons: %v", d.Reasons)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecide_LowConfidenceBlocksAuto(t *testing.T) {
|
||||
p := Plan{Type: MediaMovie, Title: "X", Year: 2000, Confidence: 0.5,
|
||||
Files: []PlanFile{{Role: RoleMain}}}
|
||||
match := &Match{Provider: "tmdb", ProviderID: "1", Title: "X", Year: 2000}
|
||||
d := decide(p, PreParse{}, match, true, 0.85)
|
||||
if d.Auto || !hasReason(d.Reasons, "уверенность") {
|
||||
t.Errorf("low confidence must block auto, reasons: %v", d.Reasons)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecide_AutoSeriesEpisodeCount(t *testing.T) {
|
||||
s := 2
|
||||
mk := func(e int) PlanFile { ep := e; return PlanFile{Role: RoleEpisode, Season: &s, Episode: &ep} }
|
||||
p := Plan{Type: MediaSeries, Title: "Fargo", Year: 2014, Confidence: 0.9,
|
||||
Files: []PlanFile{mk(1), mk(2), mk(3)}}
|
||||
match := &Match{Provider: "tmdb", ProviderID: "1", Title: "Fargo", Year: 2014,
|
||||
SeasonEpisodeCounts: map[int]int{2: 3}}
|
||||
if d := decide(p, PreParse{Year: 2014}, match, true, 0.85); !d.Auto {
|
||||
t.Errorf("full season must be auto, reasons: %v", d.Reasons)
|
||||
}
|
||||
|
||||
// Неполный пак (в базе 10) — авто блокируется.
|
||||
match.SeasonEpisodeCounts = map[int]int{2: 10}
|
||||
if d := decide(p, PreParse{Year: 2014}, match, true, 0.85); d.Auto ||
|
||||
!hasReason(d.Reasons, "распознано серий 3, в базе 10") {
|
||||
t.Errorf("partial pack must block auto, reasons: %v", d.Reasons)
|
||||
}
|
||||
|
||||
// Нет данных о числе серий — авто блокируется.
|
||||
match.SeasonEpisodeCounts = nil
|
||||
if d := decide(p, PreParse{Year: 2014}, match, true, 0.85); d.Auto ||
|
||||
!hasReason(d.Reasons, "нет данных о числе серий") {
|
||||
t.Errorf("missing counts must block auto, reasons: %v", d.Reasons)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPreParse(t *testing.T) {
|
||||
pre := preParse("The.Matrix.1999.1080p.BluRay.x264")
|
||||
if pre.Year != 1999 {
|
||||
|
||||
Reference in New Issue
Block a user