Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/Jackett/Jackett
- Loading branch information
Showing
16 changed files
with
337 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
src/Jackett.Test/Common/Indexers/BaseWebIndexerTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
using System.Linq; | ||
using Jackett.Common.Models; | ||
using Jackett.Test.TestHelpers; | ||
using NUnit.Framework; | ||
using Assert = NUnit.Framework.Assert; | ||
|
||
namespace Jackett.Test.Common.Indexers | ||
{ | ||
[TestFixture] | ||
public class BaseWebIndexerTests | ||
{ | ||
[Test] | ||
public void TestConstructor() | ||
{ | ||
var indexer = new TestWebIndexer(); | ||
var caps = indexer.TorznabCaps; | ||
|
||
Assert.True(caps.SearchAvailable); | ||
Assert.IsEmpty(caps.TvSearchParams); | ||
Assert.False(caps.TvSearchAvailable); | ||
Assert.False(caps.TvSearchSeasonAvailable); | ||
Assert.False(caps.TvSearchEpAvailable); | ||
Assert.False(caps.TvSearchImdbAvailable); | ||
Assert.False(caps.TvSearchTvdbAvailable); | ||
Assert.False(caps.TvSearchTvRageAvailable); | ||
Assert.IsEmpty(caps.MovieSearchParams); | ||
Assert.False(caps.MovieSearchAvailable); | ||
Assert.False(caps.MovieSearchImdbAvailable); | ||
Assert.False(caps.MovieSearchTmdbAvailable); | ||
Assert.IsEmpty(caps.MusicSearchParams); | ||
Assert.False(caps.MusicSearchAvailable); | ||
Assert.False(caps.MusicSearchAlbumAvailable); | ||
Assert.False(caps.MusicSearchArtistAvailable); | ||
Assert.False(caps.MusicSearchLabelAvailable); | ||
Assert.False(caps.MusicSearchYearAvailable); | ||
Assert.IsEmpty(caps.BookSearchParams); | ||
Assert.False(caps.BookSearchAvailable); | ||
Assert.False(caps.BookSearchTitleAvailable); | ||
Assert.False(caps.BookSearchAuthorAvailable); | ||
Assert.AreEqual(0, caps.Categories.GetTorznabCategories().Count); | ||
} | ||
|
||
[Test] | ||
public void TestAddCategoryMapping() | ||
{ | ||
var indexer = new TestWebIndexer(); | ||
|
||
// you can find more complex tests in TorznabCapabilitiesCategoriesTests.cs | ||
indexer._AddCategoryMapping("11", TorznabCatType.MoviesSD, "MoviesSD"); | ||
Assert.AreEqual(2, indexer.TorznabCaps.Categories.GetTorznabCategories().Count); | ||
indexer._AddCategoryMapping(14, TorznabCatType.MoviesHD); | ||
Assert.AreEqual(3, indexer.TorznabCaps.Categories.GetTorznabCategories().Count); | ||
} | ||
|
||
[Test] | ||
public void TestAddMultiCategoryMapping() | ||
{ | ||
var indexer = new TestWebIndexer(); | ||
|
||
indexer._AddMultiCategoryMapping(TorznabCatType.MoviesHD,19, 18); | ||
Assert.AreEqual(1, indexer.TorznabCaps.Categories.GetTorznabCategories().Count); | ||
} | ||
|
||
[Test] | ||
public void TestMapTorznabCapsToTrackers() | ||
{ | ||
var indexer = new TestWebIndexer(); | ||
indexer.AddTestCategories(); | ||
|
||
var query = new TorznabQuery // int category with subcategories (parent cat) | ||
{ | ||
Categories = new [] { TorznabCatType.Movies.ID } | ||
}; | ||
var trackerCats = indexer._MapTorznabCapsToTrackers(query); | ||
Assert.AreEqual(2, trackerCats.Count); | ||
Assert.AreEqual("1", trackerCats[0]); // Movies | ||
Assert.AreEqual("mov_sd", trackerCats[1]); // Movies SD | ||
} | ||
|
||
[Test] | ||
public void TestMapTrackerCatToNewznab() | ||
{ | ||
var indexer = new TestWebIndexer(); | ||
indexer.AddTestCategories(); | ||
|
||
// TODO: this is wrong, custom cat 100001 doesn't exists (it's not defined by us) | ||
var torznabCats = indexer._MapTrackerCatToNewznab("1").ToList(); | ||
Assert.AreEqual(2, torznabCats.Count); | ||
Assert.AreEqual(2000, torznabCats[0]); | ||
Assert.AreEqual(100001, torznabCats[1]); | ||
} | ||
|
||
[Test] | ||
public void TestMapTrackerCatDescToNewznab() | ||
{ | ||
var indexer = new TestWebIndexer(); | ||
indexer.AddTestCategories(); | ||
|
||
var torznabCats = indexer._MapTrackerCatDescToNewznab("Console/Wii_c").ToList(); | ||
Assert.AreEqual(1, torznabCats.Count); | ||
Assert.AreEqual(1030, torznabCats[0]); | ||
} | ||
} | ||
} |
115 changes: 3 additions & 112 deletions
115
src/Jackett.Test/Torznab/TorznabTests.cs → .../Common/Indexers/CardigannIndexerTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using System.Linq; | ||
using Jackett.Common.Models.DTO; | ||
using Jackett.Test.TestHelpers; | ||
using NUnit.Framework; | ||
using Assert = NUnit.Framework.Assert; | ||
|
||
namespace Jackett.Test.Common.Models.DTO | ||
{ | ||
[TestFixture] | ||
public class IndexerTests | ||
{ | ||
[Test] | ||
public void TestConstructor() | ||
{ | ||
var indexer = new TestWebIndexer(); | ||
|
||
var dto = new Indexer(indexer); | ||
Assert.AreEqual("test_id", dto.id); | ||
Assert.AreEqual("test_name", dto.name); | ||
Assert.AreEqual("test_description", dto.description); | ||
Assert.AreEqual("private", dto.type); | ||
Assert.False(dto.configured); | ||
Assert.AreEqual("https://test.link/", dto.site_link); | ||
Assert.AreEqual(2, dto.alternativesitelinks.ToList().Count); | ||
Assert.AreEqual("en-us", dto.language); | ||
Assert.AreEqual("", dto.last_error); | ||
Assert.False(dto.potatoenabled); | ||
Assert.AreEqual(0, dto.caps.ToList().Count); | ||
} | ||
|
||
[Test] | ||
public void TestConstructorWithCategories() | ||
{ | ||
var indexer = new TestWebIndexer(); | ||
indexer.AddTestCategories(); | ||
|
||
// test Jackett UI categories (internal JSON) | ||
var dto = new Indexer(indexer); | ||
var dtoCaps = dto.caps.ToList(); | ||
Assert.AreEqual(7, dtoCaps.Count); | ||
Assert.AreEqual("100044", dtoCaps[0].ID); | ||
Assert.AreEqual("100045", dtoCaps[1].ID); | ||
Assert.AreEqual("1030", dtoCaps[2].ID); | ||
Assert.AreEqual("1040", dtoCaps[3].ID); | ||
Assert.AreEqual("2000", dtoCaps[4].ID); | ||
Assert.AreEqual("2030", dtoCaps[5].ID); | ||
Assert.AreEqual("7030", dtoCaps[6].ID); | ||
|
||
// movies categories enable potato search | ||
Assert.True(dto.potatoenabled); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.