Download Handling, Clean Up Drone Folder Leftovers

This commit is contained in:
Qstick
2017-09-17 23:00:37 -04:00
parent 9f689c0233
commit 405e7f981d
24 changed files with 467 additions and 754 deletions
@@ -1,10 +1,9 @@
using System;
using System;
using System.IO;
using System.Net;
using Moq;
using NUnit.Framework;
using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Download;
using NzbDrone.Core.Download.Clients.Pneumatic;
using NzbDrone.Core.Parser.Model;
@@ -19,9 +18,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
private const string _nzbUrl = "http://www.nzbs.com/url";
private const string _title = "30.Rock.S01E05.hdtv.xvid-LoL";
private string _pneumaticFolder;
private string _sabDrop;
private string _strmFolder;
private string _nzbPath;
private RemoteAlbum _remoteEpisode;
private RemoteAlbum _remoteAlbum;
[SetUp]
public void Setup()
@@ -29,21 +28,20 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
_pneumaticFolder = @"d:\nzb\pneumatic\".AsOsAgnostic();
_nzbPath = Path.Combine(_pneumaticFolder, _title + ".nzb").AsOsAgnostic();
_sabDrop = @"d:\unsorted tv\".AsOsAgnostic();
_strmFolder = @"d:\unsorted tv\".AsOsAgnostic();
Mocker.GetMock<IConfigService>().SetupGet(c => c.DownloadedAlbumsFolder).Returns(_sabDrop);
_remoteAlbum = new RemoteAlbum();
_remoteAlbum.Release = new ReleaseInfo();
_remoteAlbum.Release.Title = _title;
_remoteAlbum.Release.DownloadUrl = _nzbUrl;
_remoteEpisode = new RemoteAlbum();
_remoteEpisode.Release = new ReleaseInfo();
_remoteEpisode.Release.Title = _title;
_remoteEpisode.Release.DownloadUrl = _nzbUrl;
_remoteEpisode.ParsedAlbumInfo = new ParsedAlbumInfo();
_remoteAlbum.ParsedAlbumInfo = new ParsedAlbumInfo();
Subject.Definition = new DownloadClientDefinition();
Subject.Definition.Settings = new PneumaticSettings
{
NzbFolder = _pneumaticFolder
NzbFolder = _pneumaticFolder,
StrmFolder = _strmFolder
};
}
@@ -55,26 +53,25 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
[Test]
public void should_download_file_if_it_doesnt_exist()
{
Subject.Download(_remoteEpisode);
Subject.Download(_remoteAlbum);
Mocker.GetMock<IHttpClient>().Verify(c => c.DownloadFile(_nzbUrl, _nzbPath), Times.Once());
}
[Test]
public void should_throw_on_failed_download()
{
WithFailedDownload();
Assert.Throws<WebException>(() => Subject.Download(_remoteEpisode));
Assert.Throws<WebException>(() => Subject.Download(_remoteAlbum));
}
[Test]
public void should_throw_if_full_season_download()
{
_remoteEpisode.Release.Title = "30 Rock - Season 1";
_remoteAlbum.Release.Title = "30 Rock - Season 1";
Assert.Throws<NotSupportedException>(() => Subject.Download(_remoteEpisode));
Assert.Throws<NotSupportedException>(() => Subject.Download(_remoteAlbum));
}
[Test]
@@ -88,9 +85,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
{
var illegalTitle = "Saturday Night Live - S38E08 - Jeremy Renner/Maroon 5 [SDTV]";
var expectedFilename = Path.Combine(_pneumaticFolder, "Saturday Night Live - S38E08 - Jeremy Renner+Maroon 5 [SDTV].nzb");
_remoteEpisode.Release.Title = illegalTitle;
_remoteAlbum.Release.Title = illegalTitle;
Subject.Download(_remoteEpisode);
Subject.Download(_remoteAlbum);
Mocker.GetMock<IHttpClient>().Verify(c => c.DownloadFile(It.IsAny<string>(), expectedFilename), Times.Once());
}