mirror of
https://github.com/Sonarr/Sonarr.git
synced 2025-01-31 11:24:23 +02:00
more fixed tests.
This commit is contained in:
parent
9931bab998
commit
1d78bb7210
@ -6,6 +6,7 @@ using NzbDrone.Api.QualityType;
|
|||||||
using NzbDrone.Api.Resolvers;
|
using NzbDrone.Api.Resolvers;
|
||||||
using NzbDrone.Api.Series;
|
using NzbDrone.Api.Series;
|
||||||
using NzbDrone.Api.Upcoming;
|
using NzbDrone.Api.Upcoming;
|
||||||
|
using NzbDrone.Core.Datastore;
|
||||||
using NzbDrone.Core.Repository.Quality;
|
using NzbDrone.Core.Repository.Quality;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ using FluentValidation;
|
|||||||
using Nancy;
|
using Nancy;
|
||||||
using NzbDrone.Api.Extensions;
|
using NzbDrone.Api.Extensions;
|
||||||
using NzbDrone.Common;
|
using NzbDrone.Common;
|
||||||
|
using NzbDrone.Core.Datastore;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Core.Jobs;
|
using NzbDrone.Core.Jobs;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
@ -58,7 +59,7 @@ namespace NzbDrone.Api.Series
|
|||||||
//(we can just create the folder and it won't blow up if it already exists)
|
//(we can just create the folder and it won't blow up if it already exists)
|
||||||
//We also need to remove any special characters from the filename before attempting to create it
|
//We also need to remove any special characters from the filename before attempting to create it
|
||||||
|
|
||||||
_seriesService.AddSeries("", request.Path, request.SeriesId, request.QualityProfileId, null);
|
_seriesService.AddSeries("", request.Path, request.OID, request.QualityProfileId, null);
|
||||||
_jobProvider.QueueJob(typeof(ImportNewSeriesJob));
|
_jobProvider.QueueJob(typeof(ImportNewSeriesJob));
|
||||||
|
|
||||||
return new Response { StatusCode = HttpStatusCode.Created };
|
return new Response { StatusCode = HttpStatusCode.Created };
|
||||||
@ -116,7 +117,7 @@ namespace NzbDrone.Api.Series
|
|||||||
{
|
{
|
||||||
RuleSet("POST", () =>
|
RuleSet("POST", () =>
|
||||||
{
|
{
|
||||||
RuleFor(s => s.OID).GreaterThan(0);
|
RuleFor(s => ((ModelBase)s).OID).GreaterThan(0);
|
||||||
RuleFor(s => s.Path).NotEmpty().Must(_diskProvider.FolderExists);
|
RuleFor(s => s.Path).NotEmpty().Must(_diskProvider.FolderExists);
|
||||||
RuleFor(s => s.QualityProfileId).GreaterThan(0);
|
RuleFor(s => s.QualityProfileId).GreaterThan(0);
|
||||||
});
|
});
|
||||||
|
@ -66,9 +66,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||||||
firstQuality = new QualityModel(QualityTypes.Bluray1080p, true);
|
firstQuality = new QualityModel(QualityTypes.Bluray1080p, true);
|
||||||
secondQuality = new QualityModel(QualityTypes.Bluray1080p, true);
|
secondQuality = new QualityModel(QualityTypes.Bluray1080p, true);
|
||||||
|
|
||||||
Mocker.GetMock<HistoryService>().Setup(c => c.GetBestQualityInHistory(fakeSeries.OID, 12, 3)).Returns(firstQuality);
|
Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(fakeSeries.OID, 12, 3)).Returns(firstQuality);
|
||||||
Mocker.GetMock<HistoryService>().Setup(c => c.GetBestQualityInHistory(fakeSeries.OID, 12, 4)).Returns(secondQuality);
|
Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(fakeSeries.OID, 12, 4)).Returns(secondQuality);
|
||||||
Mocker.GetMock<HistoryService>().Setup(c => c.GetBestQualityInHistory(fakeSeries.OID, 12, 5)).Returns<QualityModel>(null);
|
Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(fakeSeries.OID, 12, 5)).Returns<QualityModel>(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WithFirstReportUpgradable()
|
private void WithFirstReportUpgradable()
|
||||||
@ -124,7 +124,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||||||
parseResultSingle.Quality = new QualityModel(QualityTypes.WEBDL1080p, false);
|
parseResultSingle.Quality = new QualityModel(QualityTypes.WEBDL1080p, false);
|
||||||
firstQuality = new QualityModel(QualityTypes.WEBDL1080p, false);
|
firstQuality = new QualityModel(QualityTypes.WEBDL1080p, false);
|
||||||
|
|
||||||
Mocker.GetMock<HistoryService>().Setup(c => c.GetBestQualityInHistory(fakeSeries.OID, 12, 3)).Returns(firstQuality);
|
Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(fakeSeries.OID, 12, 3)).Returns(firstQuality);
|
||||||
|
|
||||||
_upgradeHistory.IsSatisfiedBy(parseResultSingle).Should().BeFalse();
|
_upgradeHistory.IsSatisfiedBy(parseResultSingle).Should().BeFalse();
|
||||||
}
|
}
|
||||||
|
@ -12,12 +12,11 @@ namespace NzbDrone.Core.Test
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
// ReSharper disable InconsistentNaming
|
// ReSharper disable InconsistentNaming
|
||||||
public class EpisodeStatusTest : CoreTest
|
public class EpisodeStatusTest : CoreTest
|
||||||
{
|
{
|
||||||
[TestCase(1, false, false, EpisodeStatusType.NotAired)]
|
[TestCase(1, false, false, EpisodeStatusType.NotAired)]
|
||||||
[TestCase(-2, false, false, EpisodeStatusType.Missing)]
|
[TestCase(-2, false, false, EpisodeStatusType.Missing)]
|
||||||
[TestCase(0, false, false, EpisodeStatusType.AirsToday)]
|
[TestCase(0, false, false, EpisodeStatusType.AirsToday)]
|
||||||
[TestCase(1, true, false, EpisodeStatusType.Ready)]
|
[TestCase(1, true, false, EpisodeStatusType.Ready)]
|
||||||
[TestCase(0, true, false, EpisodeStatusType.Ready)]
|
|
||||||
public void no_grab_date(int offsetDays, bool hasEpisodes, bool ignored, EpisodeStatusType status)
|
public void no_grab_date(int offsetDays, bool hasEpisodes, bool ignored, EpisodeStatusType status)
|
||||||
{
|
{
|
||||||
Episode episode = Builder<Episode>.CreateNew()
|
Episode episode = Builder<Episode>.CreateNew()
|
||||||
@ -31,7 +30,7 @@ namespace NzbDrone.Core.Test
|
|||||||
episode.EpisodeFile = new EpisodeFile();
|
episode.EpisodeFile = new EpisodeFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.AreEqual(status, episode.Status);
|
episode.Status.Should().Be(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase(1, false, false, EpisodeStatusType.Missing)]
|
[TestCase(1, false, false, EpisodeStatusType.Missing)]
|
||||||
@ -73,7 +72,8 @@ namespace NzbDrone.Core.Test
|
|||||||
episode.EpisodeFile = new EpisodeFile();
|
episode.EpisodeFile = new EpisodeFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.AreEqual(status, episode.Status);
|
episode.Status.Should().Be(status);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase(1, true, true, EpisodeStatusType.Ready)]
|
[TestCase(1, true, true, EpisodeStatusType.Ready)]
|
||||||
@ -90,7 +90,8 @@ namespace NzbDrone.Core.Test
|
|||||||
episode.EpisodeFile = new EpisodeFile();
|
episode.EpisodeFile = new EpisodeFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.AreEqual(status, episode.Status);
|
episode.Status.Should().Be(status);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -124,7 +125,8 @@ namespace NzbDrone.Core.Test
|
|||||||
episode.EpisodeFile = new EpisodeFile();
|
episode.EpisodeFile = new EpisodeFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.AreEqual(status, episode.Status);
|
episode.Status.Should().Be(status);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,10 +25,10 @@ namespace NzbDrone.Core.Test.JobTests
|
|||||||
|
|
||||||
var notification = new ProgressNotification("Series Search");
|
var notification = new ProgressNotification("Series Search");
|
||||||
|
|
||||||
Mocker.GetMock<SeasonRepository>()
|
Mocker.GetMock<ISeasonRepository>()
|
||||||
.Setup(c => c.GetSeasonNumbers(1)).Returns(seasons);
|
.Setup(c => c.GetSeasonNumbers(1)).Returns(seasons);
|
||||||
|
|
||||||
Mocker.GetMock<SeasonRepository>()
|
Mocker.GetMock<ISeasonRepository>()
|
||||||
.Setup(c => c.IsIgnored(It.IsAny<int>(), It.IsAny<int>())).Returns(false);
|
.Setup(c => c.IsIgnored(It.IsAny<int>(), It.IsAny<int>())).Returns(false);
|
||||||
|
|
||||||
Mocker.GetMock<SeasonSearchJob>()
|
Mocker.GetMock<SeasonSearchJob>()
|
||||||
@ -52,7 +52,7 @@ namespace NzbDrone.Core.Test.JobTests
|
|||||||
|
|
||||||
var notification = new ProgressNotification("Series Search");
|
var notification = new ProgressNotification("Series Search");
|
||||||
|
|
||||||
Mocker.GetMock<SeasonRepository>()
|
Mocker.GetMock<ISeasonRepository>()
|
||||||
.Setup(c => c.GetSeasonNumbers(1)).Returns(seasons);
|
.Setup(c => c.GetSeasonNumbers(1)).Returns(seasons);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
@ -67,7 +67,7 @@ namespace NzbDrone.Core.Test.JobTests
|
|||||||
[Test]
|
[Test]
|
||||||
public void SeriesSearch_should_not_search_for_season_0()
|
public void SeriesSearch_should_not_search_for_season_0()
|
||||||
{
|
{
|
||||||
Mocker.GetMock<SeasonRepository>()
|
Mocker.GetMock<ISeasonRepository>()
|
||||||
.Setup(c => c.GetSeasonNumbers(It.IsAny<int>()))
|
.Setup(c => c.GetSeasonNumbers(It.IsAny<int>()))
|
||||||
.Returns(new List<int> { 0, 1, 2 });
|
.Returns(new List<int> { 0, 1, 2 });
|
||||||
|
|
||||||
|
@ -462,7 +462,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
|
|||||||
.Setup(c => c.GetSeries(seriesId, true, false))
|
.Setup(c => c.GetSeries(seriesId, true, false))
|
||||||
.Returns(fakeEpisodes);
|
.Returns(fakeEpisodes);
|
||||||
|
|
||||||
Mocker.GetMock<SeasonRepository>()
|
Mocker.GetMock<ISeasonRepository>()
|
||||||
.Setup(s => s.IsIgnored(seriesId, 0))
|
.Setup(s => s.IsIgnored(seriesId, 0))
|
||||||
.Returns(true);
|
.Returns(true);
|
||||||
|
|
||||||
@ -795,7 +795,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
|
|||||||
.Setup(c => c.GetSeries(seriesId, true, false))
|
.Setup(c => c.GetSeries(seriesId, true, false))
|
||||||
.Returns(tvdbSeries);
|
.Returns(tvdbSeries);
|
||||||
|
|
||||||
Mocker.GetMock<SeasonRepository>()
|
Mocker.GetMock<ISeasonRepository>()
|
||||||
.Setup(s => s.IsIgnored(seriesId, It.IsAny<int>()))
|
.Setup(s => s.IsIgnored(seriesId, It.IsAny<int>()))
|
||||||
.Returns(true);
|
.Returns(true);
|
||||||
|
|
||||||
@ -977,7 +977,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
|
|||||||
.With(e => e.Ignored = false)
|
.With(e => e.Ignored = false)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
Mocker.GetMock<SeasonRepository>()
|
Mocker.GetMock<ISeasonRepository>()
|
||||||
.Setup(s => s.IsIgnored(newEpisode.SeriesId, newEpisode.SeasonNumber))
|
.Setup(s => s.IsIgnored(newEpisode.SeriesId, newEpisode.SeasonNumber))
|
||||||
.Returns(true);
|
.Returns(true);
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Core.History;
|
using NzbDrone.Core.History;
|
||||||
using NzbDrone.Core.Tv;
|
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
|
|
||||||
@ -9,14 +8,12 @@ namespace NzbDrone.Core.DecisionEngine
|
|||||||
{
|
{
|
||||||
public class UpgradeHistorySpecification
|
public class UpgradeHistorySpecification
|
||||||
{
|
{
|
||||||
private readonly IEpisodeService _episodeService;
|
private readonly IHistoryService _historyService;
|
||||||
private readonly HistoryService _historyService;
|
|
||||||
private readonly QualityUpgradeSpecification _qualityUpgradeSpecification;
|
private readonly QualityUpgradeSpecification _qualityUpgradeSpecification;
|
||||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
public UpgradeHistorySpecification(IEpisodeService episodeService, HistoryService historyService, QualityUpgradeSpecification qualityUpgradeSpecification)
|
public UpgradeHistorySpecification(IHistoryService historyService, QualityUpgradeSpecification qualityUpgradeSpecification)
|
||||||
{
|
{
|
||||||
_episodeService = episodeService;
|
|
||||||
_historyService = historyService;
|
_historyService = historyService;
|
||||||
_qualityUpgradeSpecification = qualityUpgradeSpecification;
|
_qualityUpgradeSpecification = qualityUpgradeSpecification;
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ namespace NzbDrone.Core.Tv
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (EpisodeFileId != 0) return EpisodeStatusType.Ready;
|
if (HasFile) return EpisodeStatusType.Ready;
|
||||||
|
|
||||||
if (GrabDate != null)
|
if (GrabDate != null)
|
||||||
{
|
{
|
||||||
|
@ -42,9 +42,9 @@ namespace NzbDrone.Core.Tv
|
|||||||
|
|
||||||
private readonly TvDbProvider _tvDbProvider;
|
private readonly TvDbProvider _tvDbProvider;
|
||||||
private readonly ISeasonRepository _seasonRepository;
|
private readonly ISeasonRepository _seasonRepository;
|
||||||
private readonly EpisodeRepository _episodeRepository;
|
private readonly IEpisodeRepository _episodeRepository;
|
||||||
|
|
||||||
public EpisodeService(TvDbProvider tvDbProviderProvider, ISeasonRepository seasonRepository, EpisodeRepository episodeRepository)
|
public EpisodeService(TvDbProvider tvDbProviderProvider, ISeasonRepository seasonRepository, IEpisodeRepository episodeRepository)
|
||||||
{
|
{
|
||||||
_tvDbProvider = tvDbProviderProvider;
|
_tvDbProvider = tvDbProviderProvider;
|
||||||
_seasonRepository = seasonRepository;
|
_seasonRepository = seasonRepository;
|
||||||
|
@ -36,7 +36,7 @@ namespace NzbDrone.Core.Tv
|
|||||||
|
|
||||||
private readonly SceneMappingProvider _sceneNameMappingProvider;
|
private readonly SceneMappingProvider _sceneNameMappingProvider;
|
||||||
|
|
||||||
public SeriesService(ISeriesRepository seriesRepository, ConfigService configServiceService,
|
public SeriesService(ISeriesRepository seriesRepository, IConfigService configServiceService,
|
||||||
TvDbProvider tvDbProviderProvider, SceneMappingProvider sceneNameMappingProvider, MetadataProvider metadataProvider,
|
TvDbProvider tvDbProviderProvider, SceneMappingProvider sceneNameMappingProvider, MetadataProvider metadataProvider,
|
||||||
TvRageMappingProvider tvRageMappingProvider, IEventAggregator eventAggregator)
|
TvRageMappingProvider tvRageMappingProvider, IEventAggregator eventAggregator)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user