mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-10-30 15:32:31 +01:00
Implemented indexer integration tests for a couple of public indexers.
This commit is contained in:
parent
2345984bda
commit
0ae0bd43be
@ -1,70 +1,211 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.Indexers.Eztv;
|
||||
using NzbDrone.Core.Indexers.Fanzub;
|
||||
using NzbDrone.Core.Indexers.KickassTorrents;
|
||||
using NzbDrone.Core.Indexers.Newznab;
|
||||
using NzbDrone.Core.Indexers.Nyaa;
|
||||
using NzbDrone.Core.Indexers.Wombles;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.ThingiProvider;
|
||||
using NzbDrone.Test.Common.Categories;
|
||||
using System.Linq;
|
||||
|
||||
namespace NzbDrone.Core.Test.IndexerTests.IntegrationTests
|
||||
{
|
||||
[IntegrationTest]
|
||||
public class IndexerIntegrationTests : CoreTest<Wombles>
|
||||
public class IndexerIntegrationTests : CoreTest
|
||||
{
|
||||
private SingleEpisodeSearchCriteria _singleSearchCriteria;
|
||||
private AnimeEpisodeSearchCriteria _animeSearchCriteria;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
UseRealHttp();
|
||||
|
||||
_singleSearchCriteria = new SingleEpisodeSearchCriteria()
|
||||
{
|
||||
SceneTitles = new List<string> { "Person of Interest" },
|
||||
SeasonNumber = 1,
|
||||
EpisodeNumber = 1
|
||||
};
|
||||
|
||||
_animeSearchCriteria = new AnimeEpisodeSearchCriteria()
|
||||
{
|
||||
SceneTitles = new List<string> { "Steins;Gate" },
|
||||
AbsoluteEpisodeNumber = 1
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void wombles_rss()
|
||||
public void wombles_fetch_recent()
|
||||
{
|
||||
Subject.Definition = new IndexerDefinition
|
||||
var indexer = Mocker.Resolve<Wombles>();
|
||||
|
||||
indexer.Definition = new IndexerDefinition
|
||||
{
|
||||
Name = "Wombles",
|
||||
Name = "MyIndexer",
|
||||
Settings = NullConfig.Instance
|
||||
};
|
||||
|
||||
var result = Subject.FetchRecent();
|
||||
var result = indexer.FetchRecent();
|
||||
|
||||
ValidateResult(result, skipSize: true, skipInfo: true);
|
||||
ValidateResult(result);
|
||||
}
|
||||
|
||||
private void ValidateResult(IList<ReleaseInfo> reports, bool skipSize = false, bool skipInfo = false)
|
||||
[Test]
|
||||
public void fanzub_fetch_recent()
|
||||
{
|
||||
Assert.Inconclusive("Fanzub Down");
|
||||
|
||||
var indexer = Mocker.Resolve<Fanzub>();
|
||||
|
||||
indexer.Definition = new IndexerDefinition
|
||||
{
|
||||
Name = "MyIndexer",
|
||||
Settings = NullConfig.Instance
|
||||
};
|
||||
|
||||
var result = indexer.FetchRecent();
|
||||
|
||||
ValidateResult(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void fanzub_search_single()
|
||||
{
|
||||
Assert.Inconclusive("Fanzub Down");
|
||||
|
||||
var indexer = Mocker.Resolve<Fanzub>();
|
||||
|
||||
indexer.Definition = new IndexerDefinition
|
||||
{
|
||||
Name = "MyIndexer",
|
||||
Settings = NullConfig.Instance
|
||||
};
|
||||
|
||||
var result = indexer.Fetch(_animeSearchCriteria);
|
||||
|
||||
ValidateResult(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void kickass_fetch_recent()
|
||||
{
|
||||
var indexer = Mocker.Resolve<KickassTorrents>();
|
||||
|
||||
indexer.Definition = new IndexerDefinition
|
||||
{
|
||||
Name = "MyIndexer",
|
||||
Settings = new KickassTorrentsSettings()
|
||||
};
|
||||
|
||||
var result = indexer.FetchRecent();
|
||||
|
||||
ValidateTorrentResult(result, hasSize: true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void kickass_search_single()
|
||||
{
|
||||
var indexer = Mocker.Resolve<KickassTorrents>();
|
||||
|
||||
indexer.Definition = new IndexerDefinition
|
||||
{
|
||||
Name = "MyIndexer",
|
||||
Settings = new KickassTorrentsSettings()
|
||||
};
|
||||
|
||||
var result = indexer.Fetch(_singleSearchCriteria);
|
||||
|
||||
ValidateTorrentResult(result, hasSize: true, hasMagnet: true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void eztv_fetch_recent()
|
||||
{
|
||||
var indexer = Mocker.Resolve<Eztv>();
|
||||
|
||||
indexer.Definition = new IndexerDefinition
|
||||
{
|
||||
Name = "MyIndexer",
|
||||
Settings = new EztvSettings()
|
||||
};
|
||||
|
||||
var result = indexer.FetchRecent();
|
||||
|
||||
ValidateTorrentResult(result, hasSize: true, hasMagnet: true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void nyaa_fetch_recent()
|
||||
{
|
||||
var indexer = Mocker.Resolve<Nyaa>();
|
||||
|
||||
indexer.Definition = new IndexerDefinition
|
||||
{
|
||||
Name = "MyIndexer",
|
||||
Settings = new NyaaSettings()
|
||||
};
|
||||
|
||||
var result = indexer.FetchRecent();
|
||||
|
||||
ValidateTorrentResult(result, hasSize: true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void nyaa_search_single()
|
||||
{
|
||||
var indexer = Mocker.Resolve<Nyaa>();
|
||||
|
||||
indexer.Definition = new IndexerDefinition
|
||||
{
|
||||
Name = "MyIndexer",
|
||||
Settings = new NyaaSettings()
|
||||
};
|
||||
|
||||
var result = indexer.Fetch(_animeSearchCriteria);
|
||||
|
||||
ValidateTorrentResult(result, hasSize: true);
|
||||
}
|
||||
|
||||
private void ValidateResult(IList<ReleaseInfo> reports, bool hasSize = false, bool hasInfoUrl = false)
|
||||
{
|
||||
reports.Should().NotBeEmpty();
|
||||
reports.Should().NotContain(c => string.IsNullOrWhiteSpace(c.Title));
|
||||
reports.Should().NotContain(c => string.IsNullOrWhiteSpace(c.DownloadUrl));
|
||||
reports.Should().OnlyContain(c => c.Title.IsNotNullOrWhiteSpace());
|
||||
reports.Should().OnlyContain(c => c.PublishDate.Year > 2000);
|
||||
reports.Should().OnlyContain(c => c.DownloadUrl.IsNotNullOrWhiteSpace());
|
||||
reports.Should().OnlyContain(c => c.DownloadUrl.StartsWith("http"));
|
||||
|
||||
if (!skipInfo)
|
||||
if (hasInfoUrl)
|
||||
{
|
||||
reports.Should().NotContain(c => string.IsNullOrWhiteSpace(c.InfoUrl));
|
||||
reports.Should().OnlyContain(c => c.InfoUrl.IsNotNullOrWhiteSpace());
|
||||
}
|
||||
|
||||
if (!skipSize)
|
||||
if (hasSize)
|
||||
{
|
||||
reports.Should().OnlyContain(c => c.Size > 0);
|
||||
}
|
||||
}
|
||||
|
||||
private void ValidateTorrentResult(IList<ReleaseInfo> reports, bool skipSize = false, bool skipInfo = false)
|
||||
private void ValidateTorrentResult(IList<ReleaseInfo> reports, bool hasSize = false, bool hasInfoUrl = false, bool hasMagnet = false)
|
||||
{
|
||||
reports.Should().OnlyContain(c => c.GetType() == typeof(TorrentInfo));
|
||||
|
||||
ValidateResult(reports, skipSize, skipInfo);
|
||||
ValidateResult(reports, hasSize, hasInfoUrl);
|
||||
|
||||
reports.Should().OnlyContain(c => c.DownloadUrl.EndsWith(".torrent"));
|
||||
reports.Should().OnlyContain(c => c.DownloadProtocol == DownloadProtocol.Torrent);
|
||||
|
||||
if (hasMagnet)
|
||||
{
|
||||
reports.Cast<TorrentInfo>().Should().OnlyContain(c => c.MagnetUrl.StartsWith("magnet:"));
|
||||
reports.Cast<TorrentInfo>().Should().NotContain(c => string.IsNullOrWhiteSpace(c.InfoHash));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user