From 9835608ff0d4f0f85e7e8238a3c0d3d7d60c82e8 Mon Sep 17 00:00:00 2001 From: Keivan Beigi Date: Tue, 16 Jul 2013 10:55:11 -0700 Subject: [PATCH] skip episode folder if drop folder doesn't exist. --- .../DropFolderImportServiceFixture.cs | 32 +++++++++++++++---- .../DownloadedEpisodesImportService.cs | 25 ++++++++------- 2 files changed, 40 insertions(+), 17 deletions(-) diff --git a/NzbDrone.Core.Test/MediaFileTests/DropFolderImportServiceFixture.cs b/NzbDrone.Core.Test/MediaFileTests/DropFolderImportServiceFixture.cs index e96ddfd78..5e3bd33b7 100644 --- a/NzbDrone.Core.Test/MediaFileTests/DropFolderImportServiceFixture.cs +++ b/NzbDrone.Core.Test/MediaFileTests/DropFolderImportServiceFixture.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.IO; using FizzWare.NBuilder; @@ -7,11 +6,11 @@ using NzbDrone.Common; using NzbDrone.Core.Configuration; using NzbDrone.Core.MediaFiles; +using NzbDrone.Core.MediaFiles.Commands; using NzbDrone.Core.MediaFiles.EpisodeImport; -using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Parser; -using NzbDrone.Core.Tv; using NzbDrone.Core.Test.Framework; +using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.MediaFileTests { @@ -34,14 +33,20 @@ public void Setup() Mocker.GetMock().Setup(c => c.GetDirectories(It.IsAny())) .Returns(_subFolders); + + Mocker.GetMock().Setup(c => c.FolderExists(It.IsAny())) + .Returns(true); + Mocker.GetMock().SetupGet(c => c.DownloadedEpisodesFolder) .Returns("c:\\drop\\"); + + } [Test] public void should_import_file() { - Subject.ProcessDownloadedEpisodesFolder(); + Subject.Execute(new DownloadedEpisodesScanCommand()); VerifyImport(); } @@ -49,18 +54,33 @@ public void should_import_file() [Test] public void should_search_for_series_using_folder_name() { - Subject.ProcessDownloadedEpisodesFolder(); + Subject.Execute(new DownloadedEpisodesScanCommand()); + Mocker.GetMock().Verify(c => c.GetSeries("foldername"), Times.Once()); } + [Test] + public void should_skip_import_if_dropfolder_doesnt_exist() + { + Mocker.GetMock().Setup(c => c.FolderExists(It.IsAny())).Returns(false); + + Subject.Execute(new DownloadedEpisodesScanCommand()); + + Mocker.GetMock().Verify(c => c.GetDirectories(It.IsAny()), Times.Never()); + Mocker.GetMock().Verify(c => c.GetFiles(It.IsAny(), It.IsAny()), Times.Never()); + + ExceptionVerification.ExpectedWarns(1); + } + [Test] public void should_skip_if_file_is_in_use_by_another_process() { Mocker.GetMock().Setup(c => c.IsFileLocked(It.IsAny())) .Returns(true); - Subject.ProcessDownloadedEpisodesFolder(); + Subject.Execute(new DownloadedEpisodesScanCommand()); + VerifyNoImport(); } diff --git a/NzbDrone.Core/MediaFiles/DownloadedEpisodesImportService.cs b/NzbDrone.Core/MediaFiles/DownloadedEpisodesImportService.cs index f91beaf08..dd6bb58f4 100644 --- a/NzbDrone.Core/MediaFiles/DownloadedEpisodesImportService.cs +++ b/NzbDrone.Core/MediaFiles/DownloadedEpisodesImportService.cs @@ -18,7 +18,6 @@ public class DownloadedEpisodesImportService : IExecute videoFiles, Series series)