Build download requests from indexer implementation

(cherry picked from commit a0b08f6c6f106d92cdb12fbb959dd2605c22fe6a)
This commit is contained in:
Bogdan
2023-04-30 07:09:11 +03:00
parent 1978a726bb
commit 7a7039b1f7
26 changed files with 132 additions and 91 deletions
@@ -3,12 +3,17 @@ using System.IO;
using System.Net;
using FizzWare.NBuilder;
using Moq;
using NLog;
using NUnit.Framework;
using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Download;
using NzbDrone.Core.Download.Clients.Pneumatic;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Test.IndexerTests;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.Download.DownloadClientTests
@@ -22,6 +27,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
private string _strmFolder;
private string _nzbPath;
private RemoteBook _remoteBook;
private IIndexer _indexer;
private DownloadClientItem _downloadClientItem;
[SetUp]
@@ -39,6 +45,12 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
_remoteBook.ParsedBookInfo = new ParsedBookInfo();
_indexer = new TestIndexer(Mocker.Resolve<IHttpClient>(),
Mocker.Resolve<IIndexerStatusService>(),
Mocker.Resolve<IConfigService>(),
Mocker.Resolve<IParsingService>(),
Mocker.Resolve<Logger>());
_downloadClientItem = Builder<DownloadClientItem>
.CreateNew().With(d => d.DownloadId = "_Droned.S01E01.Pilot.1080p.WEB-DL-DRONE_0")
.Build();
@@ -59,7 +71,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
[Test]
public void should_download_file_if_it_doesnt_exist()
{
Subject.Download(_remoteBook);
Subject.Download(_remoteBook, _indexer);
Mocker.GetMock<IHttpClient>().Verify(c => c.DownloadFile(_nzbUrl, _nzbPath, null), Times.Once());
}
@@ -69,7 +81,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
{
WithFailedDownload();
Assert.Throws<WebException>(() => Subject.Download(_remoteBook));
Assert.Throws<WebException>(() => Subject.Download(_remoteBook, _indexer));
}
[Test]
@@ -78,7 +90,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
_remoteBook.Release.Title = "Alien Ant Farm - Discography";
_remoteBook.ParsedBookInfo.Discography = true;
Assert.Throws<NotSupportedException>(() => Subject.Download(_remoteBook));
Assert.Throws<NotSupportedException>(() => Subject.Download(_remoteBook, _indexer));
}
[Test]
@@ -94,7 +106,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
var expectedFilename = Path.Combine(_pneumaticFolder, "Saturday Night Live - S38E08 - Jeremy Renner+Maroon 5 [SDTV].nzb");
_remoteBook.Release.Title = illegalTitle;
Subject.Download(_remoteBook);
Subject.Download(_remoteBook, _indexer);
Mocker.GetMock<IHttpClient>().Verify(c => c.DownloadFile(It.IsAny<string>(), expectedFilename, null), Times.Once());
}