|
|
|
@ -82,7 +82,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<RemoteEpisode>()));
|
|
|
|
|
mock.Setup(s => s.Download(It.IsAny<RemoteEpisode>(), It.IsAny<IIndexer>()));
|
|
|
|
|
|
|
|
|
|
Subject.DownloadReport(_parseResult, null);
|
|
|
|
|
|
|
|
|
@ -93,18 +93,18 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
|
public void Download_report_should_grab_using_client()
|
|
|
|
|
{
|
|
|
|
|
var mock = WithUsenetClient();
|
|
|
|
|
mock.Setup(s => s.Download(It.IsAny<RemoteEpisode>()));
|
|
|
|
|
mock.Setup(s => s.Download(It.IsAny<RemoteEpisode>(), It.IsAny<IIndexer>()));
|
|
|
|
|
|
|
|
|
|
Subject.DownloadReport(_parseResult, null);
|
|
|
|
|
|
|
|
|
|
mock.Verify(s => s.Download(It.IsAny<RemoteEpisode>()), Times.Once());
|
|
|
|
|
mock.Verify(s => s.Download(It.IsAny<RemoteEpisode>(), 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<RemoteEpisode>()))
|
|
|
|
|
mock.Setup(s => s.Download(It.IsAny<RemoteEpisode>(), It.IsAny<IIndexer>()))
|
|
|
|
|
.Throws(new WebException());
|
|
|
|
|
|
|
|
|
|
Assert.Throws<WebException>(() => Subject.DownloadReport(_parseResult, null));
|
|
|
|
@ -116,8 +116,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<RemoteEpisode>()))
|
|
|
|
|
.Callback<RemoteEpisode>(v =>
|
|
|
|
|
mock.Setup(s => s.Download(It.IsAny<RemoteEpisode>(), It.IsAny<IIndexer>()))
|
|
|
|
|
.Callback<RemoteEpisode, IIndexer>((v, indexer) =>
|
|
|
|
|
{
|
|
|
|
|
throw new ReleaseDownloadException(v.Release, "Error", new WebException());
|
|
|
|
|
});
|
|
|
|
@ -136,8 +136,8 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
|
response.Headers["Retry-After"] = "300";
|
|
|
|
|
|
|
|
|
|
var mock = WithUsenetClient();
|
|
|
|
|
mock.Setup(s => s.Download(It.IsAny<RemoteEpisode>()))
|
|
|
|
|
.Callback<RemoteEpisode>(v =>
|
|
|
|
|
mock.Setup(s => s.Download(It.IsAny<RemoteEpisode>(), It.IsAny<IIndexer>()))
|
|
|
|
|
.Callback<RemoteEpisode, IIndexer>((v, indexer) =>
|
|
|
|
|
{
|
|
|
|
|
throw new ReleaseDownloadException(v.Release, "Error", new TooManyRequestsException(request, response));
|
|
|
|
|
});
|
|
|
|
@ -156,8 +156,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<RemoteEpisode>()))
|
|
|
|
|
.Callback<RemoteEpisode>(v =>
|
|
|
|
|
mock.Setup(s => s.Download(It.IsAny<RemoteEpisode>(), It.IsAny<IIndexer>()))
|
|
|
|
|
.Callback<RemoteEpisode, IIndexer>((v, indexer) =>
|
|
|
|
|
{
|
|
|
|
|
throw new ReleaseDownloadException(v.Release, "Error", new TooManyRequestsException(request, response));
|
|
|
|
|
});
|
|
|
|
@ -173,7 +173,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<RemoteEpisode>()))
|
|
|
|
|
mock.Setup(s => s.Download(It.IsAny<RemoteEpisode>(), It.IsAny<IIndexer>()))
|
|
|
|
|
.Throws(new DownloadClientException("Some Error"));
|
|
|
|
|
|
|
|
|
|
Assert.Throws<DownloadClientException>(() => Subject.DownloadReport(_parseResult, null));
|
|
|
|
@ -186,8 +186,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<RemoteEpisode>()))
|
|
|
|
|
.Callback<RemoteEpisode>(v =>
|
|
|
|
|
mock.Setup(s => s.Download(It.IsAny<RemoteEpisode>(), It.IsAny<IIndexer>()))
|
|
|
|
|
.Callback<RemoteEpisode, IIndexer>((v, indexer) =>
|
|
|
|
|
{
|
|
|
|
|
throw new ReleaseUnavailableException(v.Release, "Error", new WebException());
|
|
|
|
|
});
|
|
|
|
@ -203,7 +203,7 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
|
{
|
|
|
|
|
Assert.Throws<DownloadClientUnavailableException>(() => Subject.DownloadReport(_parseResult, null));
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IDownloadClient>().Verify(c => c.Download(It.IsAny<RemoteEpisode>()), Times.Never());
|
|
|
|
|
Mocker.GetMock<IDownloadClient>().Verify(c => c.Download(It.IsAny<RemoteEpisode>(), It.IsAny<IIndexer>()), Times.Never());
|
|
|
|
|
VerifyEventNotPublished<EpisodeGrabbedEvent>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -226,7 +226,7 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
|
Subject.DownloadReport(_parseResult, null);
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IDownloadClientStatusService>().Verify(c => c.GetBlockedProviders(), Times.Never());
|
|
|
|
|
mockUsenet.Verify(c => c.Download(It.IsAny<RemoteEpisode>()), Times.Once());
|
|
|
|
|
mockUsenet.Verify(c => c.Download(It.IsAny<RemoteEpisode>(), It.IsAny<IIndexer>()), Times.Once());
|
|
|
|
|
VerifyEventPublished<EpisodeGrabbedEvent>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -238,8 +238,8 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
|
|
|
|
|
|
Subject.DownloadReport(_parseResult, null);
|
|
|
|
|
|
|
|
|
|
mockTorrent.Verify(c => c.Download(It.IsAny<RemoteEpisode>()), Times.Never());
|
|
|
|
|
mockUsenet.Verify(c => c.Download(It.IsAny<RemoteEpisode>()), Times.Once());
|
|
|
|
|
mockTorrent.Verify(c => c.Download(It.IsAny<RemoteEpisode>(), It.IsAny<IIndexer>()), Times.Never());
|
|
|
|
|
mockUsenet.Verify(c => c.Download(It.IsAny<RemoteEpisode>(), It.IsAny<IIndexer>()), Times.Once());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
@ -252,8 +252,8 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
|
|
|
|
|
|
Subject.DownloadReport(_parseResult, null);
|
|
|
|
|
|
|
|
|
|
mockTorrent.Verify(c => c.Download(It.IsAny<RemoteEpisode>()), Times.Once());
|
|
|
|
|
mockUsenet.Verify(c => c.Download(It.IsAny<RemoteEpisode>()), Times.Never());
|
|
|
|
|
mockTorrent.Verify(c => c.Download(It.IsAny<RemoteEpisode>(), It.IsAny<IIndexer>()), Times.Once());
|
|
|
|
|
mockUsenet.Verify(c => c.Download(It.IsAny<RemoteEpisode>(), It.IsAny<IIndexer>()), Times.Never());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|