|
|
@ -6,10 +6,13 @@ using NUnit.Framework;
|
|
|
|
using NzbDrone.Common.Disk;
|
|
|
|
using NzbDrone.Common.Disk;
|
|
|
|
using NzbDrone.Core.Configuration;
|
|
|
|
using NzbDrone.Core.Configuration;
|
|
|
|
using NzbDrone.Core.Download;
|
|
|
|
using NzbDrone.Core.Download;
|
|
|
|
|
|
|
|
using NzbDrone.Core.Download.TrackedDownloads;
|
|
|
|
using NzbDrone.Core.MediaFiles;
|
|
|
|
using NzbDrone.Core.MediaFiles;
|
|
|
|
using NzbDrone.Core.MediaFiles.Commands;
|
|
|
|
using NzbDrone.Core.MediaFiles.Commands;
|
|
|
|
using NzbDrone.Core.MediaFiles.EpisodeImport;
|
|
|
|
using NzbDrone.Core.MediaFiles.EpisodeImport;
|
|
|
|
|
|
|
|
using NzbDrone.Core.Parser.Model;
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
|
|
|
using NzbDrone.Core.Tv;
|
|
|
|
using NzbDrone.Test.Common;
|
|
|
|
using NzbDrone.Test.Common;
|
|
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.MediaFiles
|
|
|
|
namespace NzbDrone.Core.Test.MediaFiles
|
|
|
@ -18,6 +21,9 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|
|
|
public class DownloadedEpisodesCommandServiceFixture : CoreTest<DownloadedEpisodesCommandService>
|
|
|
|
public class DownloadedEpisodesCommandServiceFixture : CoreTest<DownloadedEpisodesCommandService>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private string _droneFactory = "c:\\drop\\".AsOsAgnostic();
|
|
|
|
private string _droneFactory = "c:\\drop\\".AsOsAgnostic();
|
|
|
|
|
|
|
|
private string _downloadFolder = "c:\\drop_other\\Show.S01E01\\".AsOsAgnostic();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private TrackedDownload _trackedDownload;
|
|
|
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
[SetUp]
|
|
|
|
public void Setup()
|
|
|
|
public void Setup()
|
|
|
@ -31,6 +37,33 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
|
|
|
.Setup(v => v.ProcessRootFolder(It.IsAny<DirectoryInfo>()))
|
|
|
|
.Setup(v => v.ProcessRootFolder(It.IsAny<DirectoryInfo>()))
|
|
|
|
.Returns(new List<ImportResult>());
|
|
|
|
.Returns(new List<ImportResult>());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
|
|
|
|
|
|
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
|
|
|
|
|
|
|
.Returns(new List<ImportResult>());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var downloadItem = Builder<DownloadClientItem>.CreateNew()
|
|
|
|
|
|
|
|
.With(v => v.DownloadId = "sab1")
|
|
|
|
|
|
|
|
.With(v => v.Status = DownloadItemStatus.Downloading)
|
|
|
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var remoteEpisode = Builder<RemoteEpisode>.CreateNew()
|
|
|
|
|
|
|
|
.With(v => v.Series = new Series())
|
|
|
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_trackedDownload = new TrackedDownload
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
DownloadItem = downloadItem,
|
|
|
|
|
|
|
|
RemoteEpisode = remoteEpisode,
|
|
|
|
|
|
|
|
State = TrackedDownloadStage.Downloading
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void GivenValidQueueItem()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Mocker.GetMock<ITrackedDownloadService>()
|
|
|
|
|
|
|
|
.Setup(s => s.Find("sab1"))
|
|
|
|
|
|
|
|
.Returns(_trackedDownload);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
@ -51,6 +84,42 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>().Verify(c => c.ProcessRootFolder(It.IsAny<DirectoryInfo>()), Times.Never());
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>().Verify(c => c.ProcessRootFolder(It.IsAny<DirectoryInfo>()), Times.Never());
|
|
|
|
|
|
|
|
|
|
|
|
ExceptionVerification.ExpectedWarns(1);
|
|
|
|
ExceptionVerification.ExpectedWarns(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
|
|
public void should_ignore_downloadclientid_if_path_is_not_specified()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Subject.Execute(new DownloadedEpisodesScanCommand() { DownloadClientId = "sab1" });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>().Verify(c => c.ProcessRootFolder(It.IsAny<DirectoryInfo>()), Times.Once());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
|
|
public void should_process_folder_if_downloadclientid_is_not_specified()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Subject.Execute(new DownloadedEpisodesScanCommand() { Path = _downloadFolder });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>().Verify(c => c.ProcessPath(It.IsAny<string>(), null, null), Times.Once());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
|
|
public void should_process_folder_with_downloadclientitem_if_available()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
GivenValidQueueItem();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Subject.Execute(new DownloadedEpisodesScanCommand() { Path = _downloadFolder, DownloadClientId = "sab1" });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>().Verify(c => c.ProcessPath(_downloadFolder, _trackedDownload.RemoteEpisode.Series, _trackedDownload.DownloadItem), Times.Once());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
|
|
public void should_process_folder_without_downloadclientitem_if_not_available()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Subject.Execute(new DownloadedEpisodesScanCommand() { Path = _downloadFolder, DownloadClientId = "sab1" });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>().Verify(c => c.ProcessPath(_downloadFolder, null, null), Times.Once());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ExceptionVerification.ExpectedWarns(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|