Newznab Indexer Tests

Newznab Indexer Tests
pull/18/head
Qstick 8 years ago
parent f72afba764
commit 5b22e5a9ae

@ -9,15 +9,11 @@
<audio-search available="yes"/> <audio-search available="yes"/>
</searching> </searching>
<categories> <categories>
<category id="5000" name="TV"> <category id="3000" name="Audio">
<subcat id="5070" name="Anime"/> <subcat id="3010" name="MP3" description="Audio"/>
<subcat id="5080" name="Documentary"/> <subcat id="3020" name="Video" description="Audio"/>
<subcat id="5020" name="Foreign"/> <subcat id="3030" name="Audiobook" description="Audio"/>
<subcat id="5040" name="HD"/> <subcat id="3040" name="Lossless" description="Audio"/>
<subcat id="5050" name="Other"/>
<subcat id="5030" name="SD"/>
<subcat id="5060" name="Sport"/>
<subcat id="5010" name="WEB-DL"/>
</category> </category>
<category id="7000" name="Other"> <category id="7000" name="Other">
<subcat id="7010" name="Misc"/> <subcat id="7010" name="Misc"/>

@ -89,7 +89,7 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
[Test] [Test]
public void should_not_throw_on_xml_data_unexpected() public void should_not_throw_on_xml_data_unexpected()
{ {
GivenCapsResponse(_caps.Replace("5030", "asdf")); GivenCapsResponse(_caps.Replace("3040", "asdf"));
var result = Subject.GetCapabilities(_settings); var result = Subject.GetCapabilities(_settings);

@ -50,15 +50,15 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
var releaseInfo = releases.First(); var releaseInfo = releases.First();
releaseInfo.Title.Should().Be("White.Collar.S03E05.720p.HDTV.X264-DIMENSION"); releaseInfo.Title.Should().Be("Brainstorm-Scary Creatures-CD-FLAC-2016-NBFLAC");
releaseInfo.DownloadProtocol.Should().Be(DownloadProtocol.Usenet); releaseInfo.DownloadProtocol.Should().Be(DownloadProtocol.Usenet);
releaseInfo.DownloadUrl.Should().Be("http://nzb.su/getnzb/24967ef4c2e26296c65d3bbfa97aa8fe.nzb&i=37292&r=xxx"); releaseInfo.DownloadUrl.Should().Be("https://api.nzbgeek.info/api?t=get&id=38884827e1e56b9336278a449e0a38ec&apikey=xxx");
releaseInfo.InfoUrl.Should().Be("http://nzb.su/details/24967ef4c2e26296c65d3bbfa97aa8fe"); releaseInfo.InfoUrl.Should().Be("https://nzbgeek.info/geekseek.php?guid=38884827e1e56b9336278a449e0a38ec");
releaseInfo.CommentUrl.Should().Be("http://nzb.su/details/24967ef4c2e26296c65d3bbfa97aa8fe#comments"); releaseInfo.CommentUrl.Should().Be("https://nzbgeek.info/geekseek.php?guid=38884827e1e56b9336278a449e0a38ec");
releaseInfo.IndexerId.Should().Be(Subject.Definition.Id); releaseInfo.IndexerId.Should().Be(Subject.Definition.Id);
releaseInfo.Indexer.Should().Be(Subject.Definition.Name); releaseInfo.Indexer.Should().Be(Subject.Definition.Name);
releaseInfo.PublishDate.Should().Be(DateTime.Parse("2012/02/27 16:09:39")); releaseInfo.PublishDate.Should().Be(DateTime.Parse("2017/05/26 05:54:31"));
releaseInfo.Size.Should().Be(1183105773); releaseInfo.Size.Should().Be(492735000);
} }
[Test] [Test]

@ -12,6 +12,7 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
public class NewznabRequestGeneratorFixture : CoreTest<NewznabRequestGenerator> public class NewznabRequestGeneratorFixture : CoreTest<NewznabRequestGenerator>
{ {
private SingleEpisodeSearchCriteria _singleEpisodeSearchCriteria; private SingleEpisodeSearchCriteria _singleEpisodeSearchCriteria;
private AlbumSearchCriteria _singleAlbumSearchCriteria;
private AnimeEpisodeSearchCriteria _animeSearchCriteria; private AnimeEpisodeSearchCriteria _animeSearchCriteria;
private NewznabCapabilities _capabilities; private NewznabCapabilities _capabilities;
@ -22,7 +23,7 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
{ {
Url = "http://127.0.0.1:1234/", Url = "http://127.0.0.1:1234/",
Categories = new [] { 1, 2 }, Categories = new [] { 1, 2 },
AnimeCategories = new [] { 3, 4 }, //AnimeCategories = new [] { 3, 4 },
ApiKey = "abcd", ApiKey = "abcd",
}; };
@ -34,6 +35,13 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
EpisodeNumber = 2 EpisodeNumber = 2
}; };
_singleAlbumSearchCriteria = new AlbumSearchCriteria
{
Artist = new Music.Artist { Name = "Alien Ant Farm" },
Album = new Music.Album { Title = "TruANT" }
};
_animeSearchCriteria = new AnimeEpisodeSearchCriteria() _animeSearchCriteria = new AnimeEpisodeSearchCriteria()
{ {
SceneTitles = new List<string>() { "Monkey+Island" }, SceneTitles = new List<string>() { "Monkey+Island" },
@ -56,212 +64,228 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
var page = results.GetAllTiers().First().First(); var page = results.GetAllTiers().First().First();
page.Url.Query.Should().Contain("&cat=1,2,3,4&"); page.Url.Query.Should().Contain("&cat=1,2&");
} }
[Test] //We dont use Anime Categories so there is no need to check for proper concat in feed
public void should_not_have_duplicate_categories()
{
Subject.Settings.Categories = new[] { 1, 2, 3 };
var results = Subject.GetRecentRequests(); //[Test]
//public void should_not_have_duplicate_categories()
//{
// Subject.Settings.Categories = new[] { 1, 2, 3 };
results.GetAllTiers().Should().HaveCount(1); // var results = Subject.GetRecentRequests();
var page = results.GetAllTiers().First().First(); // results.GetAllTiers().Should().HaveCount(1);
page.Url.FullUri.Should().Contain("&cat=1,2,3,4&"); // var page = results.GetAllTiers().First().First();
}
[Test] // page.Url.FullUri.Should().Contain("&cat=1,2,3,4&");
public void should_use_only_anime_categories_for_anime_search() //}
{
var results = Subject.GetSearchRequests(_animeSearchCriteria);
results.GetAllTiers().Should().HaveCount(1); //[Test]
//public void should_use_only_anime_categories_for_anime_search()
//{
// var results = Subject.GetSearchRequests(_animeSearchCriteria);
var page = results.GetAllTiers().First().First(); // results.GetAllTiers().Should().HaveCount(1);
page.Url.FullUri.Should().Contain("&cat=3,4&"); // var page = results.GetAllTiers().First().First();
}
[Test] // page.Url.FullUri.Should().Contain("&cat=3,4&");
public void should_use_mode_search_for_anime() //}
{
var results = Subject.GetSearchRequests(_animeSearchCriteria);
results.GetAllTiers().Should().HaveCount(1); //[Test]
//public void should_use_mode_search_for_anime()
//{
// var results = Subject.GetSearchRequests(_animeSearchCriteria);
var page = results.GetAllTiers().First().First(); // results.GetAllTiers().Should().HaveCount(1);
page.Url.FullUri.Should().Contain("?t=search&"); // var page = results.GetAllTiers().First().First();
}
[Test] // page.Url.FullUri.Should().Contain("?t=search&");
public void should_return_subsequent_pages() //}
{
var results = Subject.GetSearchRequests(_animeSearchCriteria);
results.GetAllTiers().Should().HaveCount(1); //[Test]
//public void should_return_subsequent_pages()
//{
// var results = Subject.GetSearchRequests(_animeSearchCriteria);
var pages = results.GetAllTiers().First().Take(3).ToList(); // results.GetAllTiers().Should().HaveCount(1);
pages[0].Url.FullUri.Should().Contain("&offset=0&"); // var pages = results.GetAllTiers().First().Take(3).ToList();
pages[1].Url.FullUri.Should().Contain("&offset=100&");
pages[2].Url.FullUri.Should().Contain("&offset=200&");
}
[Test] // pages[0].Url.FullUri.Should().Contain("&offset=0&");
public void should_not_get_unlimited_pages() // pages[1].Url.FullUri.Should().Contain("&offset=100&");
{ // pages[2].Url.FullUri.Should().Contain("&offset=200&");
var results = Subject.GetSearchRequests(_animeSearchCriteria); //}
results.GetAllTiers().Should().HaveCount(1); //[Test]
//public void should_not_get_unlimited_pages()
//{
// var results = Subject.GetSearchRequests(_animeSearchCriteria);
var pages = results.GetAllTiers().First().Take(500).ToList(); // results.GetAllTiers().Should().HaveCount(1);
pages.Count.Should().BeLessThan(500); // var pages = results.GetAllTiers().First().Take(500).ToList();
}
[Test] // pages.Count.Should().BeLessThan(500);
public void should_not_search_by_rid_if_not_supported() //}
{
_capabilities.SupportedTvSearchParameters = new[] { "q", "season", "ep" };
var results = Subject.GetSearchRequests(_singleEpisodeSearchCriteria); //[Test]
//public void should_not_search_by_rid_if_not_supported()
//{
// _capabilities.SupportedAudioSearchParameters = new[] { "q", "artist", "album" };
results.GetAllTiers().Should().HaveCount(1); // var results = Subject.GetSearchRequests(_singleAlbumSearchCriteria);
var page = results.GetAllTiers().First().First(); // results.GetAllTiers().Should().HaveCount(1);
page.Url.Query.Should().NotContain("rid=10"); // var page = results.GetAllTiers().First().First();
page.Url.Query.Should().Contain("q=Monkey");
}
[Test] // page.Url.Query.Should().NotContain("rid=10");
public void should_search_by_rid_if_supported() // page.Url.Query.Should().Contain("q=Monkey");
{ //}
var results = Subject.GetSearchRequests(_singleEpisodeSearchCriteria);
results.GetTier(0).Should().HaveCount(1);
var page = results.GetAllTiers().First().First(); //[Test]
//public void should_search_by_rid_if_supported()
//{
// var results = Subject.GetSearchRequests(_singleAlbumSearchCriteria);
// results.GetTier(0).Should().HaveCount(1);
page.Url.Query.Should().Contain("rid=10"); // var page = results.GetAllTiers().First().First();
}
[Test] // page.Url.Query.Should().Contain("rid=10");
public void should_not_search_by_tvdbid_if_not_supported() //}
{
_capabilities.SupportedTvSearchParameters = new[] { "q", "season", "ep" };
var results = Subject.GetSearchRequests(_singleEpisodeSearchCriteria); //[Test]
results.GetTier(0).Should().HaveCount(1); //public void should_not_search_by_tvdbid_if_not_supported()
//{
// _capabilities.SupportedTvSearchParameters = new[] { "q", "season", "ep" };
var page = results.GetAllTiers().First().First(); // var results = Subject.GetSearchRequests(_singleEpisodeSearchCriteria);
// results.GetTier(0).Should().HaveCount(1);
page.Url.Query.Should().NotContain("rid=10"); // var page = results.GetAllTiers().First().First();
page.Url.Query.Should().Contain("q=Monkey");
}
[Test] // page.Url.Query.Should().NotContain("rid=10");
public void should_search_by_tvdbid_if_supported() // page.Url.Query.Should().Contain("q=Monkey");
{ //}
_capabilities.SupportedTvSearchParameters = new[] { "q", "tvdbid", "season", "ep" };
var results = Subject.GetSearchRequests(_singleEpisodeSearchCriteria); //[Test]
results.GetTier(0).Should().HaveCount(1); //public void should_search_by_tvdbid_if_supported()
//{
// _capabilities.SupportedTvSearchParameters = new[] { "q", "tvdbid", "season", "ep" };
var page = results.GetAllTiers().First().First(); // var results = Subject.GetSearchRequests(_singleEpisodeSearchCriteria);
// results.GetTier(0).Should().HaveCount(1);
page.Url.Query.Should().Contain("tvdbid=20"); // var page = results.GetAllTiers().First().First();
}
// page.Url.Query.Should().Contain("tvdbid=20");
//}
[Test] [Test]
public void should_search_by_tvmaze_if_supported() public void should_search_by_artist_and_album_if_supported()
{ {
_capabilities.SupportedTvSearchParameters = new[] { "q", "tvmazeid", "season", "ep" }; _capabilities.SupportedAudioSearchParameters = new[] { "q", "artist", "album"};
var results = Subject.GetSearchRequests(_singleEpisodeSearchCriteria); var results = Subject.GetSearchRequests(_singleAlbumSearchCriteria);
results.GetTier(0).Should().HaveCount(1); results.GetTier(0).Should().HaveCount(1);
var page = results.GetAllTiers().First().First(); var page = results.GetAllTiers().First().First();
page.Url.Query.Should().Contain("tvmazeid=30"); page.Url.Query.Should().Contain("artist=Alien Ant Farm");
page.Url.Query.Should().Contain("album=TruANT");
} }
[Test] //[Test]
public void should_prefer_search_by_tvdbid_if_rid_supported() //public void should_search_by_tvmaze_if_supported()
{ //{
_capabilities.SupportedTvSearchParameters = new[] { "q", "tvdbid", "rid", "season", "ep" }; // _capabilities.SupportedTvSearchParameters = new[] { "q", "tvmazeid", "season", "ep" };
var results = Subject.GetSearchRequests(_singleEpisodeSearchCriteria); // var results = Subject.GetSearchRequests(_singleEpisodeSearchCriteria);
results.GetTier(0).Should().HaveCount(1); // results.GetTier(0).Should().HaveCount(1);
var page = results.GetAllTiers().First().First(); // var page = results.GetAllTiers().First().First();
page.Url.Query.Should().Contain("tvdbid=20"); // page.Url.Query.Should().Contain("tvmazeid=30");
page.Url.Query.Should().NotContain("rid=10"); //}
}
[Test] //[Test]
public void should_use_aggregrated_id_search_if_supported() //public void should_prefer_search_by_tvdbid_if_rid_supported()
{ //{
_capabilities.SupportedTvSearchParameters = new[] { "q", "tvdbid", "rid", "season", "ep" }; // _capabilities.SupportedTvSearchParameters = new[] { "q", "tvdbid", "rid", "season", "ep" };
_capabilities.SupportsAggregateIdSearch = true;
var results = Subject.GetSearchRequests(_singleEpisodeSearchCriteria); // var results = Subject.GetSearchRequests(_singleEpisodeSearchCriteria);
results.GetTier(0).Should().HaveCount(1); // results.GetTier(0).Should().HaveCount(1);
var page = results.GetTier(0).First().First(); // var page = results.GetAllTiers().First().First();
page.Url.Query.Should().Contain("tvdbid=20"); // page.Url.Query.Should().Contain("tvdbid=20");
page.Url.Query.Should().Contain("rid=10"); // page.Url.Query.Should().NotContain("rid=10");
} //}
[Test] //[Test]
public void should_not_use_aggregrated_id_search_if_no_ids_supported() //public void should_use_aggregrated_id_search_if_supported()
{ //{
_capabilities.SupportedTvSearchParameters = new[] { "q", "season", "ep" }; // _capabilities.SupportedTvSearchParameters = new[] { "q", "tvdbid", "rid", "season", "ep" };
_capabilities.SupportsAggregateIdSearch = true; // Turns true if indexer supplies supportedParams. // _capabilities.SupportsAggregateIdSearch = true;
var results = Subject.GetSearchRequests(_singleEpisodeSearchCriteria); // var results = Subject.GetSearchRequests(_singleEpisodeSearchCriteria);
results.Tiers.Should().Be(1); // results.GetTier(0).Should().HaveCount(1);
results.GetTier(0).Should().HaveCount(1);
var page = results.GetTier(0).First().First(); // var page = results.GetTier(0).First().First();
page.Url.Query.Should().Contain("q="); // page.Url.Query.Should().Contain("tvdbid=20");
} // page.Url.Query.Should().Contain("rid=10");
//}
[Test] //[Test]
public void should_not_use_aggregrated_id_search_if_no_ids_are_known() //public void should_not_use_aggregrated_id_search_if_no_ids_supported()
{ //{
_capabilities.SupportedTvSearchParameters = new[] { "q", "rid", "season", "ep" }; // _capabilities.SupportedTvSearchParameters = new[] { "q", "season", "ep" };
_capabilities.SupportsAggregateIdSearch = true; // Turns true if indexer supplies supportedParams. // _capabilities.SupportsAggregateIdSearch = true; // Turns true if indexer supplies supportedParams.
_singleEpisodeSearchCriteria.Series.TvRageId = 0; // var results = Subject.GetSearchRequests(_singleEpisodeSearchCriteria);
// results.Tiers.Should().Be(1);
// results.GetTier(0).Should().HaveCount(1);
var results = Subject.GetSearchRequests(_singleEpisodeSearchCriteria); // var page = results.GetTier(0).First().First();
var page = results.GetTier(0).First().First(); // page.Url.Query.Should().Contain("q=");
//}
page.Url.Query.Should().Contain("q="); //[Test]
} //public void should_not_use_aggregrated_id_search_if_no_ids_are_known()
//{
// _capabilities.SupportedTvSearchParameters = new[] { "q", "rid", "season", "ep" };
// _capabilities.SupportsAggregateIdSearch = true; // Turns true if indexer supplies supportedParams.
[Test] // _singleEpisodeSearchCriteria.Series.TvRageId = 0;
public void should_fallback_to_q()
{
_capabilities.SupportedTvSearchParameters = new[] { "q", "tvdbid", "rid", "season", "ep" };
_capabilities.SupportsAggregateIdSearch = true;
var results = Subject.GetSearchRequests(_singleEpisodeSearchCriteria); // var results = Subject.GetSearchRequests(_singleEpisodeSearchCriteria);
results.Tiers.Should().Be(2);
var pageTier2 = results.GetTier(1).First().First(); // var page = results.GetTier(0).First().First();
pageTier2.Url.Query.Should().NotContain("tvdbid=20"); // page.Url.Query.Should().Contain("q=");
pageTier2.Url.Query.Should().NotContain("rid=10"); //}
pageTier2.Url.Query.Should().Contain("q=");
} //[Test]
//public void should_fallback_to_q()
//{
// _capabilities.SupportedAudioSearchParameters = new[] { "q", "artist", "album" };
// _capabilities.SupportsAggregateIdSearch = true;
// var results = Subject.GetSearchRequests(_singleAlbumSearchCriteria);
// results.Tiers.Should().Be(2);
// var pageTier2 = results.GetTier(1).First().First();
// pageTier2.Url.Query.Should().NotContain("artist=");
// pageTier2.Url.Query.Should().NotContain("album=");
// pageTier2.Url.Query.Should().Contain("q=");
//}
} }
} }

@ -58,6 +58,8 @@ namespace NzbDrone.Core.Indexers.Newznab
} }
} }
private bool SupportsTvdbSearch private bool SupportsTvdbSearch
{ {
get get
@ -113,9 +115,9 @@ namespace NzbDrone.Core.Indexers.Newznab
var capabilities = _capabilitiesProvider.GetCapabilities(Settings); var capabilities = _capabilitiesProvider.GetCapabilities(Settings);
if (capabilities.SupportedTvSearchParameters != null) if (capabilities.SupportedAudioSearchParameters != null)
{ {
pageableRequests.Add(GetPagedRequests(MaxPages, Settings.Categories.Concat(Settings.AnimeCategories), "tvsearch", "")); pageableRequests.Add(GetPagedRequests(MaxPages, Settings.Categories, "music", ""));
} }
return pageableRequests; return pageableRequests;

Loading…
Cancel
Save