mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-18 21:34:28 -04:00
Episodes older than 14 days have their own priority
This commit is contained in:
@@ -6,6 +6,7 @@ using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Download.Clients;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
@@ -14,21 +15,26 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
|
||||
[TestFixture]
|
||||
public class BlackholeProviderFixture : CoreTest<BlackholeProvider>
|
||||
{
|
||||
private const string nzbUrl = "http://www.nzbs.com/url";
|
||||
private const string title = "some_nzb_title";
|
||||
private const string blackHoleFolder = @"d:\nzb\blackhole\";
|
||||
private const string nzbPath = @"d:\nzb\blackhole\some_nzb_title.nzb";
|
||||
private const string _nzbUrl = "http://www.nzbs.com/url";
|
||||
private const string _title = "some_nzb_title";
|
||||
private const string _blackHoleFolder = @"d:\nzb\blackhole\";
|
||||
private const string _nzbPath = @"d:\nzb\blackhole\some_nzb_title.nzb";
|
||||
private RemoteEpisode _remoteEpisode;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
Mocker.GetMock<IConfigService>().SetupGet(c => c.BlackholeFolder).Returns(blackHoleFolder);
|
||||
}
|
||||
Mocker.GetMock<IConfigService>().SetupGet(c => c.BlackholeFolder).Returns(_blackHoleFolder);
|
||||
|
||||
_remoteEpisode = new RemoteEpisode();
|
||||
_remoteEpisode.Report = new ReportInfo();
|
||||
_remoteEpisode.Report.Title = _title;
|
||||
_remoteEpisode.Report.NzbUrl = _nzbUrl;
|
||||
}
|
||||
|
||||
private void WithExistingFile()
|
||||
{
|
||||
Mocker.GetMock<IDiskProvider>().Setup(c => c.FileExists(nzbPath)).Returns(true);
|
||||
Mocker.GetMock<IDiskProvider>().Setup(c => c.FileExists(_nzbPath)).Returns(true);
|
||||
}
|
||||
|
||||
private void WithFailedDownload()
|
||||
@@ -39,9 +45,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
|
||||
[Test]
|
||||
public void DownloadNzb_should_download_file_if_it_doesnt_exist()
|
||||
{
|
||||
Subject.DownloadNzb(nzbUrl, title).Should().BeTrue();
|
||||
Subject.DownloadNzb(_remoteEpisode).Should().BeTrue();
|
||||
|
||||
Mocker.GetMock<IHttpProvider>().Verify(c => c.DownloadFile(nzbUrl, nzbPath), Times.Once());
|
||||
Mocker.GetMock<IHttpProvider>().Verify(c => c.DownloadFile(_nzbUrl, _nzbPath), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -49,7 +55,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
|
||||
{
|
||||
WithExistingFile();
|
||||
|
||||
Subject.DownloadNzb(nzbUrl, title).Should().BeTrue();
|
||||
Subject.DownloadNzb(_remoteEpisode).Should().BeTrue();
|
||||
|
||||
Mocker.GetMock<IHttpProvider>().Verify(c => c.DownloadFile(It.IsAny<string>(), It.IsAny<string>()), Times.Never());
|
||||
}
|
||||
@@ -59,7 +65,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
|
||||
{
|
||||
WithFailedDownload();
|
||||
|
||||
Subject.DownloadNzb(nzbUrl, title).Should().BeFalse();
|
||||
Subject.DownloadNzb(_remoteEpisode).Should().BeFalse();
|
||||
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
@@ -68,9 +74,10 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
|
||||
public void should_replace_illegal_characters_in_title()
|
||||
{
|
||||
var illegalTitle = "Saturday Night Live - S38E08 - Jeremy Renner/Maroon 5 [SDTV]";
|
||||
var expectedFilename = Path.Combine(blackHoleFolder, "Saturday Night Live - S38E08 - Jeremy Renner+Maroon 5 [SDTV].nzb");
|
||||
var expectedFilename = Path.Combine(_blackHoleFolder, "Saturday Night Live - S38E08 - Jeremy Renner+Maroon 5 [SDTV].nzb");
|
||||
_remoteEpisode.Report.Title = illegalTitle;
|
||||
|
||||
Subject.DownloadNzb(nzbUrl, illegalTitle).Should().BeTrue();
|
||||
Subject.DownloadNzb(_remoteEpisode).Should().BeTrue();
|
||||
|
||||
Mocker.GetMock<IHttpProvider>().Verify(c => c.DownloadFile(It.IsAny<string>(), expectedFilename), Times.Once());
|
||||
}
|
||||
|
||||
+12
-6
@@ -5,12 +5,17 @@ using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Download.Clients.Nzbget;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetProviderTests
|
||||
{
|
||||
public class DownloadNzbFixture : CoreTest
|
||||
{
|
||||
private const string _url = "http://www.nzbdrone.com";
|
||||
private const string _title = "30 Rock - S01E01 - Pilot [HDTV-720p]";
|
||||
private RemoteEpisode _remoteEpisode;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
@@ -21,8 +26,12 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetProviderTests
|
||||
fakeConfig.SetupGet(c => c.NzbgetPassword).Returns("pass");
|
||||
fakeConfig.SetupGet(c => c.NzbgetTvCategory).Returns("TV");
|
||||
fakeConfig.SetupGet(c => c.NzbgetRecentTvPriority).Returns(PriorityType.High);
|
||||
}
|
||||
|
||||
_remoteEpisode = new RemoteEpisode();
|
||||
_remoteEpisode.Report = new ReportInfo();
|
||||
_remoteEpisode.Report.Title = _title;
|
||||
_remoteEpisode.Report.NzbUrl = _url;
|
||||
}
|
||||
|
||||
private void WithFailResponse()
|
||||
{
|
||||
@@ -34,16 +43,13 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetProviderTests
|
||||
[Test]
|
||||
public void should_add_item_to_queue()
|
||||
{
|
||||
const string url = "http://www.nzbdrone.com";
|
||||
const string title = "30 Rock - S01E01 - Pilot [HDTV-720p]";
|
||||
|
||||
Mocker.GetMock<IHttpProvider>()
|
||||
.Setup(s => s.PostCommand("192.168.5.55:6789", "nzbget", "pass",
|
||||
It.Is<String>(c => c.Equals("{\"method\":\"appendurl\",\"params\":[\"30 Rock - S01E01 - Pilot [HDTV-720p]\",\"TV\",50,false,\"http://www.nzbdrone.com\"]}"))))
|
||||
.Returns("{\"version\": \"1.1\",\"result\": true}");
|
||||
|
||||
Mocker.Resolve<NzbgetClient>()
|
||||
.DownloadNzb(url, title)
|
||||
.DownloadNzb(_remoteEpisode)
|
||||
.Should()
|
||||
.BeTrue();
|
||||
}
|
||||
@@ -53,7 +59,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetProviderTests
|
||||
{
|
||||
WithFailResponse();
|
||||
|
||||
Assert.Throws<ApplicationException>(() => Mocker.Resolve<NzbgetClient>().DownloadNzb("http://www.nzbdrone.com", "30 Rock - S01E01 - Pilot [HDTV-720p]"));
|
||||
Assert.Throws<ApplicationException>(() => Mocker.Resolve<NzbgetClient>().DownloadNzb(_remoteEpisode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,32 +6,42 @@ using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Download.Clients;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.Download.DownloadClientTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class PneumaticProviderFixture : CoreTest
|
||||
public class PneumaticProviderFixture : CoreTest<PneumaticClient>
|
||||
{
|
||||
private const string nzbUrl = "http://www.nzbs.com/url";
|
||||
private const string title = "30.Rock.S01E05.hdtv.xvid-LoL";
|
||||
private const string pneumaticFolder = @"d:\nzb\pneumatic\";
|
||||
private const string sabDrop = @"d:\unsorted tv\";
|
||||
private string nzbPath;
|
||||
private const string _nzbUrl = "http://www.nzbs.com/url";
|
||||
private const string _title = "30.Rock.S01E05.hdtv.xvid-LoL";
|
||||
private const string _pneumaticFolder = @"d:\nzb\pneumatic\";
|
||||
private const string _sabDrop = @"d:\unsorted tv\";
|
||||
private string _nzbPath;
|
||||
private RemoteEpisode _remoteEpisode;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
nzbPath = pneumaticFolder + title + ".nzb";
|
||||
_nzbPath = _pneumaticFolder + _title + ".nzb";
|
||||
|
||||
Mocker.GetMock<IConfigService>().SetupGet(c => c.PneumaticFolder).Returns(pneumaticFolder);
|
||||
Mocker.GetMock<IConfigService>().SetupGet(c => c.DownloadedEpisodesFolder).Returns(sabDrop);
|
||||
Mocker.GetMock<IConfigService>().SetupGet(c => c.PneumaticFolder).Returns(_pneumaticFolder);
|
||||
Mocker.GetMock<IConfigService>().SetupGet(c => c.DownloadedEpisodesFolder).Returns(_sabDrop);
|
||||
|
||||
_remoteEpisode = new RemoteEpisode();
|
||||
_remoteEpisode.Report = new ReportInfo();
|
||||
_remoteEpisode.Report.Title = _title;
|
||||
_remoteEpisode.Report.NzbUrl = _nzbUrl;
|
||||
|
||||
_remoteEpisode.ParsedEpisodeInfo = new ParsedEpisodeInfo();
|
||||
_remoteEpisode.ParsedEpisodeInfo.FullSeason = false;
|
||||
}
|
||||
|
||||
private void WithExistingFile()
|
||||
{
|
||||
Mocker.GetMock<IDiskProvider>().Setup(c => c.FileExists(nzbPath)).Returns(true);
|
||||
Mocker.GetMock<IDiskProvider>().Setup(c => c.FileExists(_nzbPath)).Returns(true);
|
||||
}
|
||||
|
||||
private void WithFailedDownload()
|
||||
@@ -42,9 +52,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
|
||||
[Test]
|
||||
public void should_download_file_if_it_doesnt_exist()
|
||||
{
|
||||
Mocker.Resolve<PneumaticClient>().DownloadNzb(nzbUrl, title).Should().BeTrue();
|
||||
Subject.DownloadNzb(_remoteEpisode).Should().BeTrue();
|
||||
|
||||
Mocker.GetMock<IHttpProvider>().Verify(c => c.DownloadFile(nzbUrl, nzbPath),Times.Once());
|
||||
Mocker.GetMock<IHttpProvider>().Verify(c => c.DownloadFile(_nzbUrl, _nzbPath),Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -52,7 +62,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
|
||||
{
|
||||
WithExistingFile();
|
||||
|
||||
Mocker.Resolve<PneumaticClient>().DownloadNzb(nzbUrl, title).Should().BeTrue();
|
||||
Subject.DownloadNzb(_remoteEpisode).Should().BeTrue();
|
||||
|
||||
Mocker.GetMock<IHttpProvider>().Verify(c => c.DownloadFile(It.IsAny<string>(), It.IsAny<string>()), Times.Never());
|
||||
}
|
||||
@@ -62,7 +72,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
|
||||
{
|
||||
WithFailedDownload();
|
||||
|
||||
Mocker.Resolve<PneumaticClient>().DownloadNzb(nzbUrl, title).Should().BeFalse();
|
||||
Subject.DownloadNzb(_remoteEpisode).Should().BeFalse();
|
||||
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
@@ -70,16 +80,20 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
|
||||
[Test]
|
||||
public void should_skip_if_full_season_download()
|
||||
{
|
||||
Mocker.Resolve<PneumaticClient>().DownloadNzb(nzbUrl, "30 Rock - Season 1").Should().BeFalse();
|
||||
_remoteEpisode.Report.Title = "30 Rock - Season 1";
|
||||
_remoteEpisode.ParsedEpisodeInfo.FullSeason = true;
|
||||
|
||||
Mocker.Resolve<PneumaticClient>().DownloadNzb(_remoteEpisode).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void 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");
|
||||
var expectedFilename = Path.Combine(_pneumaticFolder, "Saturday Night Live - S38E08 - Jeremy Renner+Maroon 5 [SDTV].nzb");
|
||||
_remoteEpisode.Report.Title = illegalTitle;
|
||||
|
||||
Mocker.Resolve<PneumaticClient>().DownloadNzb(nzbUrl, illegalTitle).Should().BeTrue();
|
||||
Subject.DownloadNzb(_remoteEpisode).Should().BeTrue();
|
||||
|
||||
Mocker.GetMock<IHttpProvider>().Verify(c => c.DownloadFile(It.IsAny<string>(), expectedFilename), Times.Once());
|
||||
}
|
||||
|
||||
+12
-6
@@ -6,6 +6,7 @@ using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Download.Clients.Sabnzbd;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
@@ -17,6 +18,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabProviderTests
|
||||
{
|
||||
private const string URL = "http://www.nzbclub.com/nzb_download.aspx?mid=1950232";
|
||||
private const string TITLE = "My Series Name - 5x2-5x3 - My title [Bluray720p] [Proper]";
|
||||
private RemoteEpisode _remoteEpisode;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
@@ -29,6 +31,11 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabProviderTests
|
||||
fakeConfig.SetupGet(c => c.SabUsername).Returns("admin");
|
||||
fakeConfig.SetupGet(c => c.SabPassword).Returns("pass");
|
||||
fakeConfig.SetupGet(c => c.SabTvCategory).Returns("tv");
|
||||
|
||||
_remoteEpisode = new RemoteEpisode();
|
||||
_remoteEpisode.Report = new ReportInfo();
|
||||
_remoteEpisode.Report.Title = TITLE;
|
||||
_remoteEpisode.Report.NzbUrl = URL;
|
||||
}
|
||||
|
||||
private void WithFailResponse()
|
||||
@@ -45,14 +52,14 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabProviderTests
|
||||
.Returns("{ \"status\": true }");
|
||||
|
||||
|
||||
Subject.DownloadNzb(URL, TITLE).Should().BeTrue();
|
||||
Subject.DownloadNzb(_remoteEpisode).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void add_by_url_should_detect_and_handle_sab_errors()
|
||||
{
|
||||
WithFailResponse();
|
||||
Assert.Throws<ApplicationException>(() => Subject.DownloadNzb(URL, TITLE).Should().BeFalse());
|
||||
Assert.Throws<ApplicationException>(() => Subject.DownloadNzb(_remoteEpisode).Should().BeFalse());
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -186,7 +193,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabProviderTests
|
||||
Mocker.GetMock<IHttpProvider>()
|
||||
.Setup(s => s.DownloadString(It.IsAny<String>())).Throws(new WebException());
|
||||
|
||||
Subject.DownloadNzb(URL, TITLE).Should().BeFalse();
|
||||
Subject.DownloadNzb(_remoteEpisode).Should().BeFalse();
|
||||
ExceptionVerification.ExpectedErrors(1);
|
||||
}
|
||||
|
||||
@@ -203,11 +210,10 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabProviderTests
|
||||
.Returns("{ \"status\": true }");
|
||||
|
||||
|
||||
Subject.DownloadNzb(URL, TITLE).Should().BeTrue();
|
||||
Subject.DownloadNzb(_remoteEpisode).Should().BeTrue();
|
||||
|
||||
Mocker.GetMock<IHttpProvider>()
|
||||
.Verify(v => v.DownloadString("http://192.168.5.55:2222/api?mode=addurl&name=http://www.nzbclub.com/nzb_download.aspx?mid=1950232&priority=1&pp=3&cat=tv&nzbname=My+Series+Name+-+5x2-5x3+-+My+title+%5bBluray720p%5d+%5bProper%5d&output=json&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"), Times.Once());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,14 +37,14 @@ namespace NzbDrone.Core.Test.Download
|
||||
private void WithSuccessfulAdd()
|
||||
{
|
||||
Mocker.GetMock<IDownloadClient>()
|
||||
.Setup(s => s.DownloadNzb(It.IsAny<String>(), It.IsAny<String>()))
|
||||
.Setup(s => s.DownloadNzb(It.IsAny<RemoteEpisode>()))
|
||||
.Returns(true);
|
||||
}
|
||||
|
||||
private void WithFailedAdd()
|
||||
{
|
||||
Mocker.GetMock<IDownloadClient>()
|
||||
.Setup(s => s.DownloadNzb(It.IsAny<String>(), It.IsAny<String>()))
|
||||
.Setup(s => s.DownloadNzb(It.IsAny<RemoteEpisode>()))
|
||||
.Returns(false);
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace NzbDrone.Core.Test.Download
|
||||
Subject.DownloadReport(_parseResult);
|
||||
|
||||
Mocker.GetMock<IDownloadClient>()
|
||||
.Verify(s => s.DownloadNzb(It.IsAny<String>(), It.IsAny<String>()), Times.Once());
|
||||
.Verify(s => s.DownloadNzb(It.IsAny<RemoteEpisode>()), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -77,8 +77,5 @@ namespace NzbDrone.Core.Test.Download
|
||||
Subject.DownloadReport(_parseResult);
|
||||
VerifyEventNotPublished<EpisodeGrabbedEvent>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user