mirror of
https://github.com/Sonarr/Sonarr
synced 2024-12-26 17:57:43 +00:00
New: Series search will search starting with the lowest season
This commit is contained in:
parent
c58c8ea542
commit
730aba4408
3 changed files with 84 additions and 2 deletions
|
@ -0,0 +1,80 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using FluentAssertions;
|
||||||
|
using Moq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using NzbDrone.Core.DecisionEngine;
|
||||||
|
using NzbDrone.Core.Download;
|
||||||
|
using NzbDrone.Core.IndexerSearch;
|
||||||
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
using NzbDrone.Core.Tv;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Test.IndexerSearchTests
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class SeriesSearchServiceFixture : CoreTest<SeriesSearchService>
|
||||||
|
{
|
||||||
|
private Series _series;
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public void Setup()
|
||||||
|
{
|
||||||
|
_series = new Series
|
||||||
|
{
|
||||||
|
Id = 1,
|
||||||
|
Title = "Title",
|
||||||
|
Seasons = new List<Season>()
|
||||||
|
};
|
||||||
|
|
||||||
|
Mocker.GetMock<ISeriesService>()
|
||||||
|
.Setup(s => s.GetSeries(It.IsAny<Int32>()))
|
||||||
|
.Returns(_series);
|
||||||
|
|
||||||
|
Mocker.GetMock<ISearchForNzb>()
|
||||||
|
.Setup(s => s.SeasonSearch(_series.Id, It.IsAny<Int32>()))
|
||||||
|
.Returns(new List<DownloadDecision>());
|
||||||
|
|
||||||
|
Mocker.GetMock<IProcessDownloadDecisions>()
|
||||||
|
.Setup(s => s.ProcessDecisions(It.IsAny<List<DownloadDecision>>()))
|
||||||
|
.Returns(new ProcessedDecisions(new List<DownloadDecision>(), new List<DownloadDecision>()));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_only_include_monitored_seasons()
|
||||||
|
{
|
||||||
|
_series.Seasons = new List<Season>
|
||||||
|
{
|
||||||
|
new Season { SeasonNumber = 0, Monitored = false },
|
||||||
|
new Season { SeasonNumber = 1, Monitored = true }
|
||||||
|
};
|
||||||
|
|
||||||
|
Subject.Execute(new SeriesSearchCommand{ SeriesId = _series.Id });
|
||||||
|
|
||||||
|
Mocker.GetMock<ISearchForNzb>()
|
||||||
|
.Verify(v => v.SeasonSearch(_series.Id, It.IsAny<Int32>()), Times.Exactly(_series.Seasons.Count(s => s.Monitored)));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_start_with_lower_seasons_first()
|
||||||
|
{
|
||||||
|
var seasonOrder = new List<Int32>();
|
||||||
|
|
||||||
|
_series.Seasons = new List<Season>
|
||||||
|
{
|
||||||
|
new Season { SeasonNumber = 3, Monitored = true },
|
||||||
|
new Season { SeasonNumber = 1, Monitored = true },
|
||||||
|
new Season { SeasonNumber = 2, Monitored = true }
|
||||||
|
};
|
||||||
|
|
||||||
|
Mocker.GetMock<ISearchForNzb>()
|
||||||
|
.Setup(s => s.SeasonSearch(_series.Id, It.IsAny<Int32>()))
|
||||||
|
.Returns(new List<DownloadDecision>())
|
||||||
|
.Callback<Int32, Int32>((seriesId, seasonNumber) => seasonOrder.Add(seasonNumber));
|
||||||
|
|
||||||
|
Subject.Execute(new SeriesSearchCommand { SeriesId = _series.Id });
|
||||||
|
|
||||||
|
seasonOrder.First().Should().Be(_series.Seasons.OrderBy(s => s.SeasonNumber).First().SeasonNumber);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -175,6 +175,7 @@
|
||||||
<Compile Include="Housekeeping\Housekeepers\CleanupOrphanedMetadataFilesFixture.cs" />
|
<Compile Include="Housekeeping\Housekeepers\CleanupOrphanedMetadataFilesFixture.cs" />
|
||||||
<Compile Include="Housekeeping\Housekeepers\CleanupOrphanedPendingReleasesFixture.cs" />
|
<Compile Include="Housekeeping\Housekeepers\CleanupOrphanedPendingReleasesFixture.cs" />
|
||||||
<Compile Include="Housekeeping\Housekeepers\FixFutureRunScheduledTasksFixture.cs" />
|
<Compile Include="Housekeeping\Housekeepers\FixFutureRunScheduledTasksFixture.cs" />
|
||||||
|
<Compile Include="IndexerSearchTests\SeriesSearchServiceFixture.cs" />
|
||||||
<Compile Include="IndexerSearchTests\NzbSearchServiceFixture.cs" />
|
<Compile Include="IndexerSearchTests\NzbSearchServiceFixture.cs" />
|
||||||
<Compile Include="IndexerSearchTests\SearchDefinitionFixture.cs" />
|
<Compile Include="IndexerSearchTests\SearchDefinitionFixture.cs" />
|
||||||
<Compile Include="IndexerTests\AnimezbTests\AnimezbFixture.cs" />
|
<Compile Include="IndexerTests\AnimezbTests\AnimezbFixture.cs" />
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using NLog;
|
using System.Linq;
|
||||||
|
using NLog;
|
||||||
using NzbDrone.Common.Instrumentation.Extensions;
|
using NzbDrone.Common.Instrumentation.Extensions;
|
||||||
using NzbDrone.Core.Download;
|
using NzbDrone.Core.Download;
|
||||||
using NzbDrone.Core.Messaging.Commands;
|
using NzbDrone.Core.Messaging.Commands;
|
||||||
|
@ -30,7 +31,7 @@ namespace NzbDrone.Core.IndexerSearch
|
||||||
|
|
||||||
var downloadedCount = 0;
|
var downloadedCount = 0;
|
||||||
|
|
||||||
foreach (var season in series.Seasons)
|
foreach (var season in series.Seasons.OrderBy(s => s.SeasonNumber))
|
||||||
{
|
{
|
||||||
if (!season.Monitored)
|
if (!season.Monitored)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue