Should skip History check during a search

pull/2/head
Mark McDowall 12 years ago
parent 1274c1c144
commit 33db208bb6

@ -3,6 +3,7 @@ using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.DecisionEngine.Specifications.RssSync;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Test.Framework;
@ -102,5 +103,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
WithSecondEpisodeUnmonitored();
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti, null).Should().BeTrue();
}
[Test]
public void should_return_true_if_it_is_a_search()
{
_fakeSeries.Monitored = false;
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti, new SeasonSearchCriteria()).Should().BeTrue();
}
}
}

@ -4,6 +4,7 @@ using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.History;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
@ -122,5 +123,11 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
_upgradeHistory.IsSatisfiedBy(_parseResultSingle, null).Should().BeFalse();
}
[Test]
public void should_return_true_if_it_is_a_search()
{
_upgradeHistory.IsSatisfiedBy(_parseResultMulti, new SeasonSearchCriteria()).Should().BeTrue();
}
}
}

@ -5,6 +5,6 @@ namespace NzbDrone.Core.DecisionEngine
{
public interface IDecisionEngineSpecification : IRejectWithReason
{
bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteriaBase);
bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria);
}
}

@ -25,7 +25,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
get { return "File size too big or small"; }
}
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteriaBase)
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
{
_logger.Trace("Beginning size check for: {0}", subject);

@ -22,7 +22,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
}
}
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteriaBase)
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
{
_logger.Trace("Checking if report meets language requirements. {0}", subject.ParsedEpisodeInfo.Language);
if (subject.ParsedEpisodeInfo.Language != Language.English)

@ -28,7 +28,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
}
}
public bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteriaBase)
public bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
{
var downloadClient = _downloadClientProvider.GetDownloadClient();

@ -25,7 +25,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
}
}
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteriaBase)
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
{
_logger.Trace("Checking if release contains any restricted terms: {0}", subject);

@ -21,7 +21,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
}
}
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteriaBase)
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
{
_logger.Trace("Checking if report meets quality requirements. {0}", subject.ParsedEpisodeInfo.Quality);
if (!subject.Series.QualityProfile.Value.Allowed.Contains(subject.ParsedEpisodeInfo.Quality.Quality))

@ -25,7 +25,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
}
}
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteriaBase)
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
{
var age = subject.Report.Age;

@ -22,9 +22,9 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
}
}
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteriaBase)
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
{
if (searchCriteriaBase != null)
if (searchCriteria != null)
{
_logger.Trace("Skipping monitored check during search");
return true;

@ -23,14 +23,14 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.Search
return "Episode doesn't match";
}
}
public bool IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteriaBase)
public bool IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria)
{
if (searchCriteriaBase == null)
if (searchCriteria == null)
{
return true;
}
var dailySearchSpec = searchCriteriaBase as DailyEpisodeSearchCriteria;
var dailySearchSpec = searchCriteria as DailyEpisodeSearchCriteria;
if (dailySearchSpec == null) return true;

@ -21,14 +21,14 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.Search
}
}
public bool IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteriaBase)
public bool IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria)
{
if (searchCriteriaBase == null)
if (searchCriteria == null)
{
return true;
}
var singleEpisodeSpec = searchCriteriaBase as SeasonSearchCriteria;
var singleEpisodeSpec = searchCriteria as SeasonSearchCriteria;
if (singleEpisodeSpec == null) return true;
if (singleEpisodeSpec.SeasonNumber != remoteEpisode.ParsedEpisodeInfo.SeasonNumber)

@ -22,14 +22,14 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.Search
}
}
public bool IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteriaBase)
public bool IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria)
{
if (searchCriteriaBase == null)
if (searchCriteria == null)
{
return true;
}
var singleEpisodeSpec = searchCriteriaBase as SingleEpisodeSearchCriteria;
var singleEpisodeSpec = searchCriteria as SingleEpisodeSearchCriteria;
if (singleEpisodeSpec == null) return true;
if (singleEpisodeSpec.SeasonNumber != remoteEpisode.ParsedEpisodeInfo.SeasonNumber)

@ -25,7 +25,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
}
}
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteriaBase)
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
{
foreach (var file in subject.Episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFile.Value))
{

@ -26,8 +26,14 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
}
}
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteriaBase)
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
{
if (searchCriteria != null)
{
_logger.Trace("Skipping history check during search");
return true;
}
foreach (var episode in subject.Episodes)
{
var bestQualityInHistory = _historyService.GetBestQualityInHistory(episode.Id);

Loading…
Cancel
Save