mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-17 21:25:39 -04:00
Update Music Tests, Added Cases for Should Refresh Artist, Cleanup Skyhook Resources
This commit is contained in:
@@ -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.Music;
|
||||
using NzbDrone.Test.Common.Categories;
|
||||
|
||||
namespace NzbDrone.Core.Test.MetadataSource.SkyHook
|
||||
@@ -22,88 +22,75 @@ namespace NzbDrone.Core.Test.MetadataSource.SkyHook
|
||||
UseRealHttp();
|
||||
}
|
||||
|
||||
[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)
|
||||
[TestCase("f59c5520-5f46-4d2c-b2c4-822eabf53419", "Linkin Park")]
|
||||
[TestCase("66c662b6-6e2f-4930-8610-912e24c63ed1", "AC/DC")]
|
||||
public void should_be_able_to_get_artist_detail(string mbId, string name)
|
||||
{
|
||||
var details = Subject.GetSeriesInfo(tvdbId);
|
||||
var details = Subject.GetArtistInfo(mbId);
|
||||
|
||||
ValidateSeries(details.Item1);
|
||||
ValidateEpisodes(details.Item2);
|
||||
ValidateArtist(details.Item1);
|
||||
ValidateAlbums(details.Item2);
|
||||
|
||||
details.Item1.Title.Should().Be(title);
|
||||
details.Item1.Name.Should().Be(name);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void getting_details_of_invalid_series()
|
||||
public void getting_details_of_invalid_artist()
|
||||
{
|
||||
Assert.Throws<SeriesNotFoundException>(() => Subject.GetSeriesInfo(int.MaxValue));
|
||||
Assert.Throws<ArtistNotFoundException>(() => Subject.GetArtistInfo("aaaaaa-aaa-aaaa-aaaa"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_have_period_at_start_of_title_slug()
|
||||
public void should_not_have_period_at_start_of_name_slug()
|
||||
{
|
||||
var details = Subject.GetSeriesInfo(79099);
|
||||
var details = Subject.GetArtistInfo("f59c5520-5f46-4d2c-b2c4-822eabf53419");
|
||||
|
||||
details.Item1.TitleSlug.Should().Be("dothack");
|
||||
details.Item1.NameSlug.Should().Be("dothack");
|
||||
}
|
||||
|
||||
private void ValidateSeries(Series series)
|
||||
private void ValidateArtist(Artist artist)
|
||||
{
|
||||
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();
|
||||
artist.Should().NotBeNull();
|
||||
artist.Name.Should().NotBeNullOrWhiteSpace();
|
||||
artist.CleanName.Should().Be(Parser.Parser.CleanSeriesTitle(artist.Name));
|
||||
artist.SortName.Should().Be(Parser.Parser.NormalizeTitle(artist.Name));
|
||||
artist.Overview.Should().NotBeNullOrWhiteSpace();
|
||||
artist.Images.Should().NotBeEmpty();
|
||||
artist.NameSlug.Should().NotBeNullOrWhiteSpace();
|
||||
//series.TvRageId.Should().BeGreaterThan(0);
|
||||
series.TvdbId.Should().BeGreaterThan(0);
|
||||
artist.ForeignArtistId.Should().NotBeNullOrWhiteSpace();
|
||||
}
|
||||
|
||||
private void ValidateEpisodes(List<Episode> episodes)
|
||||
private void ValidateAlbums(List<Album> albums)
|
||||
{
|
||||
episodes.Should().NotBeEmpty();
|
||||
albums.Should().NotBeEmpty();
|
||||
|
||||
var episodeGroup = episodes.GroupBy(e => e.SeasonNumber.ToString("000") + e.EpisodeNumber.ToString("000"));
|
||||
var episodeGroup = albums.GroupBy(e => e.AlbumType + e.Title);
|
||||
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)
|
||||
foreach (var episode in albums)
|
||||
{
|
||||
ValidateEpisode(episode);
|
||||
ValidateAlbum(episode);
|
||||
|
||||
//if atleast one episdoe has title it means parse it working.
|
||||
episodes.Should().Contain(c => !string.IsNullOrWhiteSpace(c.Title));
|
||||
//if atleast one album has title it means parse it working.
|
||||
albums.Should().Contain(c => !string.IsNullOrWhiteSpace(c.Title));
|
||||
}
|
||||
}
|
||||
|
||||
private void ValidateEpisode(Episode episode)
|
||||
private void ValidateAlbum(Album album)
|
||||
{
|
||||
episode.Should().NotBeNull();
|
||||
album.Should().NotBeNull();
|
||||
|
||||
album.Title.Should().NotBeNullOrWhiteSpace();
|
||||
album.AlbumType.Should().NotBeNullOrWhiteSpace();
|
||||
|
||||
//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);
|
||||
album.Should().NotBeNull();
|
||||
|
||||
episode.Should().NotBeNull();
|
||||
|
||||
if (episode.AirDateUtc.HasValue)
|
||||
if (album.ReleaseDate.HasValue)
|
||||
{
|
||||
episode.AirDateUtc.Value.Kind.Should().Be(DateTimeKind.Utc);
|
||||
album.ReleaseDate.Value.Kind.Should().Be(DateTimeKind.Utc);
|
||||
}
|
||||
|
||||
episode.Images.Any(i => i.CoverType == MediaCoverTypes.Screenshot && i.Url.Contains("-940."))
|
||||
.Should()
|
||||
.BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user