Fixed: Correctly handle Repack Releases

This commit is contained in:
Qstick
2019-05-04 23:50:00 -04:00
parent 23316329ed
commit 2f1290d488
22 changed files with 673 additions and 72 deletions
@@ -38,17 +38,17 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
private static readonly int NoPreferredWordScore = 0;
private void GivenAutoDownloadPropers(bool autoDownloadPropers)
private void GivenAutoDownloadPropers(ProperDownloadTypes type)
{
Mocker.GetMock<IConfigService>()
.SetupGet(s => s.AutoDownloadPropers)
.Returns(autoDownloadPropers);
.SetupGet(s => s.DownloadPropersAndRepacks)
.Returns(type);
}
[Test, TestCaseSource(nameof(IsUpgradeTestCases))]
public void IsUpgradeTest(Quality current, int currentVersion, Quality newQuality, int newVersion, Quality cutoff, bool expected)
{
GivenAutoDownloadPropers(true);
GivenAutoDownloadPropers(ProperDownloadTypes.PreferAndUpgrade);
var profile = new QualityProfile
{
@@ -78,7 +78,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
[Test, TestCaseSource(nameof(IsUpgradeTestCasesLanguages))]
public void IsUpgradeTestLanguage(Quality current, int currentVersion, Language currentLanguage, Quality newQuality, int newVersion, Language newLanguage, Quality cutoff, Language languageCutoff, bool expected)
{
GivenAutoDownloadPropers(true);
GivenAutoDownloadPropers(ProperDownloadTypes.PreferAndUpgrade);
var profile = new QualityProfile
{
@@ -107,9 +107,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
}
[Test]
public void should_return_false_if_proper_and_autoDownloadPropers_is_false()
public void should_return_true_if_proper_and_download_propers_is_do_not_download()
{
GivenAutoDownloadPropers(false);
GivenAutoDownloadPropers(ProperDownloadTypes.DoNotUpgrade);
var profile = new QualityProfile
{
@@ -126,13 +126,41 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
Subject.IsUpgradable(
profile,
langProfile,
new List<QualityModel> { new QualityModel(Quality.MP3_256, new Revision(version: 2)) },
new List<QualityModel> { new QualityModel(Quality.MP3_256, new Revision(version: 1)) },
new List<Language> { Language.English },
NoPreferredWordScore,
new QualityModel(Quality.MP3_256, new Revision(version: 1)),
new QualityModel(Quality.MP3_256, new Revision(version: 2)),
Language.English,
NoPreferredWordScore)
.Should().BeFalse();
.Should().BeTrue();
}
[Test]
public void should_return_false_if_proper_and_autoDownloadPropers_is_do_not_prefer()
{
GivenAutoDownloadPropers(ProperDownloadTypes.DoNotPrefer);
var profile = new QualityProfile
{
Items = Qualities.QualityFixture.GetDefaultQualities(),
};
var langProfile = new LanguageProfile
{
Languages = LanguageFixture.GetDefaultLanguages(),
Cutoff = Language.English
};
Subject.IsUpgradable(
profile,
langProfile,
new List<QualityModel> { new QualityModel(Quality.MP3_256, new Revision(version: 1)) },
new List<Language> { Language.English },
NoPreferredWordScore,
new QualityModel(Quality.MP3_256, new Revision(version: 2)),
Language.English,
NoPreferredWordScore)
.Should().BeFalse();
}
}
}