|
|
@ -11,6 +11,7 @@ using NzbDrone.Core.History;
|
|
|
|
using NzbDrone.Core.MediaFiles;
|
|
|
|
using NzbDrone.Core.MediaFiles;
|
|
|
|
using NzbDrone.Core.MediaFiles.EpisodeImport;
|
|
|
|
using NzbDrone.Core.MediaFiles.EpisodeImport;
|
|
|
|
using NzbDrone.Core.Messaging.Events;
|
|
|
|
using NzbDrone.Core.Messaging.Events;
|
|
|
|
|
|
|
|
using NzbDrone.Core.Parser;
|
|
|
|
using NzbDrone.Core.Parser.Model;
|
|
|
|
using NzbDrone.Core.Parser.Model;
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
using NzbDrone.Core.Tv;
|
|
|
|
using NzbDrone.Core.Tv;
|
|
|
@ -66,17 +67,23 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
.Returns((History.History)null);
|
|
|
|
.Returns((History.History)null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void GivenSuccessfulImport()
|
|
|
|
private void GivenSuccessfulImport()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
|
|
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<DownloadClientItem>()))
|
|
|
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
|
|
|
.Returns(new List<ImportResult>
|
|
|
|
.Returns(new List<ImportResult>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
new ImportResult(new ImportDecision(new LocalEpisode() { Path = @"C:\TestPath\Droned.S01E01.mkv" }))
|
|
|
|
new ImportResult(new ImportDecision(new LocalEpisode() { Path = @"C:\TestPath\Droned.S01E01.mkv" }))
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void GivenSeriesMatch()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Mocker.GetMock<IParsingService>()
|
|
|
|
|
|
|
|
.Setup(s => s.GetSeries(It.IsAny<string>()))
|
|
|
|
|
|
|
|
.Returns(_trackedDownload.RemoteEpisode.Series);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[TestCase(DownloadItemStatus.Downloading)]
|
|
|
|
[TestCase(DownloadItemStatus.Downloading)]
|
|
|
|
[TestCase(DownloadItemStatus.Failed)]
|
|
|
|
[TestCase(DownloadItemStatus.Failed)]
|
|
|
|
[TestCase(DownloadItemStatus.Queued)]
|
|
|
|
[TestCase(DownloadItemStatus.Queued)]
|
|
|
@ -107,6 +114,7 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_trackedDownload.DownloadItem.Category = "tv";
|
|
|
|
_trackedDownload.DownloadItem.Category = "tv";
|
|
|
|
GivenNoGrabbedHistory();
|
|
|
|
GivenNoGrabbedHistory();
|
|
|
|
|
|
|
|
GivenSeriesMatch();
|
|
|
|
GivenSuccessfulImport();
|
|
|
|
GivenSuccessfulImport();
|
|
|
|
|
|
|
|
|
|
|
|
Subject.Process(_trackedDownload);
|
|
|
|
Subject.Process(_trackedDownload);
|
|
|
@ -142,7 +150,7 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
public void should_not_mark_as_imported_if_all_files_were_rejected()
|
|
|
|
public void should_not_mark_as_imported_if_all_files_were_rejected()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
|
|
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<DownloadClientItem>()))
|
|
|
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
|
|
|
.Returns(new List<ImportResult>
|
|
|
|
.Returns(new List<ImportResult>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
new ImportResult(new ImportDecision(new LocalEpisode {Path = @"C:\TestPath\Droned.S01E01.mkv"}, "Rejected!"),"Test Failure"),
|
|
|
|
new ImportResult(new ImportDecision(new LocalEpisode {Path = @"C:\TestPath\Droned.S01E01.mkv"}, "Rejected!"),"Test Failure"),
|
|
|
@ -161,7 +169,7 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
public void should_not_mark_as_imported_if_all_files_were_skipped()
|
|
|
|
public void should_not_mark_as_imported_if_all_files_were_skipped()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
|
|
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<DownloadClientItem>()))
|
|
|
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
|
|
|
.Returns(new List<ImportResult>
|
|
|
|
.Returns(new List<ImportResult>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
new ImportResult(new ImportDecision(new LocalEpisode {Path = @"C:\TestPath\Droned.S01E01.mkv"}),"Test Failure"),
|
|
|
|
new ImportResult(new ImportDecision(new LocalEpisode {Path = @"C:\TestPath\Droned.S01E01.mkv"}),"Test Failure"),
|
|
|
@ -177,6 +185,7 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void should_mark_as_imported_if_all_episodes_were_imported_but_extra_files_were_not()
|
|
|
|
public void should_mark_as_imported_if_all_episodes_were_imported_but_extra_files_were_not()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
GivenSeriesMatch();
|
|
|
|
|
|
|
|
|
|
|
|
_trackedDownload.RemoteEpisode.Episodes = new List<Episode>
|
|
|
|
_trackedDownload.RemoteEpisode.Episodes = new List<Episode>
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -184,14 +193,13 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
|
|
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<DownloadClientItem>()))
|
|
|
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
|
|
|
.Returns(new List<ImportResult>
|
|
|
|
.Returns(new List<ImportResult>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
new ImportResult(new ImportDecision(new LocalEpisode {Path = @"C:\TestPath\Droned.S01E01.mkv"})),
|
|
|
|
new ImportResult(new ImportDecision(new LocalEpisode {Path = @"C:\TestPath\Droned.S01E01.mkv"})),
|
|
|
|
new ImportResult(new ImportDecision(new LocalEpisode{Path = @"C:\TestPath\Droned.S01E01.mkv"}),"Test Failure")
|
|
|
|
new ImportResult(new ImportDecision(new LocalEpisode{Path = @"C:\TestPath\Droned.S01E01.mkv"}),"Test Failure")
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Subject.Process(_trackedDownload);
|
|
|
|
Subject.Process(_trackedDownload);
|
|
|
|
|
|
|
|
|
|
|
|
AssertCompletedDownload();
|
|
|
|
AssertCompletedDownload();
|
|
|
@ -208,7 +216,7 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
|
|
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<DownloadClientItem>()))
|
|
|
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
|
|
|
.Returns(new List<ImportResult>
|
|
|
|
.Returns(new List<ImportResult>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
new ImportResult(new ImportDecision(new LocalEpisode {Path = @"C:\TestPath\Droned.S01E01.mkv"})),
|
|
|
|
new ImportResult(new ImportDecision(new LocalEpisode {Path = @"C:\TestPath\Droned.S01E01.mkv"})),
|
|
|
@ -222,11 +230,38 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
AssertNoCompletedDownload();
|
|
|
|
AssertNoCompletedDownload();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
|
|
public void should_not_import_when_there_is_a_title_mismatch()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Subject.Process(_trackedDownload);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AssertNoCompletedDownload();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
|
|
public void should_mark_as_import_title_mismatch_if_ignore_warnings_is_true()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_trackedDownload.RemoteEpisode.Episodes = new List<Episode>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
new Episode()
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
|
|
|
|
|
|
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
|
|
|
|
|
|
|
.Returns(new List<ImportResult>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
new ImportResult(new ImportDecision(new LocalEpisode {Path = @"C:\TestPath\Droned.S01E01.mkv"}))
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Subject.Process(_trackedDownload, true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AssertCompletedDownload();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void AssertNoAttemptedImport()
|
|
|
|
private void AssertNoAttemptedImport()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
|
|
|
.Verify(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<DownloadClientItem>()), Times.Never());
|
|
|
|
.Verify(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()), Times.Never());
|
|
|
|
|
|
|
|
|
|
|
|
AssertNoCompletedDownload();
|
|
|
|
AssertNoCompletedDownload();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -242,7 +277,7 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
private void AssertCompletedDownload()
|
|
|
|
private void AssertCompletedDownload()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
|
|
|
.Verify(v => v.ProcessPath(_trackedDownload.DownloadItem.OutputPath.FullPath, _trackedDownload.DownloadItem), Times.Once());
|
|
|
|
.Verify(v => v.ProcessPath(_trackedDownload.DownloadItem.OutputPath.FullPath, _trackedDownload.RemoteEpisode.Series, _trackedDownload.DownloadItem), Times.Once());
|
|
|
|
|
|
|
|
|
|
|
|
_trackedDownload.State.Should().Be(TrackedDownloadStage.Imported);
|
|
|
|
_trackedDownload.State.Should().Be(TrackedDownloadStage.Imported);
|
|
|
|
}
|
|
|
|
}
|
|
|
|