mirror of
https://github.com/Radarr/Radarr
synced 2024-12-26 17:59:14 +00:00
Merge remote-tracking branch 'origin/master' into backbone
This commit is contained in:
commit
c1d0bc9ac8
2 changed files with 20 additions and 21 deletions
|
@ -12,6 +12,7 @@
|
||||||
using NzbDrone.Core.Repository;
|
using NzbDrone.Core.Repository;
|
||||||
using NzbDrone.Core.Repository.Search;
|
using NzbDrone.Core.Repository.Search;
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
using NzbDrone.Test.Common;
|
||||||
using NzbDrone.Test.Common.AutoMoq;
|
using NzbDrone.Test.Common.AutoMoq;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.JobTests
|
namespace NzbDrone.Core.Test.JobTests
|
||||||
|
@ -20,12 +21,25 @@ namespace NzbDrone.Core.Test.JobTests
|
||||||
// ReSharper disable InconsistentNaming
|
// ReSharper disable InconsistentNaming
|
||||||
public class SeasonSearchJobTest : CoreTest
|
public class SeasonSearchJobTest : CoreTest
|
||||||
{
|
{
|
||||||
|
private IList<Episode> _episodes;
|
||||||
|
|
||||||
private ProgressNotification notification;
|
private ProgressNotification notification;
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup()
|
public void Setup()
|
||||||
{
|
{
|
||||||
notification = new ProgressNotification("Search");
|
notification = new ProgressNotification("Search");
|
||||||
|
|
||||||
|
_episodes = Builder<Episode>.CreateListOfSize(5)
|
||||||
|
.All()
|
||||||
|
.With(e => e.SeriesId = 1)
|
||||||
|
.With(e => e.SeasonNumber = 1)
|
||||||
|
.With(e => e.Ignored = false)
|
||||||
|
.With(e => e.AirDate = DateTime.Today.AddDays(-1))
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
Mocker.GetMock<EpisodeProvider>()
|
||||||
|
.Setup(c => c.GetEpisodesBySeason(1, 1)).Returns(_episodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -37,18 +51,9 @@ public void SeasonSearch_partial_season_success()
|
||||||
.With(e => e.Success = true)
|
.With(e => e.Success = true)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var episodes = Builder<Episode>.CreateListOfSize(5)
|
|
||||||
.All()
|
|
||||||
.With(e => e.SeasonNumber = 1)
|
|
||||||
.With(e => e.SeriesId = 5)
|
|
||||||
.Build();
|
|
||||||
|
|
||||||
Mocker.GetMock<EpisodeProvider>()
|
|
||||||
.Setup(c => c.GetEpisodesBySeason(1, 1)).Returns(episodes);
|
|
||||||
|
|
||||||
Mocker.GetMock<SearchProvider>()
|
Mocker.GetMock<SearchProvider>()
|
||||||
.Setup(c => c.PartialSeasonSearch(notification, 1, 1))
|
.Setup(c => c.PartialSeasonSearch(notification, 1, 1))
|
||||||
.Returns(episodes.Select(e => e.EpisodeNumber).ToList());
|
.Returns(_episodes.Select(e => e.EpisodeNumber).ToList());
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
Mocker.Resolve<SeasonSearchJob>().Start(notification, new { SeriesId = 1, SeasonNumber = 1 });
|
Mocker.Resolve<SeasonSearchJob>().Start(notification, new { SeriesId = 1, SeasonNumber = 1 });
|
||||||
|
@ -62,14 +67,6 @@ public void SeasonSearch_partial_season_success()
|
||||||
[Test]
|
[Test]
|
||||||
public void SeasonSearch_partial_season_failure()
|
public void SeasonSearch_partial_season_failure()
|
||||||
{
|
{
|
||||||
var episodes = Builder<Episode>.CreateListOfSize(5)
|
|
||||||
.All()
|
|
||||||
.With(e => e.SeriesId = 1)
|
|
||||||
.With(e => e.SeasonNumber = 1)
|
|
||||||
.With(e => e.Ignored = false)
|
|
||||||
.With(e => e.AirDate = DateTime.Today.AddDays(-1))
|
|
||||||
.Build();
|
|
||||||
|
|
||||||
Mocker.GetMock<SearchProvider>()
|
Mocker.GetMock<SearchProvider>()
|
||||||
.Setup(c => c.PartialSeasonSearch(notification, 1, 1))
|
.Setup(c => c.PartialSeasonSearch(notification, 1, 1))
|
||||||
.Returns(new List<int>());
|
.Returns(new List<int>());
|
||||||
|
@ -78,7 +75,6 @@ public void SeasonSearch_partial_season_failure()
|
||||||
Mocker.Resolve<SeasonSearchJob>().Start(notification, new { SeriesId = 1, SeasonNumber = 1 });
|
Mocker.Resolve<SeasonSearchJob>().Start(notification, new { SeriesId = 1, SeasonNumber = 1 });
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Mocker.VerifyAllMocks();
|
|
||||||
Mocker.GetMock<SearchProvider>().Verify(c => c.PartialSeasonSearch(notification, 1, 1), Times.Once());
|
Mocker.GetMock<SearchProvider>().Verify(c => c.PartialSeasonSearch(notification, 1, 1), Times.Once());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,6 +119,8 @@ public void SeasonSearch_should_allow_searching_of_season_zero()
|
||||||
//Assert
|
//Assert
|
||||||
Mocker.GetMock<SearchProvider>().Verify(c => c.PartialSeasonSearch(notification, 1, 1), Times.Never());
|
Mocker.GetMock<SearchProvider>().Verify(c => c.PartialSeasonSearch(notification, 1, 1), Times.Never());
|
||||||
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, new { EpisodeId = It.IsAny<int>() }), Times.Never());
|
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, new { EpisodeId = It.IsAny<int>() }), Times.Never());
|
||||||
|
|
||||||
|
ExceptionVerification.ExpectedWarns(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -53,8 +53,9 @@ public virtual void Start(ProgressNotification notification, dynamic options)
|
||||||
//3 searches should guarentee results, (24 eps) versus, a potential 4 to get the same eps.
|
//3 searches should guarentee results, (24 eps) versus, a potential 4 to get the same eps.
|
||||||
List<int> successes = _searchProvider.PartialSeasonSearch(notification, options.SeriesId, options.SeasonNumber);
|
List<int> successes = _searchProvider.PartialSeasonSearch(notification, options.SeriesId, options.SeasonNumber);
|
||||||
|
|
||||||
if (successes.Count == 0)
|
//This causes issues with Newznab
|
||||||
return;
|
//if (successes.Count == 0)
|
||||||
|
// return;
|
||||||
|
|
||||||
Logger.Debug("Getting episodes from database for series: {0} and season: {1}", options.SeriesId, options.SeasonNumber);
|
Logger.Debug("Getting episodes from database for series: {0} and season: {1}", options.SeriesId, options.SeasonNumber);
|
||||||
List<Episode> episodes = _episodeProvider.GetEpisodesBySeason(options.SeriesId, options.SeasonNumber);
|
List<Episode> episodes = _episodeProvider.GetEpisodesBySeason(options.SeriesId, options.SeasonNumber);
|
||||||
|
|
Loading…
Reference in a new issue