New: Readarr 0.1

This commit is contained in:
ta264
2020-05-06 21:14:11 +01:00
parent 476f2d6047
commit 08496c82af
911 changed files with 14837 additions and 24442 deletions
@@ -1,98 +0,0 @@
using System;
using System.Xml;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common.Http;
using NzbDrone.Core.Indexers.Headphones;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.IndexerTests.HeadphonesTests
{
[TestFixture]
public class HeadphonesCapabilitiesProviderFixture : CoreTest<HeadphonesCapabilitiesProvider>
{
private HeadphonesSettings _settings;
private string _caps;
[SetUp]
public void SetUp()
{
_settings = new HeadphonesSettings();
_caps = ReadAllText("Files/Indexers/Newznab/newznab_caps.xml");
}
private void GivenCapsResponse(string caps)
{
Mocker.GetMock<IHttpClient>()
.Setup(o => o.Get(It.IsAny<HttpRequest>()))
.Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), caps));
}
[Test]
public void should_not_request_same_caps_twice()
{
GivenCapsResponse(_caps);
Subject.GetCapabilities(_settings);
Subject.GetCapabilities(_settings);
Mocker.GetMock<IHttpClient>()
.Verify(o => o.Get(It.IsAny<HttpRequest>()), Times.Once());
}
[Test]
public void should_report_pagesize()
{
GivenCapsResponse(_caps);
var caps = Subject.GetCapabilities(_settings);
caps.DefaultPageSize.Should().Be(25);
caps.MaxPageSize.Should().Be(60);
}
[Test]
public void should_use_default_pagesize_if_missing()
{
GivenCapsResponse(_caps.Replace("<limits", "<abclimits"));
var caps = Subject.GetCapabilities(_settings);
caps.DefaultPageSize.Should().Be(100);
caps.MaxPageSize.Should().Be(100);
}
[Test]
public void should_throw_if_failed_to_get()
{
Mocker.GetMock<IHttpClient>()
.Setup(o => o.Get(It.IsAny<HttpRequest>()))
.Throws<Exception>();
Assert.Throws<Exception>(() => Subject.GetCapabilities(_settings));
}
[Test]
public void should_throw_if_xml_invalid()
{
GivenCapsResponse(_caps.Replace("<limits", "<>"));
Assert.Throws<XmlException>(() => Subject.GetCapabilities(_settings));
}
[Test]
public void should_not_throw_on_xml_data_unexpected()
{
GivenCapsResponse(_caps.Replace("3040", "asdf"));
var result = Subject.GetCapabilities(_settings);
result.Should().NotBeNull();
ExceptionVerification.ExpectedErrors(1);
}
}
}
@@ -1,73 +0,0 @@
using System;
using System.Linq;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common.Http;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Indexers.Headphones;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.IndexerTests.HeadphonesTests
{
[TestFixture]
public class HeadphonesFixture : CoreTest<Headphones>
{
private HeadphonesCapabilities _caps;
[SetUp]
public void Setup()
{
Subject.Definition = new IndexerDefinition()
{
Name = "Headphones VIP",
Settings = new HeadphonesSettings()
{
Categories = new int[] { 3000 },
Username = "user",
Password = "pass"
}
};
_caps = new HeadphonesCapabilities();
Mocker.GetMock<IHeadphonesCapabilitiesProvider>()
.Setup(v => v.GetCapabilities(It.IsAny<HeadphonesSettings>()))
.Returns(_caps);
}
[Test]
public void should_parse_recent_feed_from_headphones()
{
var recentFeed = ReadAllText(@"Files/Indexers/Headphones/Headphones.xml");
Mocker.GetMock<IHttpClient>()
.Setup(o => o.Execute(It.Is<HttpRequest>(v => v.Method == HttpMethod.GET)))
.Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), recentFeed));
var releases = Subject.FetchRecent();
releases.Should().HaveCount(16);
releases.First().Should().BeOfType<ReleaseInfo>();
var releaseInfo = releases.First() as ReleaseInfo;
releaseInfo.Title.Should().Be("Lady Gaga Born This Way 2CD FLAC 2011 WRE");
releaseInfo.DownloadProtocol.Should().Be(DownloadProtocol.Usenet);
releaseInfo.DownloadUrl.Should().Be("https://indexer.codeshy.com/api?t=g&guid=123456&apikey=123456789");
releaseInfo.BasicAuthString.Should().Be("dXNlcjpwYXNz");
releaseInfo.Indexer.Should().Be(Subject.Definition.Name);
releaseInfo.PublishDate.Should().Be(DateTime.Parse("2013/06/02 08:58:54"));
releaseInfo.Size.Should().Be(917347414);
}
[Test]
public void should_use_pagesize_reported_by_caps()
{
_caps.MaxPageSize = 30;
_caps.DefaultPageSize = 25;
Subject.PageSize.Should().Be(25);
}
}
}
@@ -25,7 +25,7 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
_singleAlbumSearchCriteria = new AlbumSearchCriteria
{
Artist = new Music.Artist { Name = "Alien Ant Farm" },
Artist = new Music.Author { Name = "Alien Ant Farm" },
AlbumTitle = "TruANT"
};
@@ -1,56 +0,0 @@
using System;
using System.Linq;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common.Http;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Indexers.Waffles;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.IndexerTests.WafflesTests
{
[TestFixture]
public class WafflesFixture : CoreTest<Waffles>
{
[SetUp]
public void Setup()
{
Subject.Definition = new IndexerDefinition()
{
Name = "Waffles",
Settings = new WafflesSettings()
{
UserId = "xxx",
RssPasskey = "123456789"
}
};
}
[Test]
public void should_parse_recent_feed_from_waffles()
{
var recentFeed = ReadAllText(@"Files/Indexers/Waffles/waffles.xml");
Mocker.GetMock<IHttpClient>()
.Setup(o => o.Execute(It.Is<HttpRequest>(v => v.Method == HttpMethod.GET)))
.Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), recentFeed));
var releases = Subject.FetchRecent();
releases.Should().HaveCount(15);
var releaseInfo = releases.First();
releaseInfo.Title.Should().Be("Coldplay - Kaleidoscope EP (FLAC HD) [2017-Web-FLAC-Lossless]");
releaseInfo.DownloadProtocol.Should().Be(DownloadProtocol.Torrent);
releaseInfo.DownloadUrl.Should().Be("https://waffles.ch/download.php/xxx/1166992/" +
"Coldplay%20-%20Kaleidoscope%20EP%20%28FLAC%20HD%29%20%5B2017-Web-FLAC-Lossless%5D.torrent?passkey=123456789&uid=xxx&rss=1");
releaseInfo.InfoUrl.Should().Be("https://waffles.ch/details.php?id=1166992&hit=1");
releaseInfo.CommentUrl.Should().Be("https://waffles.ch/details.php?id=1166992&hit=1");
releaseInfo.Indexer.Should().Be(Subject.Definition.Name);
releaseInfo.PublishDate.Should().Be(DateTime.Parse("2017-07-16 09:51:54"));
releaseInfo.Size.Should().Be(552668227);
}
}
}