mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-26 22:46:37 -04:00
New: Drone now uses the Download Client API to determine if a download is ready for import. (User configuration is required to replace the drone factory with this feature)
This commit is contained in:
@@ -15,8 +15,8 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
|
||||
public void should_return_warning_when_download_client_has_not_been_configured()
|
||||
{
|
||||
Mocker.GetMock<IProvideDownloadClient>()
|
||||
.Setup(s => s.GetDownloadClient())
|
||||
.Returns((IDownloadClient)null);
|
||||
.Setup(s => s.GetDownloadClients())
|
||||
.Returns(new IDownloadClient[0]);
|
||||
|
||||
Subject.Check().ShouldBeWarning();
|
||||
}
|
||||
@@ -26,12 +26,12 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
|
||||
{
|
||||
var downloadClient = Mocker.GetMock<IDownloadClient>();
|
||||
|
||||
downloadClient.Setup(s => s.GetQueue())
|
||||
downloadClient.Setup(s => s.GetItems())
|
||||
.Throws<Exception>();
|
||||
|
||||
Mocker.GetMock<IProvideDownloadClient>()
|
||||
.Setup(s => s.GetDownloadClient())
|
||||
.Returns(downloadClient.Object);
|
||||
.Setup(s => s.GetDownloadClients())
|
||||
.Returns(new IDownloadClient[] { downloadClient.Object });
|
||||
|
||||
Subject.Check().ShouldBeError();
|
||||
}
|
||||
@@ -41,12 +41,12 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
|
||||
{
|
||||
var downloadClient = Mocker.GetMock<IDownloadClient>();
|
||||
|
||||
downloadClient.Setup(s => s.GetQueue())
|
||||
.Returns(new List<QueueItem>());
|
||||
downloadClient.Setup(s => s.GetItems())
|
||||
.Returns(new List<DownloadClientItem>());
|
||||
|
||||
Mocker.GetMock<IProvideDownloadClient>()
|
||||
.Setup(s => s.GetDownloadClient())
|
||||
.Returns(downloadClient.Object);
|
||||
.Setup(s => s.GetDownloadClients())
|
||||
.Returns(new IDownloadClient[] { downloadClient.Object });
|
||||
|
||||
Subject.Check().ShouldBeOk();
|
||||
}
|
||||
|
||||
@@ -25,17 +25,7 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
|
||||
.Setup(s => s.FolderExists(DRONE_FACTORY_FOLDER))
|
||||
.Returns(exists);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_warning_when_drone_factory_folder_is_not_configured()
|
||||
{
|
||||
Mocker.GetMock<IConfigService>()
|
||||
.SetupGet(s => s.DownloadedEpisodesFolder)
|
||||
.Returns("");
|
||||
|
||||
Subject.Check().ShouldBeWarning();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void should_return_error_when_drone_factory_folder_does_not_exist()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using FizzWare.NBuilder;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.HealthCheck.Checks;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Download;
|
||||
|
||||
namespace NzbDrone.Core.Test.HealthCheck.Checks
|
||||
{
|
||||
[TestFixture]
|
||||
public class ImportMechanismCheckFixture : CoreTest<ImportMechanismCheck>
|
||||
{
|
||||
private const string DRONE_FACTORY_FOLDER = @"C:\Test\Unsorted";
|
||||
|
||||
private IList<TrackedDownload> _completed;
|
||||
|
||||
private void GivenCompletedDownloadHandling(bool? enabled = null)
|
||||
{
|
||||
if (enabled.HasValue)
|
||||
{
|
||||
Mocker.GetMock<IConfigService>()
|
||||
.Setup(s => s.IsDefined("EnableCompletedDownloadHandling"))
|
||||
.Returns(true);
|
||||
|
||||
Mocker.GetMock<IConfigService>()
|
||||
.SetupGet(s => s.EnableCompletedDownloadHandling)
|
||||
.Returns(enabled.Value);
|
||||
}
|
||||
|
||||
_completed = Builder<TrackedDownload>.CreateListOfSize(1)
|
||||
.All()
|
||||
.With(v => v.State == TrackedDownloadState.Downloading)
|
||||
.With(v => v.DownloadItem = new DownloadClientItem())
|
||||
.With(v => v.DownloadItem.Status = DownloadItemStatus.Completed)
|
||||
.With(v => v.DownloadItem.OutputPath = @"C:\Test\DropFolder\myfile.mkv".AsOsAgnostic())
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<IDownloadTrackingService>()
|
||||
.Setup(v => v.GetCompletedDownloads())
|
||||
.Returns(_completed.ToList());
|
||||
}
|
||||
|
||||
private void GivenDroneFactoryFolder(bool exists = false)
|
||||
{
|
||||
Mocker.GetMock<IConfigService>()
|
||||
.SetupGet(s => s.DownloadedEpisodesFolder)
|
||||
.Returns(DRONE_FACTORY_FOLDER.AsOsAgnostic());
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(s => s.FolderExists(DRONE_FACTORY_FOLDER.AsOsAgnostic()))
|
||||
.Returns(exists);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_warning_when_completed_download_handling_not_configured()
|
||||
{
|
||||
Subject.Check().ShouldBeWarning();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_warning_when_both_completeddownloadhandling_and_dronefactory_are_not_configured()
|
||||
{
|
||||
GivenCompletedDownloadHandling(false);
|
||||
|
||||
Subject.Check().ShouldBeWarning();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_warning_when_downloadclient_drops_in_dronefactory_folder()
|
||||
{
|
||||
GivenCompletedDownloadHandling(true);
|
||||
GivenDroneFactoryFolder(true);
|
||||
|
||||
_completed.First().DownloadItem.OutputPath = (DRONE_FACTORY_FOLDER + @"\myfile.mkv").AsOsAgnostic();
|
||||
|
||||
Subject.Check().ShouldBeWarning();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_ok_when_no_issues_found()
|
||||
{
|
||||
GivenCompletedDownloadHandling(true);
|
||||
GivenDroneFactoryFolder(true);
|
||||
|
||||
Subject.Check().ShouldBeOk();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user