1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-04-21 22:05:38 -04:00

New: Minimum Upgrade Score for Custom Formats

Closes #6800
This commit is contained in:
somniumV
2024-09-15 19:20:03 +02:00
committed by GitHub
parent 24f03fc1e9
commit 8b20a9449c
14 changed files with 164 additions and 11 deletions
@@ -5,6 +5,7 @@ using NzbDrone.Core.Configuration;
using NzbDrone.Core.CustomFormats;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Profiles;
using NzbDrone.Core.Profiles.Qualities;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Test.Framework;
@@ -79,9 +80,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
GivenAutoDownloadPropers(ProperDownloadTypes.DoNotPrefer);
var profile = new QualityProfile
{
Items = Qualities.QualityFixture.GetDefaultQualities(),
};
{
Items = Qualities.QualityFixture.GetDefaultQualities(),
};
Subject.IsUpgradable(
profile,
@@ -96,9 +97,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
public void should_return_false_if_release_and_existing_file_are_the_same()
{
var profile = new QualityProfile
{
Items = Qualities.QualityFixture.GetDefaultQualities()
};
{
Items = Qualities.QualityFixture.GetDefaultQualities()
};
Subject.IsUpgradable(
profile,
@@ -146,5 +147,95 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
new List<CustomFormat>())
.Should().Be(UpgradeableRejectReason.QualityCutoff);
}
[Test]
public void should_return_false_if_minimum_custom_score_is_not_met()
{
var customFormatOne = new CustomFormat
{
Id = 1,
Name = "One"
};
var customFormatTwo = new CustomFormat
{
Id = 2,
Name = "Two"
};
var profile = new QualityProfile
{
Items = Qualities.QualityFixture.GetDefaultQualities(),
UpgradeAllowed = true,
MinUpgradeFormatScore = 11,
CutoffFormatScore = 100,
FormatItems = new List<ProfileFormatItem>
{
new ProfileFormatItem
{
Format = customFormatOne,
Score = 10
},
new ProfileFormatItem
{
Format = customFormatTwo,
Score = 20
}
}
};
Subject.IsUpgradable(
profile,
new QualityModel(Quality.DVD),
new List<CustomFormat> { customFormatOne },
new QualityModel(Quality.DVD),
new List<CustomFormat> { customFormatTwo })
.Should().Be(UpgradeableRejectReason.MinCustomFormatScore);
}
[Test]
public void should_return_true_if_minimum_custom_score_is_met()
{
var customFormatOne = new CustomFormat
{
Id = 1,
Name = "One"
};
var customFormatTwo = new CustomFormat
{
Id = 2,
Name = "Two"
};
var profile = new QualityProfile
{
Items = Qualities.QualityFixture.GetDefaultQualities(),
UpgradeAllowed = true,
MinUpgradeFormatScore = 10,
CutoffFormatScore = 100,
FormatItems = new List<ProfileFormatItem>
{
new ProfileFormatItem
{
Format = customFormatOne,
Score = 10
},
new ProfileFormatItem
{
Format = customFormatTwo,
Score = 20
}
}
};
Subject.IsUpgradable(
profile,
new QualityModel(Quality.DVD),
new List<CustomFormat> { customFormatOne },
new QualityModel(Quality.DVD),
new List<CustomFormat> { customFormatTwo })
.Should().Be(UpgradeableRejectReason.None);
}
}
}