mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-29 21:39:34 +02:00
BestQualityInHistory fixed
#ND-138 fixed #ND-138 comment "No issue with Disk upgrade check, just history." Fixed: An issue with some qualities being treated as lower than expected when checking history
This commit is contained in:
@@ -158,41 +158,29 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||
var episodes = Builder<Episode>.CreateListOfSize(10).Build();
|
||||
var historyEpisode = episodes[6];
|
||||
|
||||
var history0 = Builder<History>.CreateNew()
|
||||
.With(h => h.Quality = QualityTypes.DVD)
|
||||
.With(h => h.IsProper = true)
|
||||
.With(h => h.EpisodeId = historyEpisode.EpisodeId)
|
||||
.Build();
|
||||
var history = Builder<History>
|
||||
.CreateListOfSize(5)
|
||||
.All()
|
||||
.With(h => h.EpisodeId = historyEpisode.EpisodeId)
|
||||
.With(h => h.SeriesId = historyEpisode.SeriesId)
|
||||
.TheFirst(1)
|
||||
.With(h => h.Quality = QualityTypes.DVD)
|
||||
.With(h => h.IsProper = true)
|
||||
.TheNext(1)
|
||||
.With(h => h.Quality = QualityTypes.Bluray720p)
|
||||
.With(h => h.IsProper = false)
|
||||
.TheNext(1)
|
||||
.With(h => h.Quality = QualityTypes.Bluray720p)
|
||||
.With(h => h.IsProper = true)
|
||||
.TheNext(1)
|
||||
.With(h => h.Quality = QualityTypes.Bluray720p)
|
||||
.With(h => h.IsProper = false)
|
||||
.TheNext(1)
|
||||
.With(h => h.Quality = QualityTypes.SDTV)
|
||||
.With(h => h.IsProper = true)
|
||||
.Build();
|
||||
|
||||
var history1 = Builder<History>.CreateNew()
|
||||
.With(h => h.Quality = QualityTypes.Bluray720p)
|
||||
.With(h => h.IsProper = false)
|
||||
.With(h => h.EpisodeId = historyEpisode.EpisodeId)
|
||||
.Build();
|
||||
|
||||
var history2 = Builder<History>.CreateNew()
|
||||
.With(h => h.Quality = QualityTypes.Bluray720p)
|
||||
.With(h => h.IsProper = true)
|
||||
.With(h => h.EpisodeId = historyEpisode.EpisodeId)
|
||||
.Build();
|
||||
|
||||
var history3 = Builder<History>.CreateNew()
|
||||
.With(h => h.Quality = QualityTypes.Bluray720p)
|
||||
.With(h => h.IsProper = false)
|
||||
.With(h => h.EpisodeId = historyEpisode.EpisodeId)
|
||||
.Build();
|
||||
|
||||
var history4 = Builder<History>.CreateNew()
|
||||
.With(h => h.Quality = QualityTypes.SDTV)
|
||||
.With(h => h.IsProper = true)
|
||||
.With(h => h.EpisodeId = historyEpisode.EpisodeId)
|
||||
.Build();
|
||||
|
||||
Db.Insert(history0);
|
||||
Db.Insert(history1);
|
||||
Db.Insert(history2);
|
||||
Db.Insert(history2);
|
||||
Db.Insert(history4);
|
||||
Db.InsertMany(history);
|
||||
Db.InsertMany(episodes);
|
||||
|
||||
//Act
|
||||
@@ -205,6 +193,49 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||
result.Proper.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetBestQualityInHistory_should_return_highest_weighted_result()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var episodes = Builder<Episode>.CreateListOfSize(10).Build();
|
||||
var historyEpisode = episodes[6];
|
||||
|
||||
var history = Builder<History>
|
||||
.CreateListOfSize(5)
|
||||
.All()
|
||||
.With(h => h.EpisodeId = historyEpisode.EpisodeId)
|
||||
.With(h => h.SeriesId = historyEpisode.SeriesId)
|
||||
.TheFirst(1)
|
||||
.With(h => h.Quality = QualityTypes.DVD)
|
||||
.With(h => h.IsProper = true)
|
||||
.TheNext(1)
|
||||
.With(h => h.Quality = QualityTypes.WEBDL720p)
|
||||
.With(h => h.IsProper = false)
|
||||
.TheNext(1)
|
||||
.With(h => h.Quality = QualityTypes.WEBDL720p)
|
||||
.With(h => h.IsProper = true)
|
||||
.TheNext(1)
|
||||
.With(h => h.Quality = QualityTypes.WEBDL1080p)
|
||||
.With(h => h.IsProper = false)
|
||||
.TheNext(1)
|
||||
.With(h => h.Quality = QualityTypes.SDTV)
|
||||
.With(h => h.IsProper = true)
|
||||
.Build();
|
||||
|
||||
Db.InsertMany(history);
|
||||
Db.InsertMany(episodes);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<HistoryProvider>()
|
||||
.GetBestQualityInHistory(historyEpisode.SeriesId, historyEpisode.SeasonNumber, historyEpisode.EpisodeNumber);
|
||||
|
||||
//Assert
|
||||
result.Should().NotBeNull();
|
||||
result.Quality.Should().Be(QualityTypes.WEBDL1080p);
|
||||
result.Proper.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void add_item()
|
||||
{
|
||||
|
Reference in New Issue
Block a user