|
|
|
@ -11,6 +11,7 @@ using Moq;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using NzbDrone.Common;
|
|
|
|
|
using NzbDrone.Core.Model;
|
|
|
|
|
using NzbDrone.Core.Model.Sabnzbd;
|
|
|
|
|
using NzbDrone.Core.Providers.Core;
|
|
|
|
|
using NzbDrone.Core.Providers.DownloadClients;
|
|
|
|
|
using NzbDrone.Core.Repository;
|
|
|
|
@ -54,7 +55,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests
|
|
|
|
|
.Returns("{ \"status\": true }");
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
Mocker.Resolve<SabProvider>().DownloadNzb(url, title).Should().BeTrue();
|
|
|
|
|
Mocker.Resolve<SabProvider>().DownloadNzb(url, title, false).Should().BeTrue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
@ -66,7 +67,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
bool result = Mocker.Resolve<SabProvider>().DownloadNzb("http://www.newzbin.com/browse/post/6107863/nzb", title);
|
|
|
|
|
bool result = Mocker.Resolve<SabProvider>().DownloadNzb("http://www.newzbin.com/browse/post/6107863/nzb", title, false);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeTrue();
|
|
|
|
@ -78,7 +79,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests
|
|
|
|
|
WithFailResponse();
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
Assert.Throws<ApplicationException>(() => Mocker.Resolve<SabProvider>().DownloadNzb(url, title).Should().BeFalse());
|
|
|
|
|
Assert.Throws<ApplicationException>(() => Mocker.Resolve<SabProvider>().DownloadNzb(url, title, false).Should().BeFalse());
|
|
|
|
|
//ExceptionVerification.ExpectedErrors(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -216,8 +217,52 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests
|
|
|
|
|
Mocker.GetMock<HttpProvider>()
|
|
|
|
|
.Setup(s => s.DownloadString(It.IsAny<String>())).Throws(new WebException());
|
|
|
|
|
|
|
|
|
|
Mocker.Resolve<SabProvider>().DownloadNzb(url, title).Should().BeFalse();
|
|
|
|
|
Mocker.Resolve<SabProvider>().DownloadNzb(url, title, false).Should().BeFalse();
|
|
|
|
|
ExceptionVerification.ExpectedErrors(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void downloadNzb_should_use_sabRecentTvPriority_when_recentEpisode_is_true()
|
|
|
|
|
{
|
|
|
|
|
Mocker.GetMock<ConfigProvider>()
|
|
|
|
|
.SetupGet(s => s.SabRecentTvPriority)
|
|
|
|
|
.Returns(SabPriorityType.High);
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<ConfigProvider>()
|
|
|
|
|
.SetupGet(s => s.SabBacklogTvPriority)
|
|
|
|
|
.Returns(SabPriorityType.Low);
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<HttpProvider>()
|
|
|
|
|
.Setup(s => s.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"))
|
|
|
|
|
.Returns("{ \"status\": true }");
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
Mocker.Resolve<SabProvider>().DownloadNzb(url, title, true).Should().BeTrue();
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<HttpProvider>()
|
|
|
|
|
.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());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void downloadNzb_should_use_sabBackogTvPriority_when_recentEpisode_is_false()
|
|
|
|
|
{
|
|
|
|
|
Mocker.GetMock<ConfigProvider>()
|
|
|
|
|
.SetupGet(s => s.SabRecentTvPriority)
|
|
|
|
|
.Returns(SabPriorityType.High);
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<ConfigProvider>()
|
|
|
|
|
.SetupGet(s => s.SabBacklogTvPriority)
|
|
|
|
|
.Returns(SabPriorityType.Low);
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<HttpProvider>()
|
|
|
|
|
.Setup(s => s.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"))
|
|
|
|
|
.Returns("{ \"status\": true }");
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
Mocker.Resolve<SabProvider>().DownloadNzb(url, title, false).Should().BeTrue();
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<HttpProvider>()
|
|
|
|
|
.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());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|