You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Radarr/src/NzbDrone.Core.Test/IndexerTests/HDBitsTests/HDBitsFixture.cs

79 lines
2.9 KiB

using System;
9 years ago
using System.Linq;
using System.Net.Http;
9 years ago
using System.Text;
using System.Threading.Tasks;
9 years ago
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common.Http;
9 years ago
using NzbDrone.Common.Serializer;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Indexers.HDBits;
using NzbDrone.Core.Parser.Model;
9 years ago
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
9 years ago
namespace NzbDrone.Core.Test.IndexerTests.HDBitsTests
{
[TestFixture]
9 years ago
public class HDBitsFixture : CoreTest<HDBits>
{
[SetUp]
public void Setup()
{
Subject.Definition = new IndexerDefinition()
{
Name = "HdBits",
9 years ago
Settings = new HDBitsSettings() { ApiKey = "fakekey" }
};
}
[TestCase("Files/Indexers/HdBits/RecentFeedLongIDs.json")]
8 years ago
[TestCase("Files/Indexers/HdBits/RecentFeedStringIDs.json")]
public async Task should_parse_recent_feed_from_HDBits(string fileName)
{
var responseJson = ReadAllText(fileName);
Mocker.GetMock<IHttpClient>()
.Setup(o => o.ExecuteAsync(It.Is<HttpRequest>(v => v.Method == HttpMethod.Post)))
.Returns<HttpRequest>(r => Task.FromResult(new HttpResponse(r, new HttpHeader(), responseJson)));
var torrents = await Subject.FetchRecent();
torrents.Should().HaveCount(2);
Fixed all tests and even added some new ones :) (#835) * First fixing of tests. * Updated more tests. * Fix some tests * Fix all prioritization tests. And add new for preferred words. * Updated CompletedDownloadservice tests * Fixed a lot of tests * Fixed all indexer requests. We should add more for the indexers we added. To lazy for that though ¯\_(ツ)_/¯ * Fixed organizer tests. Should probably be also updated to incorporate our newly added tags. * Fix notification tests. * Fixed update test for osx * Fixed a few more tests. * Fixed some more tests. * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update activity.less * Update appveyor.yml * Update appveyor.yml * Update CommonVersionInfo.cs * Update build-appveyor.cake Let's hope this works. * Update CommonVersionInfo.cs Just to kickstart appveyor * Fixed a few tests * Just ignore those tests. * Fixed more tests. * First steps in fixing Core.Test.Download.DownloadApprovedFixture * Fix most DownloadApprovedFixture tests * Fixed something. * Fixed a few more tests. * Fixed pending release tests. * All Core tests are now fixed. * Fixed the last tests :) * Fixed Download Station Tests. * Fixed Vuze and Transmission default settings which caused the tests to fail. * Fix most tests. * Fix RootFolder tests. * Fixed last tests
7 years ago
torrents.First().Should().BeOfType<HDBitsInfo>();
var first = torrents.First() as TorrentInfo;
first.Guid.Should().Be("HDBits-257142");
first.Title.Should().Be("Supernatural S10E17 1080p WEB-DL DD5.1 H.264-ECI");
first.DownloadProtocol.Should().Be(DownloadProtocol.Torrent);
first.DownloadUrl.Should().Be("https://hdbits.org/download.php?id=257142&passkey=fakekey");
first.InfoUrl.Should().Be("https://hdbits.org/details.php?id=257142");
first.PublishDate.Should().Be(DateTime.Parse("2015-04-04T20:30:46+0000").ToUniversalTime());
first.Size.Should().Be(1718009717);
9 years ago
first.InfoHash.Should().Be("EABC50AEF9F53CEDED84ADF14144D3368E586F3A");
first.MagnetUrl.Should().BeNullOrEmpty();
first.Peers.Should().Be(47);
first.Seeders.Should().Be(46);
}
[Test]
public async Task should_warn_on_wrong_passkey()
{
9 years ago
var responseJson = new { status = 5, message = "Invalid authentication credentials" }.ToJson();
Mocker.GetMock<IHttpClient>()
.Setup(v => v.ExecuteAsync(It.IsAny<HttpRequest>()))
.Returns<HttpRequest>(r => Task.FromResult(new HttpResponse(r, new HttpHeader(), Encoding.UTF8.GetBytes(responseJson))));
var torrents = await Subject.FetchRecent();
torrents.Should().BeEmpty();
ExceptionVerification.ExpectedWarns(1);
}
}
}