mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-25 22:37:27 -04:00
New: User defined scores for each Custom Format
Brings it more into line with Sonarr preferred words
This commit is contained in:
+24
-9
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
@@ -32,8 +33,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
_format2.Id = 2;
|
||||
|
||||
var fakeSeries = Builder<Movie>.CreateNew()
|
||||
.With(c => c.Profile = new Profile { Cutoff = Quality.Bluray1080p.Id })
|
||||
.Build();
|
||||
.With(c => c.Profile = new Profile
|
||||
{
|
||||
Cutoff = Quality.Bluray1080p.Id,
|
||||
MinFormatScore = 1
|
||||
})
|
||||
.Build();
|
||||
|
||||
_remoteMovie = new RemoteMovie
|
||||
{
|
||||
@@ -41,32 +46,38 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
ParsedMovieInfo = new ParsedMovieInfo { Quality = new QualityModel(Quality.DVD, new Revision(version: 2)) },
|
||||
};
|
||||
|
||||
CustomFormatsFixture.GivenCustomFormats(CustomFormat.None, _format1, _format2);
|
||||
CustomFormatsFixture.GivenCustomFormats(_format1, _format2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_allow_if_format_is_defined_in_profile()
|
||||
public void should_allow_if_format_score_greater_than_min()
|
||||
{
|
||||
_remoteMovie.CustomFormats = new List<CustomFormat> { _format1 };
|
||||
_remoteMovie.Movie.Profile.FormatItems = CustomFormatsFixture.GetSampleFormatItems(_format1.Name);
|
||||
_remoteMovie.CustomFormatScore = _remoteMovie.Movie.Profile.CalculateCustomFormatScore(_remoteMovie.CustomFormats);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_deny_if_format_is_defined_in_profile()
|
||||
public void should_deny_if_format_score_not_greater_than_min()
|
||||
{
|
||||
_remoteMovie.CustomFormats = new List<CustomFormat> { _format2 };
|
||||
_remoteMovie.Movie.Profile.FormatItems = CustomFormatsFixture.GetSampleFormatItems(_format1.Name);
|
||||
_remoteMovie.CustomFormatScore = _remoteMovie.Movie.Profile.CalculateCustomFormatScore(_remoteMovie.CustomFormats);
|
||||
|
||||
Console.WriteLine(_remoteMovie.CustomFormatScore);
|
||||
Console.WriteLine(_remoteMovie.Movie.Profile.MinFormatScore);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_deny_if_one_format_is_defined_in_profile()
|
||||
public void should_deny_if_format_score_not_greater_than_min_2()
|
||||
{
|
||||
_remoteMovie.CustomFormats = new List<CustomFormat> { _format2, _format1 };
|
||||
_remoteMovie.Movie.Profile.FormatItems = CustomFormatsFixture.GetSampleFormatItems(_format1.Name);
|
||||
_remoteMovie.CustomFormatScore = _remoteMovie.Movie.Profile.CalculateCustomFormatScore(_remoteMovie.CustomFormats);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
@@ -76,24 +87,28 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
_remoteMovie.CustomFormats = new List<CustomFormat> { _format2, _format1 };
|
||||
_remoteMovie.Movie.Profile.FormatItems = CustomFormatsFixture.GetSampleFormatItems(_format1.Name, _format2.Name);
|
||||
_remoteMovie.CustomFormatScore = _remoteMovie.Movie.Profile.CalculateCustomFormatScore(_remoteMovie.CustomFormats);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_deny_if_no_format_was_parsed_and_none_not_in_profile()
|
||||
public void should_deny_if_no_format_was_parsed_and_min_score_positive()
|
||||
{
|
||||
_remoteMovie.CustomFormats = new List<CustomFormat> { };
|
||||
_remoteMovie.Movie.Profile.FormatItems = CustomFormatsFixture.GetSampleFormatItems(_format1.Name, _format2.Name);
|
||||
_remoteMovie.CustomFormatScore = _remoteMovie.Movie.Profile.CalculateCustomFormatScore(_remoteMovie.CustomFormats);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_allow_if_no_format_was_parsed_and_none_in_profile()
|
||||
public void should_allow_if_no_format_was_parsed_min_score_is_zero()
|
||||
{
|
||||
_remoteMovie.CustomFormats = new List<CustomFormat> { };
|
||||
_remoteMovie.Movie.Profile.FormatItems = CustomFormatsFixture.GetSampleFormatItems(CustomFormat.None.Name, _format1.Name, _format2.Name);
|
||||
_remoteMovie.Movie.Profile.FormatItems = CustomFormatsFixture.GetSampleFormatItems(_format1.Name, _format2.Name);
|
||||
_remoteMovie.Movie.Profile.MinFormatScore = 0;
|
||||
_remoteMovie.CustomFormatScore = _remoteMovie.Movie.Profile.CalculateCustomFormatScore(_remoteMovie.CustomFormats);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
@@ -40,9 +40,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
|
||||
private void GivenProfile(Profile profile)
|
||||
{
|
||||
CustomFormatsFixture.GivenCustomFormats(CustomFormat.None);
|
||||
profile.FormatItems = CustomFormatsFixture.GetSampleFormatItems("None");
|
||||
profile.FormatCutoff = CustomFormat.None.Id;
|
||||
CustomFormatsFixture.GivenCustomFormats();
|
||||
profile.FormatItems = CustomFormatsFixture.GetSampleFormatItems();
|
||||
profile.MinFormatScore = 0;
|
||||
_remoteMovie.Movie.Profile = profile;
|
||||
|
||||
Console.WriteLine(profile.ToJson());
|
||||
@@ -74,7 +74,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
_customFormat = new CustomFormat("My Format", new ResolutionSpecification { Value = (int)Resolution.R1080p }) { Id = 1 };
|
||||
|
||||
CustomFormatsFixture.GivenCustomFormats(_customFormat, CustomFormat.None);
|
||||
CustomFormatsFixture.GivenCustomFormats(_customFormat);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -126,8 +126,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
Cutoff = Quality.HDTV720p.Id,
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
FormatCutoff = CustomFormat.None.Id,
|
||||
FormatItems = CustomFormatsFixture.GetSampleFormatItems("None", "My Format")
|
||||
MinFormatScore = 0,
|
||||
FormatItems = CustomFormatsFixture.GetSampleFormatItems("My Format")
|
||||
});
|
||||
|
||||
GivenFileQuality(new QualityModel(Quality.HDTV720p));
|
||||
@@ -135,7 +135,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
|
||||
GivenCustomFormatHigher();
|
||||
|
||||
GivenOldCustomFormats(new List<CustomFormat> { CustomFormat.None });
|
||||
GivenOldCustomFormats(new List<CustomFormat>());
|
||||
GivenNewCustomFormats(new List<CustomFormat> { _customFormat });
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Mocker.Resolve<UpgradableSpecification>();
|
||||
_upgradeHistory = Mocker.Resolve<HistorySpecification>();
|
||||
|
||||
CustomFormatsFixture.GivenCustomFormats(CustomFormat.None);
|
||||
CustomFormatsFixture.GivenCustomFormats();
|
||||
|
||||
_fakeMovie = Builder<Movie>.CreateNew()
|
||||
.With(c => c.Profile = new Profile
|
||||
@@ -46,7 +46,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
Cutoff = Quality.Bluray1080p.Id,
|
||||
FormatItems = CustomFormatsFixture.GetSampleFormatItems("None"),
|
||||
FormatCutoff = CustomFormat.None.Id
|
||||
MinFormatScore = 0
|
||||
})
|
||||
.Build();
|
||||
|
||||
@@ -162,8 +162,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
Cutoff = Quality.Bluray1080p.Id,
|
||||
FormatItems = CustomFormatsFixture.GetSampleFormatItems("None"),
|
||||
FormatCutoff = CustomFormat.None.Id
|
||||
FormatItems = CustomFormatsFixture.GetSampleFormatItems(),
|
||||
MinFormatScore = 0
|
||||
};
|
||||
|
||||
_parseResultSingle.ParsedMovieInfo.Quality = new QualityModel(Quality.WEBDL1080p, new Revision(version: 1));
|
||||
@@ -185,8 +185,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
Cutoff = Quality.WEBDL1080p.Id,
|
||||
FormatItems = CustomFormatsFixture.GetSampleFormatItems("None"),
|
||||
FormatCutoff = CustomFormat.None.Id
|
||||
FormatItems = CustomFormatsFixture.GetSampleFormatItems(),
|
||||
MinFormatScore = 0
|
||||
};
|
||||
|
||||
_parseResultSingle.ParsedMovieInfo.Quality = new QualityModel(Quality.WEBDL1080p, new Revision(version: 1));
|
||||
@@ -220,8 +220,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
Cutoff = Quality.WEBDL1080p.Id,
|
||||
FormatItems = CustomFormatsFixture.GetSampleFormatItems("None"),
|
||||
FormatCutoff = CustomFormat.None.Id
|
||||
FormatItems = CustomFormatsFixture.GetSampleFormatItems(),
|
||||
MinFormatScore = 0
|
||||
};
|
||||
|
||||
_parseResultSingle.ParsedMovieInfo.Quality = new QualityModel(Quality.Bluray1080p, new Revision(version: 1));
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
_customFormat1 = new CustomFormat("My Format 1", new LanguageSpecification { Value = (int)Language.English }) { Id = 1 };
|
||||
_customFormat2 = new CustomFormat("My Format 2", new LanguageSpecification { Value = (int)Language.French }) { Id = 2 };
|
||||
|
||||
CustomFormatsFixture.GivenCustomFormats(CustomFormat.None, _customFormat1, _customFormat2);
|
||||
CustomFormatsFixture.GivenCustomFormats(_customFormat1, _customFormat2);
|
||||
}
|
||||
|
||||
private RemoteMovie GivenRemoteMovie(QualityModel quality, int age = 0, long size = 0, DownloadProtocol downloadProtocol = DownloadProtocol.Usenet)
|
||||
@@ -51,7 +51,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
PreferredTags = new List<string> { "DTS-HD", "SPARKS" },
|
||||
FormatItems = CustomFormatsFixture.GetSampleFormatItems()
|
||||
FormatItems = CustomFormatsFixture.GetSampleFormatItems(_customFormat1.Name, _customFormat2.Name),
|
||||
MinFormatScore = 0
|
||||
})
|
||||
.With(m => m.Title = "A Movie").Build();
|
||||
|
||||
@@ -62,6 +63,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
remoteMovie.Release.Title = "A Movie 1998";
|
||||
|
||||
remoteMovie.CustomFormats = new List<CustomFormat>();
|
||||
remoteMovie.CustomFormatScore = 0;
|
||||
|
||||
return remoteMovie;
|
||||
}
|
||||
@@ -328,11 +330,11 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
var quality1 = new QualityModel(Quality.Bluray720p);
|
||||
var remoteMovie1 = GivenRemoteMovie(quality1);
|
||||
remoteMovie1.CustomFormats.Add(CustomFormat.None);
|
||||
|
||||
var quality2 = new QualityModel(Quality.Bluray720p);
|
||||
var remoteMovie2 = GivenRemoteMovie(quality2);
|
||||
remoteMovie2.CustomFormats.Add(_customFormat1);
|
||||
remoteMovie2.CustomFormatScore = remoteMovie2.Movie.Profile.CalculateCustomFormatScore(remoteMovie2.CustomFormats);
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteMovie1));
|
||||
@@ -348,10 +350,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
var quality1 = new QualityModel(Quality.Bluray720p);
|
||||
var remoteMovie1 = GivenRemoteMovie(quality1);
|
||||
remoteMovie1.CustomFormats.Add(_customFormat1);
|
||||
remoteMovie1.CustomFormatScore = remoteMovie1.Movie.Profile.CalculateCustomFormatScore(remoteMovie1.CustomFormats);
|
||||
|
||||
var quality2 = new QualityModel(Quality.Bluray720p);
|
||||
var remoteMovie2 = GivenRemoteMovie(quality2);
|
||||
remoteMovie2.CustomFormats.Add(_customFormat2);
|
||||
remoteMovie2.CustomFormatScore = remoteMovie2.Movie.Profile.CalculateCustomFormatScore(remoteMovie2.CustomFormats);
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteMovie1));
|
||||
@@ -367,10 +371,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
var quality1 = new QualityModel(Quality.Bluray720p);
|
||||
var remoteMovie1 = GivenRemoteMovie(quality1);
|
||||
remoteMovie1.CustomFormats.Add(_customFormat1);
|
||||
remoteMovie1.CustomFormatScore = remoteMovie1.Movie.Profile.CalculateCustomFormatScore(remoteMovie1.CustomFormats);
|
||||
|
||||
var quality2 = new QualityModel(Quality.Bluray720p);
|
||||
var remoteMovie2 = GivenRemoteMovie(quality2);
|
||||
remoteMovie2.CustomFormats.AddRange(new List<CustomFormat> { _customFormat1, _customFormat2 });
|
||||
remoteMovie2.CustomFormatScore = remoteMovie2.Movie.Profile.CalculateCustomFormatScore(remoteMovie2.CustomFormats);
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteMovie1));
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
CustomFormatsFixture.GivenCustomFormats(CustomFormat.None, _customFormat1, _customFormat2);
|
||||
CustomFormatsFixture.GivenCustomFormats(_customFormat1, _customFormat2);
|
||||
}
|
||||
|
||||
private void GivenAutoDownloadPropers(bool autoDownloadPropers)
|
||||
@@ -73,7 +73,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
var profile = new Profile
|
||||
{
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
FormatItems = CustomFormatsFixture.GetSampleFormatItems()
|
||||
FormatItems = CustomFormatsFixture.GetSampleFormatItems(_customFormat1.Name, _customFormat2.Name),
|
||||
MinFormatScore = 0
|
||||
};
|
||||
|
||||
Subject.IsUpgradable(profile,
|
||||
|
||||
@@ -29,14 +29,14 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
Mocker.Resolve<UpgradableSpecification>();
|
||||
|
||||
CustomFormatsFixture.GivenCustomFormats(CustomFormat.None);
|
||||
CustomFormatsFixture.GivenCustomFormats();
|
||||
|
||||
_movie = Builder<Movie>.CreateNew()
|
||||
.With(e => e.Profile = new Profile
|
||||
{
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
FormatItems = CustomFormatsFixture.GetSampleFormatItems("None"),
|
||||
FormatCutoff = CustomFormat.None.Id,
|
||||
FormatItems = CustomFormatsFixture.GetSampleFormatItems(),
|
||||
MinFormatScore = 0,
|
||||
UpgradeAllowed = true
|
||||
})
|
||||
.Build();
|
||||
@@ -48,7 +48,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
_remoteMovie = Builder<RemoteMovie>.CreateNew()
|
||||
.With(r => r.Movie = _movie)
|
||||
.With(r => r.ParsedMovieInfo = new ParsedMovieInfo { Quality = new QualityModel(Quality.DVD) })
|
||||
.With(x => x.CustomFormats = new List<CustomFormat> { CustomFormat.None })
|
||||
.With(x => x.CustomFormats = new List<CustomFormat>())
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<ICustomFormatCalculationService>()
|
||||
@@ -104,7 +104,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
Quality = new QualityModel(Quality.SDTV)
|
||||
})
|
||||
.With(x => x.CustomFormats = new List<CustomFormat> { CustomFormat.None })
|
||||
.With(x => x.CustomFormats = new List<CustomFormat>())
|
||||
.Build();
|
||||
|
||||
GivenQueue(new List<RemoteMovie> { remoteMovie });
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Mocker.Resolve<UpgradableSpecification>();
|
||||
_upgradeDisk = Mocker.Resolve<UpgradeDiskSpecification>();
|
||||
|
||||
CustomFormatsFixture.GivenCustomFormats(CustomFormat.None);
|
||||
CustomFormatsFixture.GivenCustomFormats();
|
||||
|
||||
_firstFile = new MovieFile { Quality = new QualityModel(Quality.Bluray1080p, new Revision(version: 2)), DateAdded = DateTime.Now };
|
||||
|
||||
@@ -39,8 +39,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
.With(c => c.Profile = new Profile
|
||||
{
|
||||
Cutoff = Quality.Bluray1080p.Id, Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
FormatItems = CustomFormatsFixture.GetSampleFormatItems("None"),
|
||||
FormatCutoff = CustomFormat.None.Id
|
||||
FormatItems = CustomFormatsFixture.GetSampleFormatItems(),
|
||||
MinFormatScore = 0
|
||||
})
|
||||
.With(e => e.MovieFile = _firstFile)
|
||||
.Build();
|
||||
|
||||
Reference in New Issue
Block a user