Added: A Huge Cleanup of old Series Code. (Let's pray nothing breaks :P) (#2589)

This commit is contained in:
Qstick
2018-03-14 16:41:36 -04:00
committed by Leonardo Galli
parent 8a6d67a6d7
commit 25e10e26e3
551 changed files with 2835 additions and 18867 deletions
@@ -1,27 +1,27 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.MetadataSource;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Movies;
namespace NzbDrone.Core.Test.MetadataSource
{
[TestFixture]
public class SearchSeriesComparerFixture : CoreTest
public class SearchMovieComparerFixture : CoreTest
{
private List<Series> _series;
private List<Movie> _series;
[SetUp]
public void Setup()
{
_series = new List<Series>();
_series = new List<Movie>();
}
private void WithSeries(string title)
{
_series.Add(new Series { Title = title });
_series.Add(new Movie { Title = title });
}
[Test]
@@ -30,7 +30,7 @@ namespace NzbDrone.Core.Test.MetadataSource
WithSeries("Talking Dead");
WithSeries("The Walking Dead");
_series.Sort(new SearchSeriesComparer("the walking dead"));
_series.Sort(new SearchMovieComparer("the walking dead"));
_series.First().Title.Should().Be("The Walking Dead");
}
@@ -41,7 +41,7 @@ namespace NzbDrone.Core.Test.MetadataSource
WithSeries("Talking Dead");
WithSeries("The Walking Dead");
_series.Sort(new SearchSeriesComparer("walking dead"));
_series.Sort(new SearchMovieComparer("walking dead"));
_series.First().Title.Should().Be("The Walking Dead");
}
@@ -52,7 +52,7 @@ namespace NzbDrone.Core.Test.MetadataSource
WithSeries("The Blacklist");
WithSeries("Blacklist");
_series.Sort(new SearchSeriesComparer("blacklist"));
_series.Sort(new SearchMovieComparer("blacklist"));
_series.First().Title.Should().Be("Blacklist");
}
@@ -63,7 +63,7 @@ namespace NzbDrone.Core.Test.MetadataSource
WithSeries("Blacklist");
WithSeries("The Blacklist");
_series.Sort(new SearchSeriesComparer("the blacklist"));
_series.Sort(new SearchMovieComparer("the blacklist"));
_series.First().Title.Should().Be("The Blacklist");
}
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using FluentAssertions;
@@ -7,7 +7,7 @@ using NzbDrone.Core.Exceptions;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MetadataSource.SkyHook;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Movies;
using NzbDrone.Test.Common.Categories;
namespace NzbDrone.Core.Test.MetadataSource.SkyHook
@@ -25,85 +25,44 @@ namespace NzbDrone.Core.Test.MetadataSource.SkyHook
[TestCase(75978, "Family Guy")]
[TestCase(83462, "Castle (2009)")]
[TestCase(266189, "The Blacklist")]
public void should_be_able_to_get_series_detail(int tvdbId, string title)
public void should_be_able_to_get_movie_detail(int tmdbId, string title)
{
var details = Subject.GetSeriesInfo(tvdbId);
var details = Subject.GetMovieInfo(tmdbId);
ValidateSeries(details.Item1);
ValidateEpisodes(details.Item2);
ValidateMovie(details);
details.Item1.Title.Should().Be(title);
details.Title.Should().Be(title);
}
[Test]
public void getting_details_of_invalid_series()
{
Assert.Throws<SeriesNotFoundException>(() => Subject.GetSeriesInfo(int.MaxValue));
Assert.Throws<MovieNotFoundException>(() => Subject.GetMovieInfo(int.MaxValue));
}
[Test]
public void should_not_have_period_at_start_of_title_slug()
{
var details = Subject.GetSeriesInfo(79099);
var details = Subject.GetMovieInfo(79099);
details.Item1.TitleSlug.Should().Be("dothack");
details.TitleSlug.Should().Be("dothack");
}
private void ValidateSeries(Series series)
private void ValidateMovie(Movie movie)
{
series.Should().NotBeNull();
series.Title.Should().NotBeNullOrWhiteSpace();
series.CleanTitle.Should().Be(Parser.Parser.CleanSeriesTitle(series.Title));
series.SortTitle.Should().Be(SeriesTitleNormalizer.Normalize(series.Title, series.TvdbId));
series.Overview.Should().NotBeNullOrWhiteSpace();
series.AirTime.Should().NotBeNullOrWhiteSpace();
series.FirstAired.Should().HaveValue();
series.FirstAired.Value.Kind.Should().Be(DateTimeKind.Utc);
series.Images.Should().NotBeEmpty();
series.ImdbId.Should().NotBeNullOrWhiteSpace();
series.Network.Should().NotBeNullOrWhiteSpace();
series.Runtime.Should().BeGreaterThan(0);
series.TitleSlug.Should().NotBeNullOrWhiteSpace();
movie.Should().NotBeNull();
movie.Title.Should().NotBeNullOrWhiteSpace();
movie.CleanTitle.Should().Be(Parser.Parser.CleanSeriesTitle(movie.Title));
movie.SortTitle.Should().Be(MovieTitleNormalizer.Normalize(movie.Title, movie.TmdbId));
movie.Overview.Should().NotBeNullOrWhiteSpace();
movie.PhysicalRelease.Should().HaveValue();
movie.Images.Should().NotBeEmpty();
movie.ImdbId.Should().NotBeNullOrWhiteSpace();
movie.Studio.Should().NotBeNullOrWhiteSpace();
movie.Runtime.Should().BeGreaterThan(0);
movie.TitleSlug.Should().NotBeNullOrWhiteSpace();
//series.TvRageId.Should().BeGreaterThan(0);
series.TvdbId.Should().BeGreaterThan(0);
}
private void ValidateEpisodes(List<Episode> episodes)
{
episodes.Should().NotBeEmpty();
var episodeGroup = episodes.GroupBy(e => e.SeasonNumber.ToString("000") + e.EpisodeNumber.ToString("000"));
episodeGroup.Should().OnlyContain(c => c.Count() == 1);
episodes.Should().Contain(c => c.SeasonNumber > 0);
episodes.Should().Contain(c => !string.IsNullOrWhiteSpace(c.Overview));
foreach (var episode in episodes)
{
ValidateEpisode(episode);
//if atleast one episdoe has title it means parse it working.
episodes.Should().Contain(c => !string.IsNullOrWhiteSpace(c.Title));
}
}
private void ValidateEpisode(Episode episode)
{
episode.Should().NotBeNull();
//TODO: Is there a better way to validate that episode number or season number is greater than zero?
(episode.EpisodeNumber + episode.SeasonNumber).Should().NotBe(0);
episode.Should().NotBeNull();
if (episode.AirDateUtc.HasValue)
{
episode.AirDateUtc.Value.Kind.Should().Be(DateTimeKind.Utc);
}
episode.Images.Any(i => i.CoverType == MediaCoverTypes.Screenshot && i.Url.Contains("-940."))
.Should()
.BeFalse();
movie.TmdbId.Should().BeGreaterThan(0);
}
}
}
@@ -1,4 +1,4 @@
using FluentAssertions;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.MetadataSource.SkyHook;
using NzbDrone.Core.Test.Framework;
@@ -25,12 +25,12 @@ namespace NzbDrone.Core.Test.MetadataSource.SkyHook
//[TestCase("Rob & Big", "Rob & Big")]
[TestCase("M*A*S*H", "M*A*S*H")]
//[TestCase("imdb:tt0436992", "Doctor Who (2005)")]
[TestCase("tvdb:78804", "Doctor Who (2005)")]
[TestCase("tvdbid:78804", "Doctor Who (2005)")]
[TestCase("tvdbid: 78804 ", "Doctor Who (2005)")]
[TestCase("tmdb:78804", "Doctor Who (2005)")]
[TestCase("tmdbid:78804", "Doctor Who (2005)")]
[TestCase("tmdbid: 78804 ", "Doctor Who (2005)")]
public void successful_search(string title, string expected)
{
var result = Subject.SearchForNewSeries(title);
var result = Subject.SearchForNewMovie(title);
result.Should().NotBeEmpty();
@@ -39,15 +39,15 @@ namespace NzbDrone.Core.Test.MetadataSource.SkyHook
ExceptionVerification.IgnoreWarns();
}
[TestCase("tvdbid:")]
[TestCase("tvdbid: 99999999999999999999")]
[TestCase("tvdbid: 0")]
[TestCase("tvdbid: -12")]
[TestCase("tvdbid:289578")]
[TestCase("tmdbid:")]
[TestCase("tmdbid: 99999999999999999999")]
[TestCase("tmdbid: 0")]
[TestCase("tmdbid: -12")]
[TestCase("tmdbid:289578")]
[TestCase("adjalkwdjkalwdjklawjdlKAJD;EF")]
public void no_search_result(string term)
{
var result = Subject.SearchForNewSeries(term);
var result = Subject.SearchForNewMovie(term);
result.Should().BeEmpty();
ExceptionVerification.IgnoreWarns();