mirror of https://github.com/Radarr/Radarr
Fixed: fixed an issue where season ignore check wasn't working correctly.
Fixed: unavailable nzbdrone service will no longer block series from being added.
This commit is contained in:
parent
ada0a3bfbc
commit
c5df00cc87
|
@ -157,7 +157,7 @@ namespace NzbDrone.Core.Test.JobTests
|
||||||
Mocker.Resolve<ImportNewSeriesJob>().AutoIgnoreSeasons(seriesId);
|
Mocker.Resolve<ImportNewSeriesJob>().AutoIgnoreSeasons(seriesId);
|
||||||
|
|
||||||
|
|
||||||
Mocker.GetMock<EpisodeProvider>().Verify(p => p.SetSeasonIgnore(seriesId, It.IsAny<int>(), It.IsAny<Boolean>()), Times.Never());
|
Mocker.GetMock<SeasonProvider>().Verify(p => p.SetIgnore(seriesId, It.IsAny<int>(), It.IsAny<Boolean>()), Times.Never());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -184,7 +184,7 @@ namespace NzbDrone.Core.Test.JobTests
|
||||||
|
|
||||||
Mocker.Resolve<ImportNewSeriesJob>().AutoIgnoreSeasons(seriesId);
|
Mocker.Resolve<ImportNewSeriesJob>().AutoIgnoreSeasons(seriesId);
|
||||||
|
|
||||||
Mocker.GetMock<EpisodeProvider>().Verify(p => p.SetSeasonIgnore(seriesId, 2, It.IsAny<Boolean>()), Times.Never());
|
Mocker.GetMock<SeasonProvider>().Verify(p => p.SetIgnore(seriesId, 2, It.IsAny<Boolean>()), Times.Never());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -210,9 +210,9 @@ namespace NzbDrone.Core.Test.JobTests
|
||||||
|
|
||||||
Mocker.Resolve<ImportNewSeriesJob>().AutoIgnoreSeasons(seriesId);
|
Mocker.Resolve<ImportNewSeriesJob>().AutoIgnoreSeasons(seriesId);
|
||||||
|
|
||||||
Mocker.GetMock<EpisodeProvider>().Verify(p => p.SetSeasonIgnore(seriesId, 0, true), Times.Once());
|
Mocker.GetMock<SeasonProvider>().Verify(p => p.SetIgnore(seriesId, 0, true), Times.Once());
|
||||||
Mocker.GetMock<EpisodeProvider>().Verify(p => p.SetSeasonIgnore(seriesId, 1, true), Times.Never());
|
Mocker.GetMock<SeasonProvider>().Verify(p => p.SetIgnore(seriesId, 1, true), Times.Never());
|
||||||
Mocker.GetMock<EpisodeProvider>().Verify(p => p.SetSeasonIgnore(seriesId, 2, It.IsAny<Boolean>()), Times.Never());
|
Mocker.GetMock<SeasonProvider>().Verify(p => p.SetIgnore(seriesId, 2, It.IsAny<Boolean>()), Times.Never());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1020,122 +1020,6 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
Mocker.VerifyAllMocks();
|
Mocker.VerifyAllMocks();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void IgnoreSeason_Ignore()
|
|
||||||
{
|
|
||||||
WithRealDb();
|
|
||||||
|
|
||||||
var episodes = Builder<Episode>.CreateListOfSize(4)
|
|
||||||
.All()
|
|
||||||
.With(c => c.SeriesId = 10)
|
|
||||||
.With(c => c.SeasonNumber = 1)
|
|
||||||
.With(c => c.Ignored = false)
|
|
||||||
.Build().ToList();
|
|
||||||
|
|
||||||
episodes.ForEach(c => Db.Insert(c));
|
|
||||||
|
|
||||||
//Act
|
|
||||||
Mocker.Resolve<EpisodeProvider>().SetSeasonIgnore(10, 1, true);
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
var episodesInDb = Db.Fetch<Episode>(@"SELECT * FROM Episodes");
|
|
||||||
|
|
||||||
episodesInDb.Should().HaveCount(4);
|
|
||||||
episodesInDb.Where(e => e.Ignored).Should().HaveCount(4);
|
|
||||||
|
|
||||||
Mocker.VerifyAllMocks();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void IgnoreSeason_RemoveIgnore()
|
|
||||||
{
|
|
||||||
WithRealDb();
|
|
||||||
|
|
||||||
var episodes = Builder<Episode>.CreateListOfSize(4)
|
|
||||||
.All()
|
|
||||||
.With(c => c.SeriesId = 10)
|
|
||||||
.With(c => c.SeasonNumber = 1)
|
|
||||||
.With(c => c.Ignored = true)
|
|
||||||
.Build().ToList();
|
|
||||||
|
|
||||||
episodes.ForEach(c => Db.Insert(c));
|
|
||||||
|
|
||||||
//Act
|
|
||||||
Mocker.Resolve<EpisodeProvider>().SetSeasonIgnore(10, 1, false);
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
var episodesInDb = Db.Fetch<Episode>(@"SELECT * FROM Episodes");
|
|
||||||
|
|
||||||
episodesInDb.Should().HaveCount(4);
|
|
||||||
episodesInDb.Where(e => !e.Ignored).Should().HaveCount(4);
|
|
||||||
|
|
||||||
Mocker.VerifyAllMocks();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void IgnoreSeason_Ignore_Half()
|
|
||||||
{
|
|
||||||
WithRealDb();
|
|
||||||
|
|
||||||
var episodes = Builder<Episode>.CreateListOfSize(4)
|
|
||||||
.All()
|
|
||||||
.With(c => c.SeriesId = 10)
|
|
||||||
.With(c => c.SeasonNumber = 1)
|
|
||||||
.With(c => c.Ignored = true)
|
|
||||||
.TheFirst(2)
|
|
||||||
.With(c => c.Ignored = false)
|
|
||||||
.Build().ToList();
|
|
||||||
|
|
||||||
episodes.ForEach(c => Db.Insert(c));
|
|
||||||
|
|
||||||
//Act
|
|
||||||
Mocker.Resolve<EpisodeProvider>().SetSeasonIgnore(10, 1, true);
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
var episodesInDb = Db.Fetch<Episode>(@"SELECT * FROM Episodes");
|
|
||||||
|
|
||||||
episodesInDb.Should().HaveCount(4);
|
|
||||||
episodesInDb.Where(e => e.Ignored).Should().HaveCount(4);
|
|
||||||
|
|
||||||
Mocker.VerifyAllMocks();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void IgnoreSeason_should_call_SetIgnore_in_season_provider_one_time_only()
|
|
||||||
{
|
|
||||||
WithRealDb();
|
|
||||||
|
|
||||||
var episodes = Builder<Episode>.CreateListOfSize(4)
|
|
||||||
.All()
|
|
||||||
.With(c => c.SeriesId = 10)
|
|
||||||
.With(c => c.SeasonNumber = 1)
|
|
||||||
.With(c => c.Ignored = false)
|
|
||||||
.Build().ToList();
|
|
||||||
|
|
||||||
var season = new Season
|
|
||||||
{
|
|
||||||
SeriesId = 10,
|
|
||||||
SeasonNumber = 1,
|
|
||||||
Ignored = false
|
|
||||||
};
|
|
||||||
|
|
||||||
Db.Insert(season);
|
|
||||||
Db.InsertMany(episodes);
|
|
||||||
|
|
||||||
Mocker.GetMock<SeasonProvider>().Setup(s => s.SetIgnore(10, 1, true)).Verifiable();
|
|
||||||
|
|
||||||
//Act
|
|
||||||
Mocker.Resolve<EpisodeProvider>().SetSeasonIgnore(10, 1, true);
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
var episodesInDb = Db.Fetch<Episode>(@"SELECT * FROM Episodes");
|
|
||||||
|
|
||||||
episodesInDb.Should().HaveCount(4);
|
|
||||||
episodesInDb.Where(e => e.Ignored).Should().HaveCount(4);
|
|
||||||
|
|
||||||
Mocker.GetMock<SeasonProvider>().Verify(s => s.SetIgnore(10, 1, true), Times.Once());
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void EpisodesWithoutFiles_no_specials()
|
public void EpisodesWithoutFiles_no_specials()
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,13 +25,11 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
const int seriesId = 71663;
|
const int seriesId = 71663;
|
||||||
const int episodeCount = 10;
|
const int episodeCount = 10;
|
||||||
|
|
||||||
var tvDbSeries = Builder<TvdbSeries>.CreateNew().With(
|
var tvDbSeries = Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
||||||
c => c.Episodes =
|
|
||||||
new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
|
||||||
All()
|
All()
|
||||||
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
||||||
.Build())
|
.Build();
|
||||||
).With(c => c.Id = seriesId).Build();
|
|
||||||
|
|
||||||
var fakeSeries = Builder<Series>.CreateNew()
|
var fakeSeries = Builder<Series>.CreateNew()
|
||||||
.With(c => c.SeriesId = seriesId)
|
.With(c => c.SeriesId = seriesId)
|
||||||
|
@ -39,7 +37,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
|
|
||||||
var fakeEpisode = Builder<Episode>.CreateNew()
|
var fakeEpisode = Builder<Episode>.CreateNew()
|
||||||
.With(e => e.SeriesId = seriesId)
|
.With(e => e.SeriesId = seriesId)
|
||||||
.With(e => e.TvDbEpisodeId = tvDbSeries.Episodes.First().Id)
|
.With(e => e.TvDbEpisodeId = tvDbSeries.First().Id)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,13 +63,10 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
const int seriesId = 71663;
|
const int seriesId = 71663;
|
||||||
const int episodeCount = 10;
|
const int episodeCount = 10;
|
||||||
|
|
||||||
var tvDbSeries = Builder<TvdbSeries>.CreateNew().With(
|
var tvDbSeries = Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
||||||
c => c.Episodes =
|
|
||||||
new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
|
||||||
All()
|
All()
|
||||||
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
||||||
.Build())
|
.Build();
|
||||||
).With(c => c.Id = seriesId).Build();
|
|
||||||
|
|
||||||
var fakeSeries = Builder<Series>.CreateNew()
|
var fakeSeries = Builder<Series>.CreateNew()
|
||||||
.With(c => c.SeriesId = seriesId)
|
.With(c => c.SeriesId = seriesId)
|
||||||
|
@ -105,13 +100,10 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
const int seriesId = 71663;
|
const int seriesId = 71663;
|
||||||
const int episodeCount = 10;
|
const int episodeCount = 10;
|
||||||
|
|
||||||
var tvDbSeries = Builder<TvdbSeries>.CreateNew().With(
|
var tvDbSeries = Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
||||||
c => c.Episodes =
|
|
||||||
new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
|
||||||
All()
|
All()
|
||||||
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
||||||
.Build())
|
.Build();
|
||||||
).With(c => c.Id = seriesId).Build();
|
|
||||||
|
|
||||||
var fakeSeries = Builder<Series>.CreateNew()
|
var fakeSeries = Builder<Series>.CreateNew()
|
||||||
.With(c => c.SeriesId = seriesId)
|
.With(c => c.SeriesId = seriesId)
|
||||||
|
@ -145,13 +137,10 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
const int seriesId = 71663;
|
const int seriesId = 71663;
|
||||||
const int episodeCount = 10;
|
const int episodeCount = 10;
|
||||||
|
|
||||||
var tvDbSeries = Builder<TvdbSeries>.CreateNew().With(
|
var tvDbSeries = Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
||||||
c => c.Episodes =
|
|
||||||
new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
|
||||||
All()
|
All()
|
||||||
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
||||||
.Build())
|
.Build();
|
||||||
).With(c => c.Id = seriesId).Build();
|
|
||||||
|
|
||||||
var fakeSeries = Builder<Series>.CreateNew()
|
var fakeSeries = Builder<Series>.CreateNew()
|
||||||
.With(c => c.SeriesId = seriesId)
|
.With(c => c.SeriesId = seriesId)
|
||||||
|
@ -188,13 +177,10 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
const int seriesId = 71663;
|
const int seriesId = 71663;
|
||||||
const int episodeCount = 10;
|
const int episodeCount = 10;
|
||||||
|
|
||||||
var tvDbSeries = Builder<TvdbSeries>.CreateNew().With(
|
var tvDbSeries = Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
||||||
c => c.Episodes =
|
|
||||||
new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
|
||||||
All()
|
All()
|
||||||
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
||||||
.Build())
|
.Build();
|
||||||
).With(c => c.Id = seriesId).Build();
|
|
||||||
|
|
||||||
var fakeSeries = Builder<Series>.CreateNew()
|
var fakeSeries = Builder<Series>.CreateNew()
|
||||||
.With(c => c.SeriesId = seriesId)
|
.With(c => c.SeriesId = seriesId)
|
||||||
|
@ -236,5 +222,15 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
var result = db.Fetch<Episode>();
|
var result = db.Fetch<Episode>();
|
||||||
result.Should().HaveCount(1);
|
result.Should().HaveCount(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_not_do_anything_if_episode_list_is_empty()
|
||||||
|
{
|
||||||
|
WithStrictMocker();
|
||||||
|
|
||||||
|
var fakeSeries = Builder<Series>.CreateNew().Build();
|
||||||
|
|
||||||
|
Mocker.Resolve<EpisodeProvider>().DeleteEpisodesNotInTvdb(fakeSeries, new List<TvdbEpisode>());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,9 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
using FizzWare.NBuilder;
|
using FizzWare.NBuilder;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Common;
|
using NzbDrone.Common;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
|
@ -191,5 +192,20 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
result.Where(s => s.IsDaily).Should().HaveCount(3);
|
result.Where(s => s.IsDaily).Should().HaveCount(3);
|
||||||
result.Where(s => !s.IsDaily).Should().HaveCount(2);
|
result.Where(s => !s.IsDaily).Should().HaveCount(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void broken_service_should_not_cause_this_call_to_fail()
|
||||||
|
{
|
||||||
|
WithRealDb();
|
||||||
|
|
||||||
|
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(It.IsAny<string>()))
|
||||||
|
.Throws(new WebException())
|
||||||
|
.Verifiable();
|
||||||
|
|
||||||
|
Mocker.Resolve<ReferenceDataProvider>().UpdateDailySeries();
|
||||||
|
|
||||||
|
ExceptionVerification.ExpectedWarns(1);
|
||||||
|
Mocker.VerifyAllMocks();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,4 @@
|
||||||
// ReSharper disable RedundantUsingDirective
|
// ReSharper disable RedundantUsingDirective
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -25,89 +24,51 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
// ReSharper disable InconsistentNaming
|
// ReSharper disable InconsistentNaming
|
||||||
public class SeasonProviderTest : CoreTest
|
public class SeasonProviderTest : CoreTest
|
||||||
{
|
{
|
||||||
[Test]
|
[SetUp]
|
||||||
public void AddSeason_should_insert_season_to_database_with_ignored_false()
|
public void Setup()
|
||||||
{
|
{
|
||||||
WithRealDb();
|
WithRealDb();
|
||||||
|
|
||||||
var seriesId = 10;
|
|
||||||
var seasonNumber = 50;
|
|
||||||
|
|
||||||
//Act
|
|
||||||
Mocker.Resolve<SeasonProvider>().Add(seriesId, seasonNumber);
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
var result = Db.Fetch<Season>();
|
|
||||||
result.Should().HaveCount(1);
|
|
||||||
result.First().SeriesId.Should().Be(seriesId);
|
|
||||||
result.First().SeasonNumber.Should().Be(seasonNumber);
|
|
||||||
result.First().Ignored.Should().BeFalse();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[TestCase(true)]
|
[TestCase(true)]
|
||||||
[TestCase(false)]
|
[TestCase(false)]
|
||||||
public void AddSeason_should_insert_season_to_database_with_preset_ignored_status(bool isIgnored)
|
public void SetIgnore_should_update_ignored_status(bool ignoreFlag)
|
||||||
{
|
{
|
||||||
WithRealDb();
|
|
||||||
|
|
||||||
var seriesId = 10;
|
|
||||||
var seasonNumber = 50;
|
|
||||||
|
|
||||||
//Act
|
|
||||||
Mocker.Resolve<SeasonProvider>().Add(seriesId, seasonNumber, isIgnored);
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
var result = Db.Fetch<Season>();
|
|
||||||
result.Should().HaveCount(1);
|
|
||||||
result.First().SeriesId.Should().Be(seriesId);
|
|
||||||
result.First().SeasonNumber.Should().Be(seasonNumber);
|
|
||||||
result.First().Ignored.Should().Be(isIgnored);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void DeleteSeason_should_remove_season_from_database()
|
|
||||||
{
|
|
||||||
WithRealDb();
|
|
||||||
|
|
||||||
var fakeSeason = Builder<Season>.CreateNew().Build();
|
|
||||||
|
|
||||||
Db.Insert(fakeSeason);
|
|
||||||
|
|
||||||
//Act
|
|
||||||
Mocker.Resolve<SeasonProvider>().Delete(fakeSeason.SeriesId, fakeSeason.SeasonNumber);
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
var result = Db.Fetch<Season>();
|
|
||||||
result.Should().BeEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void SetIgnore_should_update_ignored_status()
|
|
||||||
{
|
|
||||||
WithRealDb();
|
|
||||||
|
|
||||||
var fakeSeason = Builder<Season>.CreateNew()
|
var fakeSeason = Builder<Season>.CreateNew()
|
||||||
.With(s => s.Ignored = false)
|
.With(s => s.Ignored = !ignoreFlag)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
var fakeEpisodes = Builder<Episode>.CreateListOfSize(4)
|
||||||
|
.All()
|
||||||
|
.With(c => c.SeriesId = fakeSeason.SeriesId)
|
||||||
|
.With(c => c.SeasonNumber = fakeSeason.SeasonId)
|
||||||
|
.With(c => c.Ignored = !ignoreFlag)
|
||||||
|
.Build().ToList();
|
||||||
|
|
||||||
|
fakeEpisodes.ForEach(c => Db.Insert(c));
|
||||||
|
|
||||||
var id = Db.Insert(fakeSeason);
|
var id = Db.Insert(fakeSeason);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
Mocker.Resolve<SeasonProvider>().SetIgnore(fakeSeason.SeriesId, fakeSeason.SeasonNumber, true);
|
Mocker.Resolve<SeasonProvider>().SetIgnore(fakeSeason.SeriesId, fakeSeason.SeasonNumber, ignoreFlag);
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
var result = Db.SingleOrDefault<Season>(id);
|
var season = Db.SingleOrDefault<Season>(id);
|
||||||
result.Ignored.Should().BeTrue();
|
season.Ignored.Should().Be(ignoreFlag);
|
||||||
|
|
||||||
|
var episodes = Db.Fetch<Episode>();
|
||||||
|
episodes.Should().HaveSameCount(fakeEpisodes);
|
||||||
|
episodes.Should().OnlyContain(c => c.Ignored == ignoreFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[TestCase(true)]
|
||||||
public void IsIgnored_should_return_ignored_status_of_season()
|
[TestCase(false)]
|
||||||
|
public void IsIgnored_should_return_ignored_status_of_season(bool ignoreFlag)
|
||||||
{
|
{
|
||||||
WithRealDb();
|
|
||||||
|
|
||||||
//Setup
|
//Setup
|
||||||
var fakeSeason = Builder<Season>.CreateNew()
|
var fakeSeason = Builder<Season>.CreateNew()
|
||||||
.With(s => s.Ignored = false)
|
.With(s => s.Ignored = ignoreFlag)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
Db.Insert(fakeSeason);
|
Db.Insert(fakeSeason);
|
||||||
|
@ -116,94 +77,13 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
var result = Mocker.Resolve<SeasonProvider>().IsIgnored(fakeSeason.SeriesId, fakeSeason.SeasonNumber);
|
var result = Mocker.Resolve<SeasonProvider>().IsIgnored(fakeSeason.SeriesId, fakeSeason.SeasonNumber);
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
result.Should().Be(fakeSeason.Ignored);
|
result.Should().Be(ignoreFlag);
|
||||||
Db.Fetch<Season>().Count.Should().Be(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void IsIgnored_should_return_true_if_not_in_db_and_is_season_zero()
|
public void IsIgnored_should_throw_an_exception_if_not_in_db()
|
||||||
{
|
{
|
||||||
//Setup
|
Assert.Throws<InvalidOperationException>(() => Mocker.Resolve<SeasonProvider>().IsIgnored(10, 0));
|
||||||
WithRealDb();
|
|
||||||
|
|
||||||
//Act
|
|
||||||
var result = Mocker.Resolve<SeasonProvider>().IsIgnored(10, 0);
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
result.Should().BeTrue();
|
|
||||||
Db.Fetch<Season>().Should().HaveCount(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void IsIgnored_should_return_false_if_not_in_db_and_is_season_one()
|
|
||||||
{
|
|
||||||
//Setup
|
|
||||||
WithRealDb();
|
|
||||||
|
|
||||||
//Act
|
|
||||||
var result = Mocker.Resolve<SeasonProvider>().IsIgnored(10, 1);
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
result.Should().BeFalse();
|
|
||||||
Db.Fetch<Season>().Should().HaveCount(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void IsIgnored_should_return_false_if_not_in_db_and_previous_season_is_not_ignored()
|
|
||||||
{
|
|
||||||
//Setup
|
|
||||||
WithRealDb();
|
|
||||||
|
|
||||||
var lastSeason = Builder<Season>.CreateNew()
|
|
||||||
.With(s => s.SeriesId = 10)
|
|
||||||
.With(s => s.SeasonNumber = 4)
|
|
||||||
.With(s => s.Ignored = false)
|
|
||||||
.Build();
|
|
||||||
|
|
||||||
Db.Insert(lastSeason);
|
|
||||||
|
|
||||||
//Act
|
|
||||||
var result = Mocker.Resolve<SeasonProvider>().IsIgnored(10, 5);
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
result.Should().BeFalse();
|
|
||||||
Db.Fetch<Season>().Should().HaveCount(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void IsIgnored_should_return_true_if_not_in_db_and_previous_season_is_ignored()
|
|
||||||
{
|
|
||||||
//Setup
|
|
||||||
WithRealDb();
|
|
||||||
|
|
||||||
var lastSeason = Builder<Season>.CreateNew()
|
|
||||||
.With(s => s.SeriesId = 10)
|
|
||||||
.With(s => s.SeasonNumber = 4)
|
|
||||||
.With(s => s.Ignored = true)
|
|
||||||
.Build();
|
|
||||||
|
|
||||||
Db.Insert(lastSeason);
|
|
||||||
|
|
||||||
//Act
|
|
||||||
var result = Mocker.Resolve<SeasonProvider>().IsIgnored(10, 5);
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
result.Should().BeTrue();
|
|
||||||
Db.Fetch<Season>().Should().HaveCount(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void IsIgnored_should_return_false_if_not_in_db_and_previous_season_does_not_exist()
|
|
||||||
{
|
|
||||||
//Setup
|
|
||||||
WithRealDb();
|
|
||||||
|
|
||||||
//Act
|
|
||||||
var result = Mocker.Resolve<SeasonProvider>().IsIgnored(10, 5);
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
result.Should().BeFalse();
|
|
||||||
Db.Fetch<Season>().Should().HaveCount(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -211,9 +91,6 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
{
|
{
|
||||||
const int seriesId = 10;
|
const int seriesId = 10;
|
||||||
|
|
||||||
//Setup
|
|
||||||
WithRealDb();
|
|
||||||
|
|
||||||
var season = Builder<Season>.CreateNew()
|
var season = Builder<Season>.CreateNew()
|
||||||
.With(s => s.SeriesId = seriesId)
|
.With(s => s.SeriesId = seriesId)
|
||||||
.With(s => s.SeasonNumber = 4)
|
.With(s => s.SeasonNumber = 4)
|
||||||
|
@ -272,10 +149,73 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
//Assert
|
//Assert
|
||||||
result.Should().HaveCount(5);
|
result.Should().HaveCount(5);
|
||||||
|
|
||||||
foreach(var season in result)
|
foreach (var season in result)
|
||||||
{
|
{
|
||||||
season.Episodes.Count.Should().Be(2);
|
season.Episodes.Count.Should().Be(2);
|
||||||
|
season.Episodes.Should().OnlyContain(c => c.SeasonNumber == season.SeasonNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void EnsureSeason_should_add_all_seasons_for_new_series()
|
||||||
|
{
|
||||||
|
var seasons = new[] { 0, 1, 2, 3, 4, 5 };
|
||||||
|
Mocker.Resolve<SeasonProvider>().EnsureSeasons(12, seasons);
|
||||||
|
|
||||||
|
Mocker.Resolve<SeasonProvider>().GetSeasons(12).SequenceEqual(seasons);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void EnsureSeason_should_add_missing_seasons()
|
||||||
|
{
|
||||||
|
var seasonsA = new[] { 0, 1, 2, 3 };
|
||||||
|
var seasonsB = new[] { 0, 1, 2, 3, 4, 5 };
|
||||||
|
Mocker.Resolve<SeasonProvider>().EnsureSeasons(12, seasonsA);
|
||||||
|
Mocker.Resolve<SeasonProvider>().GetSeasons(12).SequenceEqual(seasonsA);
|
||||||
|
|
||||||
|
Mocker.Resolve<SeasonProvider>().EnsureSeasons(12, seasonsB);
|
||||||
|
Mocker.Resolve<SeasonProvider>().GetSeasons(12).SequenceEqual(seasonsB);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void EnsureSeason_marks_season_zero_as_ignored()
|
||||||
|
{
|
||||||
|
var seasons = new[] { 0, 1, 2, 3 };
|
||||||
|
|
||||||
|
Mocker.Resolve<SeasonProvider>().EnsureSeasons(12, seasons);
|
||||||
|
Db.Fetch<Season>().Should().Contain(c => c.SeasonNumber == 0 && c.Ignored);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void EnsureSeason_none_zero_seasons_arent_ignored()
|
||||||
|
{
|
||||||
|
var seasons = new[] { 1, 2, 3 };
|
||||||
|
|
||||||
|
Mocker.Resolve<SeasonProvider>().EnsureSeasons(12, seasons);
|
||||||
|
Db.Fetch<Season>().Should().OnlyContain(c => c.Ignored == false);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void GetSeason_should_return_seasons_for_specified_series_only()
|
||||||
|
{
|
||||||
|
var seriesA = new[] { 1, 2, 3 };
|
||||||
|
var seriesB = new[] { 4, 5, 6 };
|
||||||
|
|
||||||
|
Mocker.Resolve<SeasonProvider>().EnsureSeasons(1, seriesA);
|
||||||
|
Mocker.Resolve<SeasonProvider>().EnsureSeasons(2, seriesB);
|
||||||
|
|
||||||
|
Mocker.Resolve<SeasonProvider>().GetSeasons(1).Should().Equal(seriesA);
|
||||||
|
Mocker.Resolve<SeasonProvider>().GetSeasons(2).Should().Equal(seriesB);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void GetSeason_should_return_emptylist_if_series_doesnt_exist()
|
||||||
|
{
|
||||||
|
Mocker.Resolve<SeasonProvider>().GetSeasons(1).Should().BeEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -817,5 +817,19 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
result.Last().Monitored.Should().Be(monitored);
|
result.Last().Monitored.Should().Be(monitored);
|
||||||
result.Last().SeasonFolder.Should().Be(seasonFolder);
|
result.Last().SeasonFolder.Should().Be(seasonFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void delete_series_should_delete_all_rows_related_to_the_series()
|
||||||
|
{
|
||||||
|
var fakeSeries = Builder<Series>.CreateListOfSize(3).Build();
|
||||||
|
var fakeEpisodes = Builder<Episode>.CreateListOfSize(30)
|
||||||
|
.TheFirst(10).With(c=>c.SeriesId = fakeSeries[0].SeriesId)
|
||||||
|
.TheNext(10).With(c=>c.SeriesId = fakeSeries[1].SeriesId)
|
||||||
|
.TheNext(10).With(c => c.SeriesId = fakeSeries[2].SeriesId)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} |