1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-26 22:46:53 -04:00

Fixed: Update Unit Tests for Indexers/Clients

This commit is contained in:
Qstick
2019-06-16 22:18:32 -04:00
parent 8a9e2dc90d
commit c76364a891
43 changed files with 1973 additions and 240 deletions
@@ -173,14 +173,50 @@ namespace NzbDrone.Core.Test.Download
}
[Test]
public void should_not_attempt_download_if_client_isnt_configure()
public void Download_report_should_not_trigger_indexer_backoff_on_indexer_404_error()
{
Subject.DownloadReport(_parseResult);
var mock = WithUsenetClient();
mock.Setup(s => s.Download(It.IsAny<RemoteMovie>()))
.Callback<RemoteMovie>(v => {
throw new ReleaseUnavailableException(v.Release, "Error", new WebException());
});
Assert.Throws<ReleaseUnavailableException>(() => Subject.DownloadReport(_parseResult));
Mocker.GetMock<IIndexerStatusService>()
.Verify(v => v.RecordFailure(It.IsAny<int>(), It.IsAny<TimeSpan>()), Times.Never());
}
[Test]
public void should_not_attempt_download_if_client_isnt_configured()
{
Assert.Throws<DownloadClientUnavailableException>(() => Subject.DownloadReport(_parseResult));
Mocker.GetMock<IDownloadClient>().Verify(c => c.Download(It.IsAny<RemoteMovie>()), Times.Never());
VerifyEventNotPublished<MovieGrabbedEvent>();
}
ExceptionVerification.ExpectedWarns(1);
[Test]
public void should_attempt_download_even_if_client_is_disabled()
{
var mockUsenet = WithUsenetClient();
Mocker.GetMock<IDownloadClientStatusService>()
.Setup(v => v.GetBlockedProviders())
.Returns(new List<DownloadClientStatus>
{
new DownloadClientStatus
{
ProviderId = _downloadClients.First().Definition.Id,
DisabledTill = DateTime.UtcNow.AddHours(3)
}
});
Subject.DownloadReport(_parseResult);
Mocker.GetMock<IDownloadClientStatusService>().Verify(c => c.GetBlockedProviders(), Times.Never());
mockUsenet.Verify(c => c.Download(It.IsAny<RemoteMovie>()), Times.Once());
VerifyEventPublished<MovieGrabbedEvent>();
}
[Test]