mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-26 22:46:37 -04:00
Profiles
Indexes are created with the same uniqueness when copying a table New: Non-English episode support New: Renamed Quality Profiles to Profiles and made them more powerful New: Configurable wait time before grabbing a release to wait for a better quality
This commit is contained in:
+13
-13
@@ -4,19 +4,19 @@ using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
|
||||
namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class DownloadApprovedFixture : CoreTest<DownloadApprovedReports>
|
||||
public class DownloadApprovedFixture : CoreTest<ProcessDownloadDecisions>
|
||||
{
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
@@ -47,7 +47,7 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests
|
||||
remoteEpisode.Release.PublishDate = DateTime.UtcNow;
|
||||
|
||||
remoteEpisode.Series = Builder<Series>.CreateNew()
|
||||
.With(e => e.QualityProfile = new QualityProfile { Items = Qualities.QualityFixture.GetDefaultQualities() })
|
||||
.With(e => e.Profile = new Profile { Items = Qualities.QualityFixture.GetDefaultQualities() })
|
||||
.Build();
|
||||
|
||||
return remoteEpisode;
|
||||
@@ -62,7 +62,7 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteEpisode));
|
||||
|
||||
Subject.DownloadApproved(decisions);
|
||||
Subject.ProcessDecisions(decisions);
|
||||
Mocker.GetMock<IDownloadService>().Verify(v => v.DownloadReport(It.IsAny<RemoteEpisode>()), Times.Once());
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests
|
||||
decisions.Add(new DownloadDecision(remoteEpisode));
|
||||
decisions.Add(new DownloadDecision(remoteEpisode));
|
||||
|
||||
Subject.DownloadApproved(decisions);
|
||||
Subject.ProcessDecisions(decisions);
|
||||
Mocker.GetMock<IDownloadService>().Verify(v => v.DownloadReport(It.IsAny<RemoteEpisode>()), Times.Once());
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests
|
||||
decisions.Add(new DownloadDecision(remoteEpisode1));
|
||||
decisions.Add(new DownloadDecision(remoteEpisode2));
|
||||
|
||||
Subject.DownloadApproved(decisions);
|
||||
Subject.ProcessDecisions(decisions);
|
||||
Mocker.GetMock<IDownloadService>().Verify(v => v.DownloadReport(It.IsAny<RemoteEpisode>()), Times.Once());
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteEpisode));
|
||||
|
||||
Subject.DownloadApproved(decisions).Should().HaveCount(1);
|
||||
Subject.ProcessDecisions(decisions).Grabbed.Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -130,7 +130,7 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests
|
||||
decisions.Add(new DownloadDecision(remoteEpisode1));
|
||||
decisions.Add(new DownloadDecision(remoteEpisode2));
|
||||
|
||||
Subject.DownloadApproved(decisions).Should().HaveCount(2);
|
||||
Subject.ProcessDecisions(decisions).Grabbed.Should().HaveCount(2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -156,7 +156,7 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests
|
||||
decisions.Add(new DownloadDecision(remoteEpisode2));
|
||||
decisions.Add(new DownloadDecision(remoteEpisode3));
|
||||
|
||||
Subject.DownloadApproved(decisions).Should().HaveCount(2);
|
||||
Subject.ProcessDecisions(decisions).Grabbed.Should().HaveCount(2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -169,7 +169,7 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests
|
||||
decisions.Add(new DownloadDecision(remoteEpisode));
|
||||
|
||||
Mocker.GetMock<IDownloadService>().Setup(s => s.DownloadReport(It.IsAny<RemoteEpisode>())).Throws(new Exception());
|
||||
Subject.DownloadApproved(decisions).Should().BeEmpty();
|
||||
Subject.ProcessDecisions(decisions).Grabbed.Should().BeEmpty();
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
|
||||
@@ -177,8 +177,8 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests
|
||||
public void should_return_an_empty_list_when_none_are_appproved()
|
||||
{
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(null, "Failure!"));
|
||||
decisions.Add(new DownloadDecision(null, "Failure!"));
|
||||
decisions.Add(new DownloadDecision(null, new Rejection("Failure!")));
|
||||
decisions.Add(new DownloadDecision(null, new Rejection("Failure!")));
|
||||
|
||||
Subject.GetQualifiedReports(decisions).Should().BeEmpty();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Marr.Data;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.Download.Pending;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class ProcessFixture : CoreTest<PendingReleaseService>
|
||||
{
|
||||
private DownloadDecision _temporarilyRejected;
|
||||
private Series _series;
|
||||
private Episode _episode;
|
||||
private Profile _profile;
|
||||
private ReleaseInfo _release;
|
||||
private ParsedEpisodeInfo _parsedEpisodeInfo;
|
||||
private RemoteEpisode _remoteEpisode;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_series = Builder<Series>.CreateNew()
|
||||
.Build();
|
||||
|
||||
_episode = Builder<Episode>.CreateNew()
|
||||
.Build();
|
||||
|
||||
_profile = new Profile
|
||||
{
|
||||
Name = "Test",
|
||||
Cutoff = Quality.HDTV720p,
|
||||
GrabDelay = 1,
|
||||
Items = new List<ProfileQualityItem>
|
||||
{
|
||||
new ProfileQualityItem { Allowed = true, Quality = Quality.HDTV720p },
|
||||
new ProfileQualityItem { Allowed = true, Quality = Quality.WEBDL720p },
|
||||
new ProfileQualityItem { Allowed = true, Quality = Quality.Bluray720p }
|
||||
},
|
||||
};
|
||||
|
||||
_series.Profile = new LazyLoaded<Profile>(_profile);
|
||||
|
||||
_release = Builder<ReleaseInfo>.CreateNew().Build();
|
||||
|
||||
_parsedEpisodeInfo = Builder<ParsedEpisodeInfo>.CreateNew().Build();
|
||||
_parsedEpisodeInfo.Quality = new QualityModel(Quality.HDTV720p);
|
||||
|
||||
_remoteEpisode = new RemoteEpisode();
|
||||
_remoteEpisode.Episodes = new List<Episode>{ _episode };
|
||||
_remoteEpisode.Series = _series;
|
||||
_remoteEpisode.ParsedEpisodeInfo = _parsedEpisodeInfo;
|
||||
_remoteEpisode.Release = _release;
|
||||
|
||||
_temporarilyRejected = new DownloadDecision(_remoteEpisode, new Rejection("Temp Rejected", RejectionType.Temporary));
|
||||
|
||||
Mocker.GetMock<IPendingReleaseRepository>()
|
||||
.Setup(s => s.All())
|
||||
.Returns(new List<PendingRelease>());
|
||||
|
||||
Mocker.GetMock<ISeriesService>()
|
||||
.Setup(s => s.GetSeries(It.IsAny<Int32>()))
|
||||
.Returns(_series);
|
||||
|
||||
Mocker.GetMock<IParsingService>()
|
||||
.Setup(s => s.GetEpisodes(It.IsAny<ParsedEpisodeInfo>(), _series, true, null))
|
||||
.Returns(new List<Episode> {_episode});
|
||||
|
||||
Mocker.GetMock<IPrioritizeDownloadDecision>()
|
||||
.Setup(s => s.PrioritizeDecisions(It.IsAny<List<DownloadDecision>>()))
|
||||
.Returns((List<DownloadDecision> d) => d);
|
||||
}
|
||||
|
||||
private void GivenHeldRelease(String title, String indexer, DateTime publishDate)
|
||||
{
|
||||
var release = _release.JsonClone();
|
||||
release.Indexer = indexer;
|
||||
release.PublishDate = publishDate;
|
||||
|
||||
|
||||
var heldReleases = Builder<PendingRelease>.CreateListOfSize(1)
|
||||
.All()
|
||||
.With(h => h.SeriesId = _series.Id)
|
||||
.With(h => h.Title = title)
|
||||
.With(h => h.Release = release)
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<IPendingReleaseRepository>()
|
||||
.Setup(s => s.All())
|
||||
.Returns(heldReleases);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_add()
|
||||
{
|
||||
Subject.Add(_temporarilyRejected);
|
||||
|
||||
VerifyInsert();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_add_if_it_is_the_same_release_from_the_same_indexer()
|
||||
{
|
||||
GivenHeldRelease(_release.Title, _release.Indexer, _release.PublishDate);
|
||||
|
||||
Subject.Add(_temporarilyRejected);
|
||||
|
||||
VerifyNoInsert();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_add_if_title_is_different()
|
||||
{
|
||||
GivenHeldRelease(_release.Title + "-RP", _release.Indexer, _release.PublishDate);
|
||||
|
||||
Subject.Add(_temporarilyRejected);
|
||||
|
||||
VerifyInsert();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_add_if_indexer_is_different()
|
||||
{
|
||||
GivenHeldRelease(_release.Title, "AnotherIndexer", _release.PublishDate);
|
||||
|
||||
Subject.Add(_temporarilyRejected);
|
||||
|
||||
VerifyInsert();
|
||||
}
|
||||
[Test]
|
||||
public void should_add_if_publish_date_is_different()
|
||||
{
|
||||
GivenHeldRelease(_release.Title, _release.Indexer, _release.PublishDate.AddHours(1));
|
||||
|
||||
Subject.Add(_temporarilyRejected);
|
||||
|
||||
VerifyInsert();
|
||||
}
|
||||
|
||||
private void VerifyInsert()
|
||||
{
|
||||
Mocker.GetMock<IPendingReleaseRepository>()
|
||||
.Verify(v => v.Insert(It.IsAny<PendingRelease>()), Times.Once());
|
||||
}
|
||||
|
||||
private void VerifyNoInsert()
|
||||
{
|
||||
Mocker.GetMock<IPendingReleaseRepository>()
|
||||
.Verify(v => v.Insert(It.IsAny<PendingRelease>()), Times.Never());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user