You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
266 lines
7.5 KiB
266 lines
7.5 KiB
2 years ago
|
using Recyclarr.Cli.Pipelines.CustomFormat.Models;
|
||
|
using Recyclarr.Cli.Pipelines.QualityProfile.PipelinePhases;
|
||
1 year ago
|
using Recyclarr.Config.Models;
|
||
1 year ago
|
using Recyclarr.Tests.TestLibrary;
|
||
2 years ago
|
|
||
2 years ago
|
namespace Recyclarr.Cli.Tests.Pipelines.QualityProfile.PipelinePhases;
|
||
2 years ago
|
|
||
|
[TestFixture]
|
||
|
public class QualityProfileConfigPhaseTest
|
||
|
{
|
||
2 years ago
|
private static RadarrConfiguration SetupCfs(params CustomFormatConfig[] cfConfigs)
|
||
2 years ago
|
{
|
||
2 years ago
|
return NewConfig.Radarr() with
|
||
2 years ago
|
{
|
||
|
CustomFormats = cfConfigs
|
||
|
};
|
||
|
}
|
||
|
|
||
|
[Test, AutoMockData]
|
||
|
public void All_cfs_use_score_override(
|
||
|
[Frozen] ProcessedCustomFormatCache cache,
|
||
|
QualityProfileConfigPhase sut)
|
||
|
{
|
||
|
cache.AddCustomFormats(new[]
|
||
|
{
|
||
|
NewCf.DataWithScore("", "id1", 101, 1),
|
||
|
NewCf.DataWithScore("", "id2", 201, 2)
|
||
|
});
|
||
|
|
||
|
var config = SetupCfs(new CustomFormatConfig
|
||
|
{
|
||
|
TrashIds = new[] {"id1", "id2"},
|
||
|
QualityProfiles = new List<QualityProfileScoreConfig>
|
||
|
{
|
||
|
new()
|
||
|
{
|
||
|
Name = "test_profile",
|
||
|
Score = 100
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
|
||
|
var result = sut.Execute(config);
|
||
|
|
||
|
result.Should().BeEquivalentTo(new[]
|
||
2 years ago
|
{
|
||
|
NewQp.Processed("test_profile", ("id1", 1, 100), ("id2", 2, 100))
|
||
|
},
|
||
|
o => o.Excluding(x => x.ShouldCreate));
|
||
2 years ago
|
}
|
||
|
|
||
|
[Test, AutoMockData]
|
||
|
public void All_cfs_use_guide_scores_with_no_override(
|
||
|
[Frozen] ProcessedCustomFormatCache cache,
|
||
|
QualityProfileConfigPhase sut)
|
||
|
{
|
||
|
cache.AddCustomFormats(new[]
|
||
|
{
|
||
|
NewCf.DataWithScore("", "id1", 100, 1),
|
||
|
NewCf.DataWithScore("", "id2", 200, 2)
|
||
|
});
|
||
|
|
||
|
var config = SetupCfs(new CustomFormatConfig
|
||
|
{
|
||
|
TrashIds = new[] {"id1", "id2"},
|
||
|
QualityProfiles = new List<QualityProfileScoreConfig>
|
||
|
{
|
||
|
new()
|
||
|
{
|
||
|
Name = "test_profile"
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
|
||
|
var result = sut.Execute(config);
|
||
|
|
||
|
result.Should().BeEquivalentTo(new[]
|
||
2 years ago
|
{
|
||
|
NewQp.Processed("test_profile", ("id1", 1, 100), ("id2", 2, 200))
|
||
|
},
|
||
|
o => o.Excluding(x => x.ShouldCreate));
|
||
2 years ago
|
}
|
||
|
|
||
|
[Test, AutoMockData]
|
||
|
public void No_cfs_returned_when_no_score_in_guide_or_config(
|
||
|
[Frozen] ProcessedCustomFormatCache cache,
|
||
|
QualityProfileConfigPhase sut)
|
||
|
{
|
||
|
cache.AddCustomFormats(new[]
|
||
|
{
|
||
|
NewCf.Data("", "id1", 1),
|
||
|
NewCf.Data("", "id2", 2)
|
||
|
});
|
||
|
|
||
|
var config = SetupCfs(new CustomFormatConfig
|
||
|
{
|
||
|
TrashIds = new[] {"id1", "id2"},
|
||
|
QualityProfiles = new List<QualityProfileScoreConfig>
|
||
|
{
|
||
|
new()
|
||
|
{
|
||
|
Name = "test_profile"
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
|
||
|
var result = sut.Execute(config);
|
||
|
|
||
2 years ago
|
result.Should().BeEquivalentTo(new[]
|
||
|
{
|
||
|
NewQp.Processed("test_profile")
|
||
|
},
|
||
1 year ago
|
o => o.Excluding(x => x.ShouldCreate).Excluding(x => x.ScorelessCfs));
|
||
2 years ago
|
}
|
||
|
|
||
|
[Test, AutoMockData]
|
||
|
public void Skip_duplicate_cfs_with_same_and_different_scores(
|
||
|
[Frozen] ProcessedCustomFormatCache cache,
|
||
|
QualityProfileConfigPhase sut)
|
||
|
{
|
||
|
cache.AddCustomFormats(new[]
|
||
|
{
|
||
|
NewCf.DataWithScore("", "id1", 100, 1)
|
||
|
});
|
||
|
|
||
|
var config = SetupCfs(
|
||
|
new CustomFormatConfig
|
||
|
{
|
||
|
TrashIds = new[] {"id1"}
|
||
|
},
|
||
|
new CustomFormatConfig
|
||
|
{
|
||
|
TrashIds = new[] {"id1"},
|
||
|
QualityProfiles = new List<QualityProfileScoreConfig>
|
||
|
{
|
||
|
new() {Name = "test_profile1", Score = 100}
|
||
|
}
|
||
|
},
|
||
|
new CustomFormatConfig
|
||
|
{
|
||
|
TrashIds = new[] {"id1"},
|
||
|
QualityProfiles = new List<QualityProfileScoreConfig>
|
||
|
{
|
||
|
new() {Name = "test_profile1", Score = 200}
|
||
|
}
|
||
|
},
|
||
|
new CustomFormatConfig
|
||
|
{
|
||
|
TrashIds = new[] {"id1"},
|
||
|
QualityProfiles = new List<QualityProfileScoreConfig>
|
||
|
{
|
||
|
new() {Name = "test_profile2", Score = 200}
|
||
|
}
|
||
|
},
|
||
|
new CustomFormatConfig
|
||
|
{
|
||
|
TrashIds = new[] {"id1"},
|
||
|
QualityProfiles = new List<QualityProfileScoreConfig>
|
||
|
{
|
||
|
new() {Name = "test_profile2", Score = 100}
|
||
|
}
|
||
|
}
|
||
|
);
|
||
|
|
||
|
var result = sut.Execute(config);
|
||
|
|
||
|
result.Should().BeEquivalentTo(new[]
|
||
2 years ago
|
{
|
||
|
NewQp.Processed("test_profile1", ("id1", 1, 100)),
|
||
|
NewQp.Processed("test_profile2", ("id1", 1, 200))
|
||
|
},
|
||
|
o => o.Excluding(x => x.ShouldCreate));
|
||
2 years ago
|
}
|
||
1 year ago
|
|
||
|
[Test, AutoMockData]
|
||
|
public void All_cfs_use_score_set(
|
||
|
[Frozen] ProcessedCustomFormatCache cache,
|
||
|
QualityProfileConfigPhase sut)
|
||
|
{
|
||
|
cache.AddCustomFormats(new[]
|
||
|
{
|
||
|
NewCf.DataWithScores("", "id1", 1, ("default", 101), ("set1", 102)),
|
||
|
NewCf.DataWithScores("", "id2", 2, ("default", 201), ("set2", 202))
|
||
|
});
|
||
|
|
||
|
var config = NewConfig.Radarr() with
|
||
|
{
|
||
|
CustomFormats = new[]
|
||
|
{
|
||
|
new CustomFormatConfig
|
||
|
{
|
||
|
TrashIds = new[] {"id1", "id2"},
|
||
|
QualityProfiles = new[]
|
||
|
{
|
||
|
new QualityProfileScoreConfig {Name = "test_profile"}
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
QualityProfiles = new[]
|
||
|
{
|
||
|
new QualityProfileConfig
|
||
|
{
|
||
|
Name = "test_profile",
|
||
|
ScoreSet = "set1"
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
|
||
|
var result = sut.Execute(config);
|
||
|
|
||
|
result.Should().BeEquivalentTo(new[]
|
||
|
{
|
||
|
NewQp.Processed("test_profile", ("id1", 1, 102), ("id2", 2, 201)) with
|
||
|
{
|
||
|
Profile = config.QualityProfiles.First()
|
||
|
}
|
||
|
},
|
||
|
o => o.Excluding(x => x.ShouldCreate));
|
||
|
}
|
||
1 year ago
|
|
||
|
[Test, AutoMockData]
|
||
|
public void Empty_trash_ids_list_is_ignored(
|
||
|
[Frozen] ProcessedCustomFormatCache cache,
|
||
|
QualityProfileConfigPhase sut)
|
||
|
{
|
||
|
var config = SetupCfs(new CustomFormatConfig
|
||
|
{
|
||
|
TrashIds = Array.Empty<string>(),
|
||
|
QualityProfiles = new List<QualityProfileScoreConfig>
|
||
|
{
|
||
|
new()
|
||
|
{
|
||
|
Name = "test_profile",
|
||
|
Score = 100
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
|
||
|
var result = sut.Execute(config);
|
||
|
|
||
|
result.Should().BeEmpty();
|
||
|
}
|
||
|
|
||
|
[Test, AutoMockData]
|
||
|
public void Empty_quality_profiles_is_ignored(
|
||
|
[Frozen] ProcessedCustomFormatCache cache,
|
||
|
QualityProfileConfigPhase sut)
|
||
|
{
|
||
|
cache.AddCustomFormats(new[]
|
||
|
{
|
||
|
NewCf.DataWithScore("", "id1", 101, 1),
|
||
|
NewCf.DataWithScore("", "id2", 201, 2)
|
||
|
});
|
||
|
|
||
|
var config = SetupCfs(new CustomFormatConfig
|
||
|
{
|
||
|
TrashIds = new[] {"id1", "id2"},
|
||
|
QualityProfiles = Array.Empty<QualityProfileScoreConfig>()
|
||
|
});
|
||
|
|
||
|
var result = sut.Execute(config);
|
||
|
|
||
|
result.Should().BeEmpty();
|
||
|
}
|
||
2 years ago
|
}
|