Radarr/src/NzbDrone.Core.Test/Download/DownloadClientTests/PneumaticProviderFixture.cs

107 lines
3.7 KiB
C#
Raw Normal View History

using System;
using System.IO;
2012-08-30 00:20:48 +00:00
using System.Net;
using System.Threading.Tasks;
using FizzWare.NBuilder;
2012-08-30 00:20:48 +00:00
using Moq;
using NLog;
2012-08-30 00:20:48 +00:00
using NUnit.Framework;
using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Download;
using NzbDrone.Core.Download.Clients.Pneumatic;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Parser.Model;
2012-08-30 00:20:48 +00:00
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Test.IndexerTests;
2012-08-30 00:20:48 +00:00
using NzbDrone.Test.Common;
2013-04-01 06:22:16 +00:00
namespace NzbDrone.Core.Test.Download.DownloadClientTests
2012-08-30 00:20:48 +00:00
{
[TestFixture]
public class PneumaticProviderFixture : CoreTest<Pneumatic>
2012-08-30 00:20:48 +00:00
{
private const string _nzbUrl = "http://www.nzbs.com/url";
private const string _title = "30.Rock.S01E05.hdtv.xvid-LoL";
2013-07-26 05:29:59 +00:00
private string _pneumaticFolder;
2018-11-23 07:03:32 +00:00
private string _strmFolder;
private string _nzbPath;
Fixed all tests and even added some new ones :) (#835) * First fixing of tests. * Updated more tests. * Fix some tests * Fix all prioritization tests. And add new for preferred words. * Updated CompletedDownloadservice tests * Fixed a lot of tests * Fixed all indexer requests. We should add more for the indexers we added. To lazy for that though ¯\_(ツ)_/¯ * Fixed organizer tests. Should probably be also updated to incorporate our newly added tags. * Fix notification tests. * Fixed update test for osx * Fixed a few more tests. * Fixed some more tests. * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update activity.less * Update appveyor.yml * Update appveyor.yml * Update CommonVersionInfo.cs * Update build-appveyor.cake Let's hope this works. * Update CommonVersionInfo.cs Just to kickstart appveyor * Fixed a few tests * Just ignore those tests. * Fixed more tests. * First steps in fixing Core.Test.Download.DownloadApprovedFixture * Fix most DownloadApprovedFixture tests * Fixed something. * Fixed a few more tests. * Fixed pending release tests. * All Core tests are now fixed. * Fixed the last tests :) * Fixed Download Station Tests. * Fixed Vuze and Transmission default settings which caused the tests to fail. * Fix most tests. * Fix RootFolder tests. * Fixed last tests
2017-03-06 21:23:25 +00:00
private RemoteMovie _remoteMovie;
private IIndexer _indexer;
private DownloadClientItem _downloadClientItem;
2012-08-30 00:20:48 +00:00
[SetUp]
public void Setup()
{
2013-07-26 05:29:59 +00:00
_pneumaticFolder = @"d:\nzb\pneumatic\".AsOsAgnostic();
_nzbPath = Path.Combine(_pneumaticFolder, _title + ".nzb").AsOsAgnostic();
2018-11-23 07:03:32 +00:00
_strmFolder = @"d:\unsorted tv\".AsOsAgnostic();
Fixed all tests and even added some new ones :) (#835) * First fixing of tests. * Updated more tests. * Fix some tests * Fix all prioritization tests. And add new for preferred words. * Updated CompletedDownloadservice tests * Fixed a lot of tests * Fixed all indexer requests. We should add more for the indexers we added. To lazy for that though ¯\_(ツ)_/¯ * Fixed organizer tests. Should probably be also updated to incorporate our newly added tags. * Fix notification tests. * Fixed update test for osx * Fixed a few more tests. * Fixed some more tests. * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update activity.less * Update appveyor.yml * Update appveyor.yml * Update CommonVersionInfo.cs * Update build-appveyor.cake Let's hope this works. * Update CommonVersionInfo.cs Just to kickstart appveyor * Fixed a few tests * Just ignore those tests. * Fixed more tests. * First steps in fixing Core.Test.Download.DownloadApprovedFixture * Fix most DownloadApprovedFixture tests * Fixed something. * Fixed a few more tests. * Fixed pending release tests. * All Core tests are now fixed. * Fixed the last tests :) * Fixed Download Station Tests. * Fixed Vuze and Transmission default settings which caused the tests to fail. * Fix most tests. * Fix RootFolder tests. * Fixed last tests
2017-03-06 21:23:25 +00:00
_remoteMovie = new RemoteMovie();
_remoteMovie.Release = new ReleaseInfo();
_remoteMovie.Release.Title = _title;
_remoteMovie.Release.DownloadUrl = _nzbUrl;
_remoteMovie.ParsedMovieInfo = new ParsedMovieInfo();
_indexer = new TestIndexer(Mocker.Resolve<IHttpClient>(),
Mocker.Resolve<IIndexerStatusService>(),
Mocker.Resolve<IConfigService>(),
Mocker.Resolve<IParsingService>(),
Mocker.Resolve<Logger>());
_downloadClientItem = Builder<DownloadClientItem>
.CreateNew().With(d => d.DownloadId = "_Droned.S01E01.Pilot.1080p.WEB-DL-DRONE_0")
.Build();
Subject.Definition = new DownloadClientDefinition();
Subject.Definition.Settings = new PneumaticSettings
{
2018-11-23 07:03:32 +00:00
NzbFolder = _pneumaticFolder,
StrmFolder = _strmFolder
};
2012-08-30 00:20:48 +00:00
}
private void WithFailedDownload()
{
Mocker.GetMock<IHttpClient>().Setup(c => c.DownloadFileAsync(It.IsAny<string>(), It.IsAny<string>())).Throws(new WebException());
2012-08-30 00:20:48 +00:00
}
[Test]
public async Task should_download_file_if_it_doesnt_exist()
2012-08-30 00:20:48 +00:00
{
await Subject.Download(_remoteMovie, _indexer);
2012-08-30 00:20:48 +00:00
Mocker.GetMock<IHttpClient>().Verify(c => c.DownloadFileAsync(_nzbUrl, _nzbPath), Times.Once());
2012-08-30 00:20:48 +00:00
}
[Test]
2013-08-17 23:27:18 +00:00
public void should_throw_on_failed_download()
2012-08-30 00:20:48 +00:00
{
WithFailedDownload();
Assert.ThrowsAsync<WebException>(async () => await Subject.Download(_remoteMovie, _indexer));
2012-08-30 00:20:48 +00:00
}
[Test]
public void should_throw_item_is_removed()
{
Assert.Throws<NotSupportedException>(() => Subject.RemoveItem(_downloadClientItem, true));
2012-08-30 00:20:48 +00:00
}
[Test]
public async Task should_replace_illegal_characters_in_title()
{
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");
Fixed all tests and even added some new ones :) (#835) * First fixing of tests. * Updated more tests. * Fix some tests * Fix all prioritization tests. And add new for preferred words. * Updated CompletedDownloadservice tests * Fixed a lot of tests * Fixed all indexer requests. We should add more for the indexers we added. To lazy for that though ¯\_(ツ)_/¯ * Fixed organizer tests. Should probably be also updated to incorporate our newly added tags. * Fix notification tests. * Fixed update test for osx * Fixed a few more tests. * Fixed some more tests. * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update activity.less * Update appveyor.yml * Update appveyor.yml * Update CommonVersionInfo.cs * Update build-appveyor.cake Let's hope this works. * Update CommonVersionInfo.cs Just to kickstart appveyor * Fixed a few tests * Just ignore those tests. * Fixed more tests. * First steps in fixing Core.Test.Download.DownloadApprovedFixture * Fix most DownloadApprovedFixture tests * Fixed something. * Fixed a few more tests. * Fixed pending release tests. * All Core tests are now fixed. * Fixed the last tests :) * Fixed Download Station Tests. * Fixed Vuze and Transmission default settings which caused the tests to fail. * Fix most tests. * Fix RootFolder tests. * Fixed last tests
2017-03-06 21:23:25 +00:00
_remoteMovie.Release.Title = illegalTitle;
await Subject.Download(_remoteMovie, _indexer);
Mocker.GetMock<IHttpClient>().Verify(c => c.DownloadFileAsync(It.IsAny<string>(), expectedFilename), Times.Once());
}
2012-08-30 00:20:48 +00:00
}
}