Fixed broken NewznabRequestGenerator tests

This commit is contained in:
Mark McDowall 2022-11-18 22:33:51 -08:00
parent 80af164385
commit c8dbbe431a
2 changed files with 23 additions and 19 deletions

View File

@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using FluentAssertions; using FluentAssertions;
using Moq; using Moq;
@ -36,6 +36,7 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
_animeSearchCriteria = new AnimeEpisodeSearchCriteria() _animeSearchCriteria = new AnimeEpisodeSearchCriteria()
{ {
Series = new Tv.Series { TvRageId = 10, TvdbId = 20, TvMazeId = 30, ImdbId = "t40" },
SceneTitles = new List<string>() { "Monkey+Island" }, SceneTitles = new List<string>() { "Monkey+Island" },
AbsoluteEpisodeNumber = 100, AbsoluteEpisodeNumber = 100,
SeasonNumber = 5, SeasonNumber = 5,
@ -80,11 +81,12 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
{ {
var results = Subject.GetSearchRequests(_animeSearchCriteria); var results = Subject.GetSearchRequests(_animeSearchCriteria);
results.GetAllTiers().Should().HaveCount(1); results.GetAllTiers().Should().HaveCount(2);
var page = results.GetAllTiers().First().First(); var pages = results.GetTier(0).Select(t => t.First()).ToList();
page.Url.FullUri.Should().Contain("&cat=3,4&"); pages[0].Url.FullUri.Should().Contain("&cat=3,4&");
pages[1].Url.FullUri.Should().Contain("&cat=3,4&");
} }
[Test] [Test]
@ -92,11 +94,10 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
{ {
var results = Subject.GetSearchRequests(_animeSearchCriteria); var results = Subject.GetSearchRequests(_animeSearchCriteria);
results.GetAllTiers().Should().HaveCount(1); results.GetAllTiers().Should().HaveCount(2);
var page = results.GetAllTiers().First().First(); results.GetAllTiers().First().First().Url.FullUri.Should().Contain("?t=tvsearch&");
results.GetAllTiers().Last().First().Url.FullUri.Should().Contain("?t=search&");
page.Url.FullUri.Should().Contain("?t=search&");
} }
[Test] [Test]
@ -104,7 +105,7 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
{ {
var results = Subject.GetSearchRequests(_animeSearchCriteria); var results = Subject.GetSearchRequests(_animeSearchCriteria);
results.GetAllTiers().Should().HaveCount(1); results.GetAllTiers().Should().HaveCount(2);
var pages = results.GetAllTiers().First().Take(3).ToList(); var pages = results.GetAllTiers().First().Take(3).ToList();
@ -118,7 +119,7 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
{ {
var results = Subject.GetSearchRequests(_animeSearchCriteria); var results = Subject.GetSearchRequests(_animeSearchCriteria);
results.GetAllTiers().Should().HaveCount(1); results.GetAllTiers().Should().HaveCount(2);
var pages = results.GetAllTiers().First().Take(500).ToList(); var pages = results.GetAllTiers().First().Take(500).ToList();
@ -130,11 +131,12 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
{ {
var results = Subject.GetSearchRequests(_animeSearchCriteria); var results = Subject.GetSearchRequests(_animeSearchCriteria);
results.GetAllTiers().Should().HaveCount(1); results.GetAllTiers().Should().HaveCount(2);
var page = results.GetAllTiers().First().First(); var pages = results.GetTier(0).Select(t => t.First()).ToList();
page.Url.FullUri.Should().Contain("q=Monkey%20Island+100"); pages[0].Url.FullUri.Should().Contain("rid=10&q=100");
pages[1].Url.FullUri.Should().Contain("q=Monkey%20Island+100");
} }
[Test] [Test]
@ -143,11 +145,13 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
Subject.Settings.AnimeStandardFormatSearch = true; Subject.Settings.AnimeStandardFormatSearch = true;
var results = Subject.GetSearchRequests(_animeSearchCriteria); var results = Subject.GetSearchRequests(_animeSearchCriteria);
results.GetTier(0).Should().HaveCount(2); results.GetTier(0).Should().HaveCount(4);
var pages = results.GetTier(0).Take(2).Select(t => t.First()).ToList(); var pages = results.GetTier(0).Select(t => t.First()).ToList();
pages[0].Url.FullUri.Should().Contain("q=Monkey%20Island+100"); pages[0].Url.FullUri.Should().Contain("rid=10&q=100");
pages[1].Url.FullUri.Should().Contain("q=Monkey%20Island&season=5&ep=4"); pages[1].Url.FullUri.Should().Contain("q=Monkey%20Island+100");
pages[2].Url.FullUri.Should().Contain("rid=10&season=5&ep=4");
pages[3].Url.FullUri.Should().Contain("q=Monkey%20Island&season=5&ep=4");
} }
[Test] [Test]

View File

@ -327,7 +327,7 @@ namespace NzbDrone.Core.Indexers.Newznab
foreach (var queryTitle in queryTitles) foreach (var queryTitle in queryTitles)
{ {
AddTvIdPageableRequests(pageableRequests, AddTvIdPageableRequests(pageableRequests,
Settings.Categories, Settings.AnimeCategories,
searchCriteria, searchCriteria,
$"&q={searchCriteria.AbsoluteEpisodeNumber:00}"); $"&q={searchCriteria.AbsoluteEpisodeNumber:00}");
@ -339,7 +339,7 @@ namespace NzbDrone.Core.Indexers.Newznab
if (Settings.AnimeStandardFormatSearch && searchCriteria.SeasonNumber > 0 && searchCriteria.EpisodeNumber > 0) if (Settings.AnimeStandardFormatSearch && searchCriteria.SeasonNumber > 0 && searchCriteria.EpisodeNumber > 0)
{ {
AddTvIdPageableRequests(pageableRequests, AddTvIdPageableRequests(pageableRequests,
Settings.Categories, Settings.AnimeCategories,
searchCriteria, searchCriteria,
$"&season={NewznabifySeasonNumber(searchCriteria.SeasonNumber)}&ep={searchCriteria.EpisodeNumber}"); $"&season={NewznabifySeasonNumber(searchCriteria.SeasonNumber)}&ep={searchCriteria.EpisodeNumber}");