Searching will be more picky now to ensure the proper series and season (and episode if relevant)
This commit is contained in:
parent
067d735448
commit
30e21ecd16
|
@ -26,9 +26,18 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
public void processResults_ParseResult_should_return_after_match()
|
public void processResults_ParseResult_should_return_after_match()
|
||||||
{
|
{
|
||||||
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(5)
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(5)
|
||||||
|
.TheFirst(1)
|
||||||
|
.With(e => e.SeasonNumber = 1)
|
||||||
|
.With(e => e.EpisodeNumbers = new List<int>{1})
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var episode = Builder<Episode>.CreateNew().Build();
|
var series = Builder<Series>.CreateNew().Build();
|
||||||
|
|
||||||
|
var episode = Builder<Episode>.CreateNew()
|
||||||
|
.With(e => e.SeriesId = series.SeriesId)
|
||||||
|
.With(e => e.SeasonNumber = 1)
|
||||||
|
.With(e => e.EpisodeNumber = 1)
|
||||||
|
.Build();
|
||||||
|
|
||||||
var mocker = new AutoMoqer(MockBehavior.Strict);
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||||
|
|
||||||
|
@ -39,6 +48,8 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
mocker.GetMock<DownloadProvider>()
|
mocker.GetMock<DownloadProvider>()
|
||||||
.Setup(c => c.DownloadReport(It.IsAny<EpisodeParseResult>())).Returns(true);
|
.Setup(c => c.DownloadReport(It.IsAny<EpisodeParseResult>())).Returns(true);
|
||||||
|
|
||||||
|
mocker.GetMock<SeriesProvider>()
|
||||||
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(series);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
mocker.Resolve<SearchProvider>().ProcessEpisodeSearchResults(new ProgressNotification("Test"), episode, parseResults);
|
mocker.Resolve<SearchProvider>().ProcessEpisodeSearchResults(new ProgressNotification("Test"), episode, parseResults);
|
||||||
|
@ -51,16 +62,24 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
Times.Once());
|
Times.Once());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void processResults_higher_quality_should_be_called_first()
|
public void processResults_higher_quality_should_be_called_first()
|
||||||
{
|
{
|
||||||
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(10)
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(10)
|
||||||
.All().With(c => c.Quality = new Quality(QualityTypes.DVD, true))
|
.All().With(c => c.Quality = new Quality(QualityTypes.DVD, true))
|
||||||
.Random(1).With(c => c.Quality = new Quality(QualityTypes.Bluray1080p, true))
|
.Random(1)
|
||||||
|
.With(c => c.Quality = new Quality(QualityTypes.Bluray1080p, true))
|
||||||
|
.With(e => e.SeasonNumber = 1)
|
||||||
|
.With(e => e.EpisodeNumbers = new List<int> { 1 })
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var episode = Builder<Episode>.CreateNew().Build();
|
var series = Builder<Series>.CreateNew().Build();
|
||||||
|
|
||||||
|
var episode = Builder<Episode>.CreateNew()
|
||||||
|
.With(e => e.SeriesId = series.SeriesId)
|
||||||
|
.With(e => e.SeasonNumber = 1)
|
||||||
|
.With(e => e.EpisodeNumber = 1)
|
||||||
|
.Build();
|
||||||
|
|
||||||
var mocker = new AutoMoqer(MockBehavior.Strict);
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||||
|
|
||||||
|
@ -76,6 +95,9 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
c.DownloadReport(It.Is<EpisodeParseResult>(d => d.Quality.QualityType == QualityTypes.Bluray1080p)))
|
c.DownloadReport(It.Is<EpisodeParseResult>(d => d.Quality.QualityType == QualityTypes.Bluray1080p)))
|
||||||
.Returns(true);
|
.Returns(true);
|
||||||
|
|
||||||
|
mocker.GetMock<SeriesProvider>()
|
||||||
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(series);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
mocker.Resolve<SearchProvider>().ProcessEpisodeSearchResults(new ProgressNotification("Test"), episode, parseResults);
|
mocker.Resolve<SearchProvider>().ProcessEpisodeSearchResults(new ProgressNotification("Test"), episode, parseResults);
|
||||||
|
|
||||||
|
@ -87,18 +109,26 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
Times.Once());
|
Times.Once());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void processResults_when_same_quality_proper_should_be_called_first()
|
public void processResults_when_same_quality_proper_should_be_called_first()
|
||||||
{
|
{
|
||||||
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(20)
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(20)
|
||||||
.All().With(c => c.Quality = new Quality(QualityTypes.DVD, false))
|
.All()
|
||||||
|
.With(c => c.Quality = new Quality(QualityTypes.DVD, false))
|
||||||
|
.With(e => e.SeasonNumber = 1)
|
||||||
|
.With(e => e.EpisodeNumbers = new List<int> { 1 })
|
||||||
.Random(1).With(c => c.Quality = new Quality(QualityTypes.DVD, true))
|
.Random(1).With(c => c.Quality = new Quality(QualityTypes.DVD, true))
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
parseResults.Where(c => c.Quality.Proper).Should().HaveCount(1);
|
parseResults.Where(c => c.Quality.Proper).Should().HaveCount(1);
|
||||||
|
|
||||||
var episode = Builder<Episode>.CreateNew().Build();
|
var series = Builder<Series>.CreateNew().Build();
|
||||||
|
|
||||||
|
var episode = Builder<Episode>.CreateNew()
|
||||||
|
.With(e => e.SeriesId = series.SeriesId)
|
||||||
|
.With(e => e.SeasonNumber = 1)
|
||||||
|
.With(e => e.EpisodeNumber = 1)
|
||||||
|
.Build();
|
||||||
|
|
||||||
var mocker = new AutoMoqer(MockBehavior.Strict);
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||||
|
|
||||||
|
@ -108,6 +138,8 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
mocker.GetMock<DownloadProvider>()
|
mocker.GetMock<DownloadProvider>()
|
||||||
.Setup(c => c.DownloadReport(It.Is<EpisodeParseResult>(p => p.Quality.Proper))).Returns(true);
|
.Setup(c => c.DownloadReport(It.Is<EpisodeParseResult>(p => p.Quality.Proper))).Returns(true);
|
||||||
|
|
||||||
|
mocker.GetMock<SeriesProvider>()
|
||||||
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(series);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
mocker.Resolve<SearchProvider>().ProcessEpisodeSearchResults(new ProgressNotification("Test"), episode, parseResults);
|
mocker.Resolve<SearchProvider>().ProcessEpisodeSearchResults(new ProgressNotification("Test"), episode, parseResults);
|
||||||
|
@ -120,20 +152,31 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
Times.Once());
|
Times.Once());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void processResults_when_not_needed_should_check_the_rest()
|
public void processResults_when_quality_is_not_needed_should_check_the_rest()
|
||||||
{
|
{
|
||||||
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(4)
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(4)
|
||||||
|
.All()
|
||||||
|
.With(e => e.SeasonNumber = 1)
|
||||||
|
.With(e => e.EpisodeNumbers = new List<int> { 1 })
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var episode = Builder<Episode>.CreateNew().Build();
|
var series = Builder<Series>.CreateNew().Build();
|
||||||
|
|
||||||
|
var episode = Builder<Episode>.CreateNew()
|
||||||
|
.With(e => e.SeriesId = series.SeriesId)
|
||||||
|
.With(e => e.SeasonNumber = 1)
|
||||||
|
.With(e => e.EpisodeNumber = 1)
|
||||||
|
.Build();
|
||||||
|
|
||||||
var mocker = new AutoMoqer(MockBehavior.Strict);
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||||
|
|
||||||
mocker.GetMock<InventoryProvider>()
|
mocker.GetMock<InventoryProvider>()
|
||||||
.Setup(c => c.IsQualityNeeded(It.IsAny<EpisodeParseResult>())).Returns(false);
|
.Setup(c => c.IsQualityNeeded(It.IsAny<EpisodeParseResult>())).Returns(false);
|
||||||
|
|
||||||
|
mocker.GetMock<SeriesProvider>()
|
||||||
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(series);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
mocker.Resolve<SearchProvider>().ProcessEpisodeSearchResults(new ProgressNotification("Test"), episode, parseResults);
|
mocker.Resolve<SearchProvider>().ProcessEpisodeSearchResults(new ProgressNotification("Test"), episode, parseResults);
|
||||||
|
|
||||||
|
@ -144,20 +187,31 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
ExceptionVerification.ExcpectedWarns(1);
|
ExceptionVerification.ExcpectedWarns(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void processResults_failed_IsNeeded_should_check_the_rest()
|
public void processResults_failed_IsNeeded_should_check_the_rest()
|
||||||
{
|
{
|
||||||
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(4)
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(4)
|
||||||
|
.All()
|
||||||
|
.With(e => e.SeasonNumber = 1)
|
||||||
|
.With(e => e.EpisodeNumbers = new List<int> { 1 })
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var episode = Builder<Episode>.CreateNew().Build();
|
var series = Builder<Series>.CreateNew().Build();
|
||||||
|
|
||||||
|
var episode = Builder<Episode>.CreateNew()
|
||||||
|
.With(e => e.SeriesId = series.SeriesId)
|
||||||
|
.With(e => e.SeasonNumber = 1)
|
||||||
|
.With(e => e.EpisodeNumber = 1)
|
||||||
|
.Build();
|
||||||
|
|
||||||
var mocker = new AutoMoqer(MockBehavior.Strict);
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||||
|
|
||||||
mocker.GetMock<InventoryProvider>()
|
mocker.GetMock<InventoryProvider>()
|
||||||
.Setup(c => c.IsQualityNeeded(It.IsAny<EpisodeParseResult>())).Throws(new Exception());
|
.Setup(c => c.IsQualityNeeded(It.IsAny<EpisodeParseResult>())).Throws(new Exception());
|
||||||
|
|
||||||
|
mocker.GetMock<SeriesProvider>()
|
||||||
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(series);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
mocker.Resolve<SearchProvider>().ProcessEpisodeSearchResults(new ProgressNotification("Test"), episode, parseResults);
|
mocker.Resolve<SearchProvider>().ProcessEpisodeSearchResults(new ProgressNotification("Test"), episode, parseResults);
|
||||||
|
|
||||||
|
@ -173,9 +227,18 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
public void processResults_failed_download_should_not_check_the_rest()
|
public void processResults_failed_download_should_not_check_the_rest()
|
||||||
{
|
{
|
||||||
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(4)
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(4)
|
||||||
|
.All()
|
||||||
|
.With(e => e.SeasonNumber = 1)
|
||||||
|
.With(e => e.EpisodeNumbers = new List<int> { 1 })
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var episode = Builder<Episode>.CreateNew().Build();
|
var series = Builder<Series>.CreateNew().Build();
|
||||||
|
|
||||||
|
var episode = Builder<Episode>.CreateNew()
|
||||||
|
.With(e => e.SeriesId = series.SeriesId)
|
||||||
|
.With(e => e.SeasonNumber = 1)
|
||||||
|
.With(e => e.EpisodeNumber = 1)
|
||||||
|
.Build();
|
||||||
|
|
||||||
var mocker = new AutoMoqer(MockBehavior.Strict);
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||||
|
|
||||||
|
@ -185,6 +248,9 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
mocker.GetMock<DownloadProvider>()
|
mocker.GetMock<DownloadProvider>()
|
||||||
.Setup(c => c.DownloadReport(It.IsAny<EpisodeParseResult>())).Throws(new Exception());
|
.Setup(c => c.DownloadReport(It.IsAny<EpisodeParseResult>())).Throws(new Exception());
|
||||||
|
|
||||||
|
mocker.GetMock<SeriesProvider>()
|
||||||
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(series);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
mocker.Resolve<SearchProvider>().ProcessEpisodeSearchResults(new ProgressNotification("Test"), episode, parseResults);
|
mocker.Resolve<SearchProvider>().ProcessEpisodeSearchResults(new ProgressNotification("Test"), episode, parseResults);
|
||||||
|
|
||||||
|
@ -205,8 +271,11 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(4)
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(4)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
var series = Builder<Series>.CreateNew()
|
||||||
|
.Build();
|
||||||
|
|
||||||
var episode = Builder<Episode>.CreateNew()
|
var episode = Builder<Episode>.CreateNew()
|
||||||
.With(c => c.Series = Builder<Series>.CreateNew().Build())
|
.With(c => c.Series = series)
|
||||||
.With(c => c.SeasonNumber = 12)
|
.With(c => c.SeasonNumber = 12)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
@ -216,6 +285,9 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
.Setup(c => c.GetEpisode(episode.EpisodeId))
|
.Setup(c => c.GetEpisode(episode.EpisodeId))
|
||||||
.Returns(episode);
|
.Returns(episode);
|
||||||
|
|
||||||
|
mocker.GetMock<SeriesProvider>()
|
||||||
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(series);
|
||||||
|
|
||||||
var indexer1 = new Mock<IndexerBase>();
|
var indexer1 = new Mock<IndexerBase>();
|
||||||
indexer1.Setup(c => c.FetchEpisode(episode.Series.Title, episode.SeasonNumber, episode.EpisodeNumber))
|
indexer1.Setup(c => c.FetchEpisode(episode.Series.Title, episode.SeasonNumber, episode.EpisodeNumber))
|
||||||
.Returns(parseResults).Verifiable();
|
.Returns(parseResults).Verifiable();
|
||||||
|
@ -234,9 +306,6 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
.Setup(c => c.GetSeries(It.IsAny<int>()))
|
.Setup(c => c.GetSeries(It.IsAny<int>()))
|
||||||
.Returns(episode.Series);
|
.Returns(episode.Series);
|
||||||
|
|
||||||
mocker.GetMock<InventoryProvider>()
|
|
||||||
.Setup(c => c.IsQualityNeeded(It.IsAny<EpisodeParseResult>())).Returns(false);
|
|
||||||
|
|
||||||
mocker.GetMock<SceneMappingProvider>()
|
mocker.GetMock<SceneMappingProvider>()
|
||||||
.Setup(s => s.GetSceneName(It.IsAny<int>())).Returns("");
|
.Setup(s => s.GetSceneName(It.IsAny<int>())).Returns("");
|
||||||
|
|
||||||
|
@ -246,8 +315,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
mocker.VerifyAllMocks();
|
mocker.VerifyAllMocks();
|
||||||
mocker.GetMock<InventoryProvider>().Verify(c => c.IsQualityNeeded(It.IsAny<EpisodeParseResult>()),
|
|
||||||
Times.Exactly(8));
|
|
||||||
ExceptionVerification.ExcpectedWarns(1);
|
ExceptionVerification.ExcpectedWarns(1);
|
||||||
indexer1.VerifyAll();
|
indexer1.VerifyAll();
|
||||||
indexer2.VerifyAll();
|
indexer2.VerifyAll();
|
||||||
|
@ -259,8 +327,11 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(4)
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(4)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
var series = Builder<Series>.CreateNew().With(s => s.SeriesId = 71256)
|
||||||
|
.Build();
|
||||||
|
|
||||||
var episode = Builder<Episode>.CreateNew()
|
var episode = Builder<Episode>.CreateNew()
|
||||||
.With(c => c.Series = Builder<Series>.CreateNew().With(s => s.SeriesId = 71256).Build())
|
.With(c => c.Series = series)
|
||||||
.With(c => c.SeasonNumber = 12)
|
.With(c => c.SeasonNumber = 12)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
@ -270,6 +341,9 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
.Setup(c => c.GetEpisode(episode.EpisodeId))
|
.Setup(c => c.GetEpisode(episode.EpisodeId))
|
||||||
.Returns(episode);
|
.Returns(episode);
|
||||||
|
|
||||||
|
mocker.GetMock<SeriesProvider>()
|
||||||
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(series);
|
||||||
|
|
||||||
var indexer1 = new Mock<IndexerBase>();
|
var indexer1 = new Mock<IndexerBase>();
|
||||||
indexer1.Setup(c => c.FetchEpisode("The Daily Show", episode.SeasonNumber, episode.EpisodeNumber))
|
indexer1.Setup(c => c.FetchEpisode("The Daily Show", episode.SeasonNumber, episode.EpisodeNumber))
|
||||||
.Returns(parseResults).Verifiable();
|
.Returns(parseResults).Verifiable();
|
||||||
|
@ -288,20 +362,14 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
.Setup(c => c.GetSeries(It.IsAny<int>()))
|
.Setup(c => c.GetSeries(It.IsAny<int>()))
|
||||||
.Returns(episode.Series);
|
.Returns(episode.Series);
|
||||||
|
|
||||||
mocker.GetMock<InventoryProvider>()
|
|
||||||
.Setup(c => c.IsQualityNeeded(It.IsAny<EpisodeParseResult>())).Returns(false);
|
|
||||||
|
|
||||||
mocker.GetMock<SceneMappingProvider>()
|
mocker.GetMock<SceneMappingProvider>()
|
||||||
.Setup(s => s.GetSceneName(71256)).Returns("The Daily Show");
|
.Setup(s => s.GetSceneName(71256)).Returns("The Daily Show");
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
mocker.Resolve<SearchProvider>().EpisodeSearch(new ProgressNotification("Test"), episode.EpisodeId);
|
mocker.Resolve<SearchProvider>().EpisodeSearch(new ProgressNotification("Test"), episode.EpisodeId);
|
||||||
|
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
mocker.VerifyAllMocks();
|
mocker.VerifyAllMocks();
|
||||||
mocker.GetMock<InventoryProvider>().Verify(c => c.IsQualityNeeded(It.IsAny<EpisodeParseResult>()),
|
|
||||||
Times.Exactly(8));
|
|
||||||
ExceptionVerification.ExcpectedWarns(1);
|
ExceptionVerification.ExcpectedWarns(1);
|
||||||
indexer1.VerifyAll();
|
indexer1.VerifyAll();
|
||||||
indexer2.VerifyAll();
|
indexer2.VerifyAll();
|
||||||
|
@ -348,9 +416,6 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
.Setup(c => c.GetSeries(It.IsAny<int>()))
|
.Setup(c => c.GetSeries(It.IsAny<int>()))
|
||||||
.Returns(episode.Series);
|
.Returns(episode.Series);
|
||||||
|
|
||||||
mocker.GetMock<InventoryProvider>()
|
|
||||||
.Setup(c => c.IsQualityNeeded(It.IsAny<EpisodeParseResult>())).Returns(false);
|
|
||||||
|
|
||||||
mocker.GetMock<SceneMappingProvider>()
|
mocker.GetMock<SceneMappingProvider>()
|
||||||
.Setup(s => s.GetSceneName(It.IsAny<int>())).Returns("");
|
.Setup(s => s.GetSceneName(It.IsAny<int>())).Returns("");
|
||||||
|
|
||||||
|
@ -360,8 +425,6 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
mocker.VerifyAllMocks();
|
mocker.VerifyAllMocks();
|
||||||
mocker.GetMock<InventoryProvider>().Verify(c => c.IsQualityNeeded(It.IsAny<EpisodeParseResult>()),
|
|
||||||
Times.Exactly(8));
|
|
||||||
|
|
||||||
ExceptionVerification.ExcpectedWarns(1);
|
ExceptionVerification.ExcpectedWarns(1);
|
||||||
ExceptionVerification.ExcpectedErrors(1);
|
ExceptionVerification.ExcpectedErrors(1);
|
||||||
|
@ -394,8 +457,10 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(4)
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(4)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
var series = Builder<Series>.CreateNew().Build();
|
||||||
|
|
||||||
var episode = Builder<Episode>.CreateNew()
|
var episode = Builder<Episode>.CreateNew()
|
||||||
.With(c => c.Series = Builder<Series>.CreateNew().Build())
|
.With(c => c.Series = series)
|
||||||
.With(c => c.SeasonNumber = 12)
|
.With(c => c.SeasonNumber = 12)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
@ -405,6 +470,9 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
.Setup(c => c.GetEpisode(episode.EpisodeId))
|
.Setup(c => c.GetEpisode(episode.EpisodeId))
|
||||||
.Returns(episode);
|
.Returns(episode);
|
||||||
|
|
||||||
|
mocker.GetMock<SeriesProvider>()
|
||||||
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(series);
|
||||||
|
|
||||||
var indexer1 = new Mock<IndexerBase>();
|
var indexer1 = new Mock<IndexerBase>();
|
||||||
indexer1.Setup(c => c.FetchEpisode(episode.Series.Title, episode.SeasonNumber, episode.EpisodeNumber))
|
indexer1.Setup(c => c.FetchEpisode(episode.Series.Title, episode.SeasonNumber, episode.EpisodeNumber))
|
||||||
.Returns(parseResults).Verifiable();
|
.Returns(parseResults).Verifiable();
|
||||||
|
@ -415,9 +483,6 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
.Setup(c => c.GetEnabledIndexers())
|
.Setup(c => c.GetEnabledIndexers())
|
||||||
.Returns(indexers);
|
.Returns(indexers);
|
||||||
|
|
||||||
mocker.GetMock<InventoryProvider>()
|
|
||||||
.Setup(c => c.IsQualityNeeded(It.IsAny<EpisodeParseResult>())).Returns(false);
|
|
||||||
|
|
||||||
mocker.GetMock<SceneMappingProvider>()
|
mocker.GetMock<SceneMappingProvider>()
|
||||||
.Setup(s => s.GetSceneName(It.IsAny<int>())).Returns("");
|
.Setup(s => s.GetSceneName(It.IsAny<int>())).Returns("");
|
||||||
|
|
||||||
|
@ -433,5 +498,134 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
ExceptionVerification.ExcpectedWarns(1);
|
ExceptionVerification.ExcpectedWarns(1);
|
||||||
indexer1.VerifyAll();
|
indexer1.VerifyAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void processResults_should_return_false_when_series_is_null()
|
||||||
|
{
|
||||||
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(1)
|
||||||
|
.All()
|
||||||
|
.With(e => e.SeasonNumber = 1)
|
||||||
|
.With(e => e.EpisodeNumbers = new List<int> { 1 })
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
Series series = null;
|
||||||
|
|
||||||
|
var episode = Builder<Episode>.CreateNew()
|
||||||
|
.With(e => e.SeasonNumber = 1)
|
||||||
|
.With(e => e.EpisodeNumber = 1)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||||
|
|
||||||
|
mocker.GetMock<SeriesProvider>()
|
||||||
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(series);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var result = mocker.Resolve<SearchProvider>().ProcessEpisodeSearchResults(new ProgressNotification("Test"), episode, parseResults);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
mocker.VerifyAllMocks();
|
||||||
|
result.Should().BeFalse();
|
||||||
|
ExceptionVerification.ExcpectedWarns(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void processResults_should_return_false_when_seriesId_doesnt_match()
|
||||||
|
{
|
||||||
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(1)
|
||||||
|
.All()
|
||||||
|
.With(e => e.SeasonNumber = 1)
|
||||||
|
.With(e => e.EpisodeNumbers = new List<int> { 1 })
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var series = Builder<Series>.CreateNew()
|
||||||
|
.With(s => s.SeriesId = 100)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var episode = Builder<Episode>.CreateNew()
|
||||||
|
.With(e => e.SeriesId = 1)
|
||||||
|
.With(e => e.SeasonNumber = 1)
|
||||||
|
.With(e => e.EpisodeNumber = 1)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||||
|
|
||||||
|
mocker.GetMock<SeriesProvider>()
|
||||||
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(series);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var result = mocker.Resolve<SearchProvider>().ProcessEpisodeSearchResults(new ProgressNotification("Test"), episode, parseResults);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
mocker.VerifyAllMocks();
|
||||||
|
result.Should().BeFalse();
|
||||||
|
ExceptionVerification.ExcpectedWarns(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void processResults_should_return_false_when_seasonNumber_doesnt_match()
|
||||||
|
{
|
||||||
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(1)
|
||||||
|
.All()
|
||||||
|
.With(e => e.SeasonNumber = 1)
|
||||||
|
.With(e => e.EpisodeNumbers = new List<int> { 1 })
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var series = Builder<Series>.CreateNew()
|
||||||
|
.With(s => s.SeriesId = 100)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var episode = Builder<Episode>.CreateNew()
|
||||||
|
.With(e => e.SeriesId = series.SeriesId)
|
||||||
|
.With(e => e.SeasonNumber = 2)
|
||||||
|
.With(e => e.EpisodeNumber = 1)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||||
|
|
||||||
|
mocker.GetMock<SeriesProvider>()
|
||||||
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(series);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var result = mocker.Resolve<SearchProvider>().ProcessEpisodeSearchResults(new ProgressNotification("Test"), episode, parseResults);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
mocker.VerifyAllMocks();
|
||||||
|
result.Should().BeFalse();
|
||||||
|
ExceptionVerification.ExcpectedWarns(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void processResults_should_return_false_when_episodeNumber_doesnt_match()
|
||||||
|
{
|
||||||
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(1)
|
||||||
|
.All()
|
||||||
|
.With(e => e.SeasonNumber = 1)
|
||||||
|
.With(e => e.EpisodeNumbers = new List<int> { 1 })
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var series = Builder<Series>.CreateNew()
|
||||||
|
.With(s => s.SeriesId = 100)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var episode = Builder<Episode>.CreateNew()
|
||||||
|
.With(e => e.SeriesId = series.SeriesId)
|
||||||
|
.With(e => e.SeasonNumber = 1)
|
||||||
|
.With(e => e.EpisodeNumber = 2)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||||
|
|
||||||
|
mocker.GetMock<SeriesProvider>()
|
||||||
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(series);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var result = mocker.Resolve<SearchProvider>().ProcessEpisodeSearchResults(new ProgressNotification("Test"), episode, parseResults);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
mocker.VerifyAllMocks();
|
||||||
|
result.Should().BeFalse();
|
||||||
|
ExceptionVerification.ExcpectedWarns(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -39,6 +39,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(4)
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(4)
|
||||||
.All()
|
.All()
|
||||||
.With(e => e.EpisodeNumbers = Builder<int>.CreateListOfSize(2).Build().ToList())
|
.With(e => e.EpisodeNumbers = Builder<int>.CreateListOfSize(2).Build().ToList())
|
||||||
|
.With(e => e.SeasonNumber = 1)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var mocker = new AutoMoqer(MockBehavior.Strict);
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||||
|
@ -74,6 +75,9 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
mocker.GetMock<DownloadProvider>()
|
mocker.GetMock<DownloadProvider>()
|
||||||
.Setup(s => s.DownloadReport(It.IsAny<EpisodeParseResult>())).Returns(true);
|
.Setup(s => s.DownloadReport(It.IsAny<EpisodeParseResult>())).Returns(true);
|
||||||
|
|
||||||
|
mocker.GetMock<SeriesProvider>()
|
||||||
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(series);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
var result = mocker.Resolve<SearchProvider>().PartialSeasonSearch(notification, 1, 1);
|
var result = mocker.Resolve<SearchProvider>().PartialSeasonSearch(notification, 1, 1);
|
||||||
|
|
||||||
|
@ -152,6 +156,8 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
.All()
|
.All()
|
||||||
.With(e => e.EpisodeNumbers = Builder<int>.CreateListOfSize(2).Build().ToList())
|
.With(e => e.EpisodeNumbers = Builder<int>.CreateListOfSize(2).Build().ToList())
|
||||||
.With(e => e.Series = series)
|
.With(e => e.Series = series)
|
||||||
|
.With(e => e.CleanTitle = "title")
|
||||||
|
.With(e => e.SeasonNumber = 1)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var mocker = new AutoMoqer(MockBehavior.Strict);
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||||
|
@ -164,8 +170,11 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
mocker.GetMock<DownloadProvider>()
|
mocker.GetMock<DownloadProvider>()
|
||||||
.Setup(s => s.DownloadReport(It.IsAny<EpisodeParseResult>())).Returns(true);
|
.Setup(s => s.DownloadReport(It.IsAny<EpisodeParseResult>())).Returns(true);
|
||||||
|
|
||||||
|
mocker.GetMock<SeriesProvider>()
|
||||||
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(series);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
var result = mocker.Resolve<SearchProvider>().ProcessPartialSeasonSearchResults(notification, parseResults);
|
var result = mocker.Resolve<SearchProvider>().ProcessPartialSeasonSearchResults(notification, parseResults, series, 1);
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
result.Should().HaveCount(8);
|
result.Should().HaveCount(8);
|
||||||
|
@ -175,7 +184,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void ProcessPartialSeasonSearchResults_failure()
|
public void ProcessPartialSeasonSearchResults_should_return_empty_list_when_quality_is_not_wanted()
|
||||||
{
|
{
|
||||||
var series = Builder<Series>.CreateNew()
|
var series = Builder<Series>.CreateNew()
|
||||||
.With(s => s.SeriesId = 1)
|
.With(s => s.SeriesId = 1)
|
||||||
|
@ -197,8 +206,114 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
mocker.GetMock<InventoryProvider>()
|
mocker.GetMock<InventoryProvider>()
|
||||||
.Setup(s => s.IsQualityNeeded(It.IsAny<EpisodeParseResult>())).Returns(false);
|
.Setup(s => s.IsQualityNeeded(It.IsAny<EpisodeParseResult>())).Returns(false);
|
||||||
|
|
||||||
|
mocker.GetMock<SeriesProvider>()
|
||||||
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(series);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
var result = mocker.Resolve<SearchProvider>().ProcessPartialSeasonSearchResults(notification, parseResults);
|
var result = mocker.Resolve<SearchProvider>().ProcessPartialSeasonSearchResults(notification, parseResults, series, 1);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
result.Should().HaveCount(0);
|
||||||
|
mocker.VerifyAllMocks();
|
||||||
|
mocker.GetMock<DownloadProvider>().Verify(c => c.DownloadReport(It.IsAny<EpisodeParseResult>()), Times.Never());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ProcessPartialSeasonSearchResults_should_return_empty_list_when_is_wrong_season()
|
||||||
|
{
|
||||||
|
var series = Builder<Series>.CreateNew()
|
||||||
|
.With(s => s.SeriesId = 1)
|
||||||
|
.With(s => s.Title = "Title1")
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(4)
|
||||||
|
.TheFirst(1)
|
||||||
|
.With(p => p.CleanTitle = "title")
|
||||||
|
.With(p => p.SeasonNumber = 2)
|
||||||
|
.With(p => p.FullSeason = true)
|
||||||
|
.With(p => p.EpisodeNumbers = null)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||||
|
|
||||||
|
var notification = new ProgressNotification("Season Search");
|
||||||
|
|
||||||
|
mocker.GetMock<SeriesProvider>()
|
||||||
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(series);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var result = mocker.Resolve<SearchProvider>().ProcessPartialSeasonSearchResults(notification, parseResults, series, 1);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
result.Should().HaveCount(0);
|
||||||
|
mocker.VerifyAllMocks();
|
||||||
|
mocker.GetMock<DownloadProvider>().Verify(c => c.DownloadReport(It.IsAny<EpisodeParseResult>()), Times.Never());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ProcessPartialSeasonSearchResults_should_return_empty_list_when_series_is_null()
|
||||||
|
{
|
||||||
|
var series = Builder<Series>.CreateNew()
|
||||||
|
.With(s => s.SeriesId = 1)
|
||||||
|
.With(s => s.Title = "Title1")
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
Series findSeries = null;
|
||||||
|
|
||||||
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(4)
|
||||||
|
.TheFirst(1)
|
||||||
|
.With(p => p.CleanTitle = "title")
|
||||||
|
.With(p => p.SeasonNumber = 1)
|
||||||
|
.With(p => p.FullSeason = true)
|
||||||
|
.With(p => p.EpisodeNumbers = null)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||||
|
|
||||||
|
var notification = new ProgressNotification("Season Search");
|
||||||
|
|
||||||
|
mocker.GetMock<SeriesProvider>()
|
||||||
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(findSeries);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var result = mocker.Resolve<SearchProvider>().ProcessPartialSeasonSearchResults(notification, parseResults, series, 1);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
result.Should().HaveCount(0);
|
||||||
|
mocker.VerifyAllMocks();
|
||||||
|
mocker.GetMock<DownloadProvider>().Verify(c => c.DownloadReport(It.IsAny<EpisodeParseResult>()), Times.Never());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ProcessPartialSeasonSearchResults_should_return_empty_list_when_series_mismatch()
|
||||||
|
{
|
||||||
|
var series = Builder<Series>.CreateNew()
|
||||||
|
.With(s => s.SeriesId = 1)
|
||||||
|
.With(s => s.Title = "Title1")
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var findSeries = Builder<Series>.CreateNew()
|
||||||
|
.With(s => s.SeriesId = 2)
|
||||||
|
.With(s => s.Title = "Title1")
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(4)
|
||||||
|
.TheFirst(1)
|
||||||
|
.With(p => p.CleanTitle = "title")
|
||||||
|
.With(p => p.SeasonNumber = 1)
|
||||||
|
.With(p => p.FullSeason = true)
|
||||||
|
.With(p => p.EpisodeNumbers = null)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||||
|
|
||||||
|
var notification = new ProgressNotification("Season Search");
|
||||||
|
|
||||||
|
mocker.GetMock<SeriesProvider>()
|
||||||
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(findSeries);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var result = mocker.Resolve<SearchProvider>().ProcessPartialSeasonSearchResults(notification, parseResults, series, 1);
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
result.Should().HaveCount(0);
|
result.Should().HaveCount(0);
|
||||||
|
|
|
@ -78,6 +78,9 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
mocker.GetMock<DownloadProvider>()
|
mocker.GetMock<DownloadProvider>()
|
||||||
.Setup(s => s.DownloadReport(It.IsAny<EpisodeParseResult>())).Returns(true);
|
.Setup(s => s.DownloadReport(It.IsAny<EpisodeParseResult>())).Returns(true);
|
||||||
|
|
||||||
|
mocker.GetMock<SeriesProvider>()
|
||||||
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(series);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
var result = mocker.Resolve<SearchProvider>().SeasonSearch(notification, 1, 1);
|
var result = mocker.Resolve<SearchProvider>().SeasonSearch(notification, 1, 1);
|
||||||
|
|
||||||
|
@ -167,6 +170,9 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
mocker.GetMock<DownloadProvider>()
|
mocker.GetMock<DownloadProvider>()
|
||||||
.Setup(s => s.DownloadReport(It.IsAny<EpisodeParseResult>())).Returns(true);
|
.Setup(s => s.DownloadReport(It.IsAny<EpisodeParseResult>())).Returns(true);
|
||||||
|
|
||||||
|
mocker.GetMock<SeriesProvider>()
|
||||||
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(series);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
var result = mocker.Resolve<SearchProvider>().ProcessSeasonSearchResults(notification, series, 1, parseResults);
|
var result = mocker.Resolve<SearchProvider>().ProcessSeasonSearchResults(notification, series, 1, parseResults);
|
||||||
|
|
||||||
|
@ -176,7 +182,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void ProcessSeasonSearchResults_failure()
|
public void ProcessSeasonSearchResults_should_return_false_when_quality_is_not_wanted()
|
||||||
{
|
{
|
||||||
var series = Builder<Series>.CreateNew()
|
var series = Builder<Series>.CreateNew()
|
||||||
.With(s => s.SeriesId = 1)
|
.With(s => s.SeriesId = 1)
|
||||||
|
@ -198,6 +204,113 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
mocker.GetMock<InventoryProvider>()
|
mocker.GetMock<InventoryProvider>()
|
||||||
.Setup(s => s.IsQualityNeeded(It.IsAny<EpisodeParseResult>())).Returns(false);
|
.Setup(s => s.IsQualityNeeded(It.IsAny<EpisodeParseResult>())).Returns(false);
|
||||||
|
|
||||||
|
mocker.GetMock<SeriesProvider>()
|
||||||
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(series);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var result = mocker.Resolve<SearchProvider>().ProcessSeasonSearchResults(notification, series, 1, parseResults);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
result.Should().BeFalse();
|
||||||
|
ExceptionVerification.ExcpectedWarns(1);
|
||||||
|
mocker.VerifyAllMocks();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ProcessSeasonSearchResults_should_return_false_when_series_is_null()
|
||||||
|
{
|
||||||
|
var series = Builder<Series>.CreateNew()
|
||||||
|
.With(s => s.SeriesId = 1)
|
||||||
|
.With(s => s.Title = "Title1")
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
Series findSeries = null;
|
||||||
|
|
||||||
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(4)
|
||||||
|
.TheFirst(1)
|
||||||
|
.With(p => p.CleanTitle = "title")
|
||||||
|
.With(p => p.SeasonNumber = 1)
|
||||||
|
.With(p => p.FullSeason = true)
|
||||||
|
.With(p => p.EpisodeNumbers = null)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||||
|
|
||||||
|
var notification = new ProgressNotification("Season Search");
|
||||||
|
|
||||||
|
mocker.GetMock<SeriesProvider>()
|
||||||
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(findSeries);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var result = mocker.Resolve<SearchProvider>().ProcessSeasonSearchResults(notification, series, 1, parseResults);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
result.Should().BeFalse();
|
||||||
|
ExceptionVerification.ExcpectedWarns(1);
|
||||||
|
mocker.VerifyAllMocks();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ProcessSeasonSearchResults_should_return_false_when_series_doesnt_match()
|
||||||
|
{
|
||||||
|
var series = Builder<Series>.CreateNew()
|
||||||
|
.With(s => s.SeriesId = 1)
|
||||||
|
.With(s => s.Title = "Title1")
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
Series findSeries = Builder<Series>.CreateNew()
|
||||||
|
.With(s => s.SeriesId = 2)
|
||||||
|
.With(s => s.Title = "Title1")
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(4)
|
||||||
|
.TheFirst(1)
|
||||||
|
.With(p => p.CleanTitle = "title")
|
||||||
|
.With(p => p.SeasonNumber = 1)
|
||||||
|
.With(p => p.FullSeason = true)
|
||||||
|
.With(p => p.EpisodeNumbers = null)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||||
|
|
||||||
|
var notification = new ProgressNotification("Season Search");
|
||||||
|
|
||||||
|
mocker.GetMock<SeriesProvider>()
|
||||||
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(findSeries);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var result = mocker.Resolve<SearchProvider>().ProcessSeasonSearchResults(notification, series, 1, parseResults);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
result.Should().BeFalse();
|
||||||
|
ExceptionVerification.ExcpectedWarns(1);
|
||||||
|
mocker.VerifyAllMocks();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ProcessSeasonSearchResults_should_return_false_when_seasonNumber_doesnt_match()
|
||||||
|
{
|
||||||
|
var series = Builder<Series>.CreateNew()
|
||||||
|
.With(s => s.SeriesId = 1)
|
||||||
|
.With(s => s.Title = "Title1")
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(4)
|
||||||
|
.All()
|
||||||
|
.With(p => p.SeasonNumber = 2)
|
||||||
|
.TheFirst(1)
|
||||||
|
.With(p => p.CleanTitle = "title")
|
||||||
|
.With(p => p.FullSeason = true)
|
||||||
|
.With(p => p.EpisodeNumbers = null)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||||
|
|
||||||
|
var notification = new ProgressNotification("Season Search");
|
||||||
|
|
||||||
|
mocker.GetMock<SeriesProvider>()
|
||||||
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(series);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
var result = mocker.Resolve<SearchProvider>().ProcessSeasonSearchResults(notification, series, 1, parseResults);
|
var result = mocker.Resolve<SearchProvider>().ProcessSeasonSearchResults(notification, series, 1, parseResults);
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,9 @@ namespace NzbDrone.Core.Providers.Indexer
|
||||||
|
|
||||||
if (searchModel.SearchType == SearchType.SeasonSearch)
|
if (searchModel.SearchType == SearchType.SeasonSearch)
|
||||||
{
|
{
|
||||||
searchUrls.Add(String.Format("{0}&limit=100&q={1}&season{2}", url, searchModel.SeriesTitle, searchModel.SeasonNumber));
|
//Todo: Allow full season searching to process individual episodes
|
||||||
|
//searchUrls.Add(String.Format("{0}&limit=100&q={1}&season{2}", url, searchModel.SeriesTitle, searchModel.SeasonNumber));
|
||||||
|
searchUrls.Add(String.Format("{0}&limit=100&q={1}+Season", url, searchModel.SeriesTitle));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,15 +92,15 @@ namespace NzbDrone.Core.Providers
|
||||||
|
|
||||||
notification.CurrentMessage = "Processing search results";
|
notification.CurrentMessage = "Processing search results";
|
||||||
|
|
||||||
var reportsToProcess = reports.Where(p => p.FullSeason && p.SeasonNumber == seasonNumber).ToList();
|
var fullSeasonReportsToProcess = reports.Where(p => p.FullSeason && p.SeasonNumber == seasonNumber).ToList();
|
||||||
|
|
||||||
reportsToProcess.ForEach(c =>
|
fullSeasonReportsToProcess.ForEach(c =>
|
||||||
{
|
{
|
||||||
c.Series = series;
|
|
||||||
c.EpisodeNumbers = episodeNumbers.ToList();
|
c.EpisodeNumbers = episodeNumbers.ToList();
|
||||||
});
|
});
|
||||||
|
|
||||||
return ProcessSeasonSearchResults(notification, series, seasonNumber, reportsToProcess);
|
//Todo: Handle non-full season reports
|
||||||
|
return ProcessSeasonSearchResults(notification, series, seasonNumber, fullSeasonReportsToProcess);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ProcessSeasonSearchResults(ProgressNotification notification, Series series, int seasonNumber, IEnumerable<EpisodeParseResult> reports)
|
public bool ProcessSeasonSearchResults(ProgressNotification notification, Series series, int seasonNumber, IEnumerable<EpisodeParseResult> reports)
|
||||||
|
@ -110,6 +110,18 @@ namespace NzbDrone.Core.Providers
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Logger.Trace("Analysing report " + episodeParseResult);
|
Logger.Trace("Analysing report " + episodeParseResult);
|
||||||
|
|
||||||
|
//Get the matching series
|
||||||
|
episodeParseResult.Series = _seriesProvider.FindSeries(episodeParseResult.CleanTitle);
|
||||||
|
|
||||||
|
//If series is null or doesn't match the series we're looking for return
|
||||||
|
if (episodeParseResult.Series == null || episodeParseResult.Series.SeriesId != series.SeriesId)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
//If SeasonNumber doesn't match or episode is not in the in the list in the parse result, skip it.
|
||||||
|
if (episodeParseResult.SeasonNumber != seasonNumber)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (_inventoryProvider.IsQualityNeeded(episodeParseResult))
|
if (_inventoryProvider.IsQualityNeeded(episodeParseResult))
|
||||||
{
|
{
|
||||||
Logger.Debug("Found '{0}'. Adding to download queue.", episodeParseResult);
|
Logger.Debug("Found '{0}'. Adding to download queue.", episodeParseResult);
|
||||||
|
@ -200,6 +212,18 @@ namespace NzbDrone.Core.Providers
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Logger.Trace("Analysing report " + episodeParseResult);
|
Logger.Trace("Analysing report " + episodeParseResult);
|
||||||
|
|
||||||
|
//Get the matching series
|
||||||
|
var series = _seriesProvider.FindSeries(episodeParseResult.CleanTitle);
|
||||||
|
|
||||||
|
//If series is null or doesn't match the series we're looking for return
|
||||||
|
if (series == null || series.SeriesId != episode.SeriesId)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
//If SeasonNumber doesn't match or episode is not in the in the list in the parse result, skip it.
|
||||||
|
if (episodeParseResult.SeasonNumber != episode.SeasonNumber || !episodeParseResult.EpisodeNumbers.Contains(episode.EpisodeNumber))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (_inventoryProvider.IsQualityNeeded(episodeParseResult))
|
if (_inventoryProvider.IsQualityNeeded(episodeParseResult))
|
||||||
{
|
{
|
||||||
Logger.Debug("Found '{0}'. Adding to download queue.", episodeParseResult);
|
Logger.Debug("Found '{0}'. Adding to download queue.", episodeParseResult);
|
||||||
|
@ -285,15 +309,10 @@ namespace NzbDrone.Core.Providers
|
||||||
|
|
||||||
notification.CurrentMessage = "Processing search results";
|
notification.CurrentMessage = "Processing search results";
|
||||||
|
|
||||||
reports.ForEach(c =>
|
return ProcessPartialSeasonSearchResults(notification, reports, series, seasonNumber);
|
||||||
{
|
|
||||||
c.Series = series;
|
|
||||||
});
|
|
||||||
|
|
||||||
return ProcessPartialSeasonSearchResults(notification, reports);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<int> ProcessPartialSeasonSearchResults(ProgressNotification notification, IEnumerable<EpisodeParseResult> reports)
|
public List<int> ProcessPartialSeasonSearchResults(ProgressNotification notification, IEnumerable<EpisodeParseResult> reports, Series series, int seasonNumber)
|
||||||
{
|
{
|
||||||
var successes = new List<int>();
|
var successes = new List<int>();
|
||||||
|
|
||||||
|
@ -302,6 +321,18 @@ namespace NzbDrone.Core.Providers
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Logger.Trace("Analysing report " + episodeParseResult);
|
Logger.Trace("Analysing report " + episodeParseResult);
|
||||||
|
|
||||||
|
//Get the matching series
|
||||||
|
episodeParseResult.Series = _seriesProvider.FindSeries(episodeParseResult.CleanTitle);
|
||||||
|
|
||||||
|
//If series is null or doesn't match the series we're looking for return
|
||||||
|
if (episodeParseResult.Series == null || episodeParseResult.Series.SeriesId != series.SeriesId)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
//If SeasonNumber doesn't match or episode is not in the in the list in the parse result, skip it.
|
||||||
|
if (episodeParseResult.SeasonNumber != seasonNumber)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (_inventoryProvider.IsQualityNeeded(episodeParseResult))
|
if (_inventoryProvider.IsQualityNeeded(episodeParseResult))
|
||||||
{
|
{
|
||||||
Logger.Debug("Found '{0}'. Adding to download queue.", episodeParseResult);
|
Logger.Debug("Found '{0}'. Adding to download queue.", episodeParseResult);
|
||||||
|
|
Loading…
Reference in New Issue