|
|
|
@ -73,7 +73,7 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
|
public void Download_report_should_publish_on_grab_event()
|
|
|
|
|
{
|
|
|
|
|
var mock = WithUsenetClient();
|
|
|
|
|
mock.Setup(s => s.Download(It.IsAny<RemoteMovie>()));
|
|
|
|
|
mock.Setup(s => s.Download(It.IsAny<RemoteMovie>(), It.IsAny<IIndexer>()));
|
|
|
|
|
|
|
|
|
|
Subject.DownloadReport(_parseResult);
|
|
|
|
|
|
|
|
|
@ -84,18 +84,18 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
|
public void Download_report_should_grab_using_client()
|
|
|
|
|
{
|
|
|
|
|
var mock = WithUsenetClient();
|
|
|
|
|
mock.Setup(s => s.Download(It.IsAny<RemoteMovie>()));
|
|
|
|
|
mock.Setup(s => s.Download(It.IsAny<RemoteMovie>(), It.IsAny<IIndexer>()));
|
|
|
|
|
|
|
|
|
|
Subject.DownloadReport(_parseResult);
|
|
|
|
|
|
|
|
|
|
mock.Verify(s => s.Download(It.IsAny<RemoteMovie>()), Times.Once());
|
|
|
|
|
mock.Verify(s => s.Download(It.IsAny<RemoteMovie>(), It.IsAny<IIndexer>()), Times.Once());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Download_report_should_not_publish_on_failed_grab_event()
|
|
|
|
|
{
|
|
|
|
|
var mock = WithUsenetClient();
|
|
|
|
|
mock.Setup(s => s.Download(It.IsAny<RemoteMovie>()))
|
|
|
|
|
mock.Setup(s => s.Download(It.IsAny<RemoteMovie>(), It.IsAny<IIndexer>()))
|
|
|
|
|
.Throws(new WebException());
|
|
|
|
|
|
|
|
|
|
Assert.Throws<WebException>(() => Subject.DownloadReport(_parseResult));
|
|
|
|
@ -107,8 +107,8 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
|
public void Download_report_should_trigger_indexer_backoff_on_indexer_error()
|
|
|
|
|
{
|
|
|
|
|
var mock = WithUsenetClient();
|
|
|
|
|
mock.Setup(s => s.Download(It.IsAny<RemoteMovie>()))
|
|
|
|
|
.Callback<RemoteMovie>(v =>
|
|
|
|
|
mock.Setup(s => s.Download(It.IsAny<RemoteMovie>(), It.IsAny<IIndexer>()))
|
|
|
|
|
.Callback<RemoteMovie, IIndexer>((v, indexer) =>
|
|
|
|
|
{
|
|
|
|
|
throw new ReleaseDownloadException(v.Release, "Error", new WebException());
|
|
|
|
|
});
|
|
|
|
@ -127,8 +127,8 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
|
response.Headers["Retry-After"] = "300";
|
|
|
|
|
|
|
|
|
|
var mock = WithUsenetClient();
|
|
|
|
|
mock.Setup(s => s.Download(It.IsAny<RemoteMovie>()))
|
|
|
|
|
.Callback<RemoteMovie>(v =>
|
|
|
|
|
mock.Setup(s => s.Download(It.IsAny<RemoteMovie>(), It.IsAny<IIndexer>()))
|
|
|
|
|
.Callback<RemoteMovie, IIndexer>((v, indexer) =>
|
|
|
|
|
{
|
|
|
|
|
throw new ReleaseDownloadException(v.Release, "Error", new TooManyRequestsException(request, response));
|
|
|
|
|
});
|
|
|
|
@ -147,8 +147,8 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
|
response.Headers["Retry-After"] = DateTime.UtcNow.AddSeconds(300).ToString("r");
|
|
|
|
|
|
|
|
|
|
var mock = WithUsenetClient();
|
|
|
|
|
mock.Setup(s => s.Download(It.IsAny<RemoteMovie>()))
|
|
|
|
|
.Callback<RemoteMovie>(v =>
|
|
|
|
|
mock.Setup(s => s.Download(It.IsAny<RemoteMovie>(), It.IsAny<IIndexer>()))
|
|
|
|
|
.Callback<RemoteMovie, IIndexer>((v, indexer) =>
|
|
|
|
|
{
|
|
|
|
|
throw new ReleaseDownloadException(v.Release, "Error", new TooManyRequestsException(request, response));
|
|
|
|
|
});
|
|
|
|
@ -164,7 +164,7 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
|
public void Download_report_should_not_trigger_indexer_backoff_on_downloadclient_error()
|
|
|
|
|
{
|
|
|
|
|
var mock = WithUsenetClient();
|
|
|
|
|
mock.Setup(s => s.Download(It.IsAny<RemoteMovie>()))
|
|
|
|
|
mock.Setup(s => s.Download(It.IsAny<RemoteMovie>(), It.IsAny<IIndexer>()))
|
|
|
|
|
.Throws(new DownloadClientException("Some Error"));
|
|
|
|
|
|
|
|
|
|
Assert.Throws<DownloadClientException>(() => Subject.DownloadReport(_parseResult));
|
|
|
|
@ -177,8 +177,8 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
|
public void Download_report_should_not_trigger_indexer_backoff_on_indexer_404_error()
|
|
|
|
|
{
|
|
|
|
|
var mock = WithUsenetClient();
|
|
|
|
|
mock.Setup(s => s.Download(It.IsAny<RemoteMovie>()))
|
|
|
|
|
.Callback<RemoteMovie>(v =>
|
|
|
|
|
mock.Setup(s => s.Download(It.IsAny<RemoteMovie>(), It.IsAny<IIndexer>()))
|
|
|
|
|
.Callback<RemoteMovie, IIndexer>((v, indexer) =>
|
|
|
|
|
{
|
|
|
|
|
throw new ReleaseUnavailableException(v.Release, "Error", new WebException());
|
|
|
|
|
});
|
|
|
|
@ -194,7 +194,7 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
|
{
|
|
|
|
|
Assert.Throws<DownloadClientUnavailableException>(() => Subject.DownloadReport(_parseResult));
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IDownloadClient>().Verify(c => c.Download(It.IsAny<RemoteMovie>()), Times.Never());
|
|
|
|
|
Mocker.GetMock<IDownloadClient>().Verify(c => c.Download(It.IsAny<RemoteMovie>(), It.IsAny<IIndexer>()), Times.Never());
|
|
|
|
|
VerifyEventNotPublished<MovieGrabbedEvent>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -217,7 +217,7 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
|
Subject.DownloadReport(_parseResult);
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IDownloadClientStatusService>().Verify(c => c.GetBlockedProviders(), Times.Never());
|
|
|
|
|
mockUsenet.Verify(c => c.Download(It.IsAny<RemoteMovie>()), Times.Once());
|
|
|
|
|
mockUsenet.Verify(c => c.Download(It.IsAny<RemoteMovie>(), It.IsAny<IIndexer>()), Times.Once());
|
|
|
|
|
VerifyEventPublished<MovieGrabbedEvent>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -229,8 +229,8 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
|
|
|
|
|
|
Subject.DownloadReport(_parseResult);
|
|
|
|
|
|
|
|
|
|
mockTorrent.Verify(c => c.Download(It.IsAny<RemoteMovie>()), Times.Never());
|
|
|
|
|
mockUsenet.Verify(c => c.Download(It.IsAny<RemoteMovie>()), Times.Once());
|
|
|
|
|
mockTorrent.Verify(c => c.Download(It.IsAny<RemoteMovie>(), It.IsAny<IIndexer>()), Times.Never());
|
|
|
|
|
mockUsenet.Verify(c => c.Download(It.IsAny<RemoteMovie>(), It.IsAny<IIndexer>()), Times.Once());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
@ -243,8 +243,8 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
|
|
|
|
|
|
Subject.DownloadReport(_parseResult);
|
|
|
|
|
|
|
|
|
|
mockTorrent.Verify(c => c.Download(It.IsAny<RemoteMovie>()), Times.Once());
|
|
|
|
|
mockUsenet.Verify(c => c.Download(It.IsAny<RemoteMovie>()), Times.Never());
|
|
|
|
|
mockTorrent.Verify(c => c.Download(It.IsAny<RemoteMovie>(), It.IsAny<IIndexer>()), Times.Once());
|
|
|
|
|
mockUsenet.Verify(c => c.Download(It.IsAny<RemoteMovie>(), It.IsAny<IIndexer>()), Times.Never());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|