1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-09 04:22:30 +01:00

Fixed a big where Season 0 wasn't being ignored for new seasons + a test to confirm it.

This commit is contained in:
Mark McDowall 2011-11-30 00:21:18 -08:00
parent bae2cdc1c7
commit fbc0a561ca
2 changed files with 45 additions and 4 deletions

View File

@ -414,6 +414,46 @@ public void RefreshEpisodeInfo_ignore_episode_zero()
result.Where(e => e.EpisodeNumber == 0 && e.SeasonNumber == 15).Single().Ignored.Should().BeTrue();
}
[Test]
public void RefreshEpisodeInfo_ignore_season_zero()
{
//Arrange
const int seriesId = 71663;
const int episodeCount = 10;
var fakeEpisodes = Builder<TvdbSeries>.CreateNew().With(
c => c.Episodes =
new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
All()
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
.With(e => e.SeasonNumber = 0)
.Build())
).With(c => c.Id = seriesId).Build();
var fakeSeries = Builder<Series>.CreateNew().With(c => c.SeriesId = seriesId).Build();
var mocker = new AutoMoqer();
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
db.Insert(fakeSeries);
mocker.GetMock<TvDbProvider>()
.Setup(c => c.GetSeries(seriesId, true))
.Returns(fakeEpisodes);
//Act
mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
//Assert
var result = mocker.Resolve<EpisodeProvider>().GetEpisodeBySeries(seriesId).ToList();
mocker.GetMock<TvDbProvider>().VerifyAll();
result.Should().HaveCount(episodeCount);
result.Where(e => e.Ignored).Should().HaveCount(episodeCount);
}
[Test]
public void new_episodes_only_calls_Insert()
{

View File

@ -278,12 +278,13 @@ public virtual void RefreshEpisodeInfo(Series series)
episodeToUpdate = new Episode();
newList.Add(episodeToUpdate);
//We need to check if this episode should be ignored based on IsIgnored rules
IsIgnored(series.SeriesId, episode.SeasonNumber);
//If it is Episode Zero Ignore it, since it is new
if (episode.EpisodeNumber == 0)
episodeToUpdate.Ignored = true;
//Else we need to check if this episode should be ignored based on IsIgnored rules
else
episodeToUpdate.Ignored = IsIgnored(series.SeriesId, episode.SeasonNumber);
}
else
@ -436,7 +437,7 @@ public virtual void DeleteInvalidEpisodes(Series series, TvdbSeries tvDbSeriesIn
var tvDbIdQuery = String.Format("DELETE FROM Episodes WHERE SeriesId = {0} AND TvDbEpisodeId > 0 AND TvDbEpisodeId NOT IN ({1})",
series.SeriesId, tvDbIdString);
Logger.Trace("Deleting nivalid episodes by TvDbId for {0}", series.SeriesId);
Logger.Trace("Deleting invalid episodes by TvDbId for {0}", series.SeriesId);
_database.Execute(tvDbIdQuery);
Logger.Trace("Finished deleting invalid episodes for {0}", series.SeriesId);