mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-22 22:14:44 -04:00
Fix: Quality range definitions in kbps (#157)
* Quality range uses kbits per second. Quality ranges updated for each format * Changed vorbis q10 weight * Fixed element name * Added migration to keep existing MB/min quality constraints valid * Fixed migration SQL * Slider step now 1 * Fix: using kbps for min size as well * Added tooltip for quality-size * Updated AcceptableSizeSpecification test * Small magic number fix
This commit is contained in:
@@ -16,6 +16,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
|
||||
public class AcceptableSizeSpecificationFixture : CoreTest<AcceptableSizeSpecification>
|
||||
{
|
||||
private const int HIGH_KBPS_BITRATE = 1600;
|
||||
private const int TWENTY_MINUTE_EP_MILLIS = 20 * 60 * 1000;
|
||||
private const int FORTY_FIVE_MINUTE_LP_MILLIS = 45 * 60 * 1000;
|
||||
private RemoteAlbum parseResultMultiSet;
|
||||
private RemoteAlbum parseResultMulti;
|
||||
private RemoteAlbum parseResultSingle;
|
||||
@@ -58,8 +61,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
.Returns<Quality>(v => Quality.DefaultQualityDefinitions.First(c => c.Quality == v));
|
||||
|
||||
qualityType = Builder<QualityDefinition>.CreateNew()
|
||||
.With(q => q.MinSize = 2)
|
||||
.With(q => q.MaxSize = 6)
|
||||
.With(q => q.MinSize = 150)
|
||||
.With(q => q.MaxSize = 210)
|
||||
.With(q => q.Quality = Quality.MP3_192)
|
||||
.Build();
|
||||
|
||||
@@ -81,12 +84,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
new Album(), new Album(), new Album(), new Album(), new Album { Id = 2 } });
|
||||
}
|
||||
|
||||
[TestCase(1800000, 50, false)]
|
||||
[TestCase(1800000, 150, true)]
|
||||
[TestCase(1800000, 300, false)]
|
||||
[TestCase(3600000, 100, false)]
|
||||
[TestCase(3600000, 300, true)]
|
||||
[TestCase(3600000, 600, false)]
|
||||
[TestCase(TWENTY_MINUTE_EP_MILLIS, 20, false)]
|
||||
[TestCase(TWENTY_MINUTE_EP_MILLIS, 25, true)]
|
||||
[TestCase(TWENTY_MINUTE_EP_MILLIS, 35, false)]
|
||||
[TestCase(FORTY_FIVE_MINUTE_LP_MILLIS, 45, false)]
|
||||
[TestCase(FORTY_FIVE_MINUTE_LP_MILLIS, 55, true)]
|
||||
[TestCase(FORTY_FIVE_MINUTE_LP_MILLIS, 75, false)]
|
||||
public void single_album(int runtime, int sizeInMegaBytes, bool expectedResult)
|
||||
{
|
||||
parseResultSingle.Albums.Select(c => { c.Duration = runtime; return c; }).ToList();
|
||||
@@ -96,12 +99,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().Be(expectedResult);
|
||||
}
|
||||
|
||||
[TestCase(1800000, 50 * 2, false)]
|
||||
[TestCase(1800000, 150 * 2, true)]
|
||||
[TestCase(1800000, 300 * 2, false)]
|
||||
[TestCase(3600000, 100 * 2, false)]
|
||||
[TestCase(3600000, 300 * 2, true)]
|
||||
[TestCase(3600000, 600 * 2, false)]
|
||||
[TestCase(TWENTY_MINUTE_EP_MILLIS, 20 * 2, false)]
|
||||
[TestCase(TWENTY_MINUTE_EP_MILLIS, 25 * 2, true)]
|
||||
[TestCase(TWENTY_MINUTE_EP_MILLIS, 35 * 2, false)]
|
||||
[TestCase(FORTY_FIVE_MINUTE_LP_MILLIS, 45 * 2, false)]
|
||||
[TestCase(FORTY_FIVE_MINUTE_LP_MILLIS, 55 * 2, true)]
|
||||
[TestCase(FORTY_FIVE_MINUTE_LP_MILLIS, 75 * 2, false)]
|
||||
public void multi_album(int runtime, int sizeInMegaBytes, bool expectedResult)
|
||||
{
|
||||
parseResultMulti.Albums.Select(c => { c.Duration = runtime; return c; }).ToList();
|
||||
@@ -111,12 +114,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Subject.IsSatisfiedBy(parseResultMulti, null).Accepted.Should().Be(expectedResult);
|
||||
}
|
||||
|
||||
[TestCase(1800000, 50 * 6, false)]
|
||||
[TestCase(1800000, 150 * 6, true)]
|
||||
[TestCase(1800000, 300 * 6, false)]
|
||||
[TestCase(3600000, 100 * 6, false)]
|
||||
[TestCase(3600000, 300 * 6, true)]
|
||||
[TestCase(3600000, 600 * 6, false)]
|
||||
[TestCase(TWENTY_MINUTE_EP_MILLIS, 20 * 6, false)]
|
||||
[TestCase(TWENTY_MINUTE_EP_MILLIS, 25 * 6, true)]
|
||||
[TestCase(TWENTY_MINUTE_EP_MILLIS, 35 * 6, false)]
|
||||
[TestCase(FORTY_FIVE_MINUTE_LP_MILLIS, 45 * 6, false)]
|
||||
[TestCase(FORTY_FIVE_MINUTE_LP_MILLIS, 55 * 6, true)]
|
||||
[TestCase(FORTY_FIVE_MINUTE_LP_MILLIS, 75 * 6, false)]
|
||||
public void multiset_album(int runtime, int sizeInMegaBytes, bool expectedResult)
|
||||
{
|
||||
parseResultMultiSet.Albums.Select(c => { c.Duration = runtime; return c; }).ToList();
|
||||
@@ -130,34 +133,34 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
public void should_return_true_if_size_is_zero()
|
||||
{
|
||||
GivenLastAlbum();
|
||||
parseResultSingle.Albums.Select(c => { c.Duration = 1800000; return c; }).ToList();
|
||||
parseResultSingle.Albums.Select(c => { c.Duration = TWENTY_MINUTE_EP_MILLIS; return c; }).ToList();
|
||||
parseResultSingle.Artist = artist;
|
||||
parseResultSingle.Release.Size = 0;
|
||||
qualityType.MinSize = 10;
|
||||
qualityType.MaxSize = 20;
|
||||
qualityType.MinSize = 150;
|
||||
qualityType.MaxSize = 210;
|
||||
|
||||
Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_unlimited_30_minute()
|
||||
public void should_return_true_if_unlimited_20_minute()
|
||||
{
|
||||
GivenLastAlbum();
|
||||
parseResultSingle.Albums.Select(c => { c.Duration = 1800000; return c; }).ToList();
|
||||
parseResultSingle.Albums.Select(c => { c.Duration = TWENTY_MINUTE_EP_MILLIS; return c; }).ToList();
|
||||
parseResultSingle.Artist = artist;
|
||||
parseResultSingle.Release.Size = 18457280000;
|
||||
parseResultSingle.Release.Size = (HIGH_KBPS_BITRATE * 128) * (TWENTY_MINUTE_EP_MILLIS / 1000);
|
||||
qualityType.MaxSize = null;
|
||||
|
||||
Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_unlimited_60_minute()
|
||||
public void should_return_true_if_unlimited_45_minute()
|
||||
{
|
||||
GivenLastAlbum();
|
||||
parseResultSingle.Albums.Select(c => { c.Duration = 3600000; return c; }).ToList();
|
||||
parseResultSingle.Albums.Select(c => { c.Duration = FORTY_FIVE_MINUTE_LP_MILLIS; return c; }).ToList();
|
||||
parseResultSingle.Artist = artist;
|
||||
parseResultSingle.Release.Size = 36857280000;
|
||||
parseResultSingle.Release.Size = (HIGH_KBPS_BITRATE * 128) * (FORTY_FIVE_MINUTE_LP_MILLIS / 1000);
|
||||
qualityType.MaxSize = null;
|
||||
|
||||
Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().BeTrue();
|
||||
|
||||
Reference in New Issue
Block a user