Changed: Sabnzbd Update test cases and rename to MovieCategory (#2212)

pull/2210/merge
James White 7 years ago committed by Leonardo Galli
parent 5674d8ad60
commit 386a434aeb

@ -36,7 +36,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests
ApiKey = "5c770e3197e4fe763423ee7c392c25d1", ApiKey = "5c770e3197e4fe763423ee7c392c25d1",
Username = "admin", Username = "admin",
Password = "pass", Password = "pass",
TvCategory = "tv", MovieCategory = "movie",
RecentTvPriority = (int)SabnzbdPriority.High RecentTvPriority = (int)SabnzbdPriority.High
}; };
_queued = new SabnzbdQueue _queued = new SabnzbdQueue
@ -51,7 +51,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests
Size = 1000, Size = 1000,
Sizeleft = 10, Sizeleft = 10,
Timeleft = TimeSpan.FromSeconds(10), Timeleft = TimeSpan.FromSeconds(10),
Category = "tv", Category = "movie",
Id = "sabnzbd_nzb12345", Id = "sabnzbd_nzb12345",
Title = "Droned.1998.1080p.WEB-DL-DRONE" Title = "Droned.1998.1080p.WEB-DL-DRONE"
} }
@ -66,7 +66,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests
{ {
Status = SabnzbdDownloadStatus.Failed, Status = SabnzbdDownloadStatus.Failed,
Size = 1000, Size = 1000,
Category = "tv", Category = "movie",
Id = "sabnzbd_nzb12345", Id = "sabnzbd_nzb12345",
Title = "Droned.1998.1080p.WEB-DL-DRONE" Title = "Droned.1998.1080p.WEB-DL-DRONE"
} }
@ -81,7 +81,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests
{ {
Status = SabnzbdDownloadStatus.Completed, Status = SabnzbdDownloadStatus.Completed,
Size = 1000, Size = 1000,
Category = "tv", Category = "movie",
Id = "sabnzbd_nzb12345", Id = "sabnzbd_nzb12345",
Title = "Droned.1998.1080p.WEB-DL-DRONE", Title = "Droned.1998.1080p.WEB-DL-DRONE",
Storage = "/remote/mount/vv/Droned.1998.1080p.WEB-DL-DRONE" Storage = "/remote/mount/vv/Droned.1998.1080p.WEB-DL-DRONE"
@ -97,7 +97,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests
}, },
Categories = new List<SabnzbdCategory> Categories = new List<SabnzbdCategory>
{ {
new SabnzbdCategory { Name = "tv", Dir = "vv" } new SabnzbdCategory { Name = "movie", Dir = "vv" }
} }
}; };
@ -111,7 +111,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests
_fullStatus = new SabnzbdFullStatus _fullStatus = new SabnzbdFullStatus
{ {
CompleteDir = @"Y:\nzbget\root\complete".AsOsAgnostic() CompleteDir = @"Y:\sabnzbd\root\complete".AsOsAgnostic()
}; };
Mocker.GetMock<ISabnzbdProxy>() Mocker.GetMock<ISabnzbdProxy>()
@ -408,10 +408,10 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests
result.OutputPath.Should().Be(@"C:\sorted\somewhere\asdfasdf\asdfasdf.mkv".AsOsAgnostic()); result.OutputPath.Should().Be(@"C:\sorted\somewhere\asdfasdf\asdfasdf.mkv".AsOsAgnostic());
} }
[TestCase(@"Y:\nzbget\root", @"completed\downloads", @"vv", @"Y:\nzbget\root\completed\downloads", @"Y:\nzbget\root\completed\downloads\vv")] [TestCase(@"Y:\sabnzbd\root", @"completed\downloads", @"vv", @"Y:\sabnzbd\root\completed\downloads", @"Y:\sabnzbd\root\completed\downloads\vv")]
[TestCase(@"Y:\nzbget\root", @"completed", @"vv", @"Y:\nzbget\root\completed", @"Y:\nzbget\root\completed\vv")] [TestCase(@"Y:\sabnzbd\root", @"completed", @"vv", @"Y:\sabnzbd\root\completed", @"Y:\sabnzbd\root\completed\vv")]
[TestCase(@"/nzbget/root", @"completed/downloads", @"vv", @"/nzbget/root/completed/downloads", @"/nzbget/root/completed/downloads/vv")] [TestCase(@"/sabnzbd/root", @"completed/downloads", @"vv", @"/sabnzbd/root/completed/downloads", @"/sabnzbd/root/completed/downloads/vv")]
[TestCase(@"/nzbget/root", @"completed", @"vv", @"/nzbget/root/completed", @"/nzbget/root/completed/vv")] [TestCase(@"/sabnzbd/root", @"completed", @"vv", @"/sabnzbd/root/completed", @"/sabnzbd/root/completed/vv")]
public void should_return_status_with_outputdir_for_version_lt_2(string rootFolder, string completeDir, string categoryDir, string fullCompleteDir, string fullCategoryDir) public void should_return_status_with_outputdir_for_version_lt_2(string rootFolder, string completeDir, string categoryDir, string fullCompleteDir, string fullCategoryDir)
{ {
_fullStatus.CompleteDir = null; _fullStatus.CompleteDir = null;
@ -429,10 +429,10 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests
result.OutputRootFolders.First().Should().Be(fullCategoryDir); result.OutputRootFolders.First().Should().Be(fullCategoryDir);
} }
[TestCase(@"Y:\nzbget\root", @"completed\downloads", @"vv", @"Y:\nzbget\root\completed\downloads", @"Y:\nzbget\root\completed\downloads\vv")] [TestCase(@"Y:\sabnzbd\root", @"completed\downloads", @"vv", @"Y:\sabnzbd\root\completed\downloads", @"Y:\sabnzbd\root\completed\downloads\vv")]
[TestCase(@"Y:\nzbget\root", @"completed", @"vv", @"Y:\nzbget\root\completed", @"Y:\nzbget\root\completed\vv")] [TestCase(@"Y:\sabnzbd\root", @"completed", @"vv", @"Y:\sabnzbd\root\completed", @"Y:\sabnzbd\root\completed\vv")]
[TestCase(@"/nzbget/root", @"completed/downloads", @"vv", @"/nzbget/root/completed/downloads", @"/nzbget/root/completed/downloads/vv")] [TestCase(@"/sabnzbd/root", @"completed/downloads", @"vv", @"/sabnzbd/root/completed/downloads", @"/sabnzbd/root/completed/downloads/vv")]
[TestCase(@"/nzbget/root", @"completed", @"vv", @"/nzbget/root/completed", @"/nzbget/root/completed/vv")] [TestCase(@"/sabnzbd/root", @"completed", @"vv", @"/sabnzbd/root/completed", @"/sabnzbd/root/completed/vv")]
public void should_return_status_with_outputdir_for_version_gte_2(string rootFolder, string completeDir, string categoryDir, string fullCompleteDir, string fullCategoryDir) public void should_return_status_with_outputdir_for_version_gte_2(string rootFolder, string completeDir, string categoryDir, string fullCompleteDir, string fullCategoryDir)
{ {
_fullStatus.CompleteDir = fullCompleteDir; _fullStatus.CompleteDir = fullCompleteDir;
@ -554,7 +554,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests
[Test] [Test]
public void should_test_failed_if_tv_sorting_default_category() public void should_test_failed_if_tv_sorting_default_category()
{ {
Subject.Definition.Settings.As<SabnzbdSettings>().TvCategory = null; Subject.Definition.Settings.As<SabnzbdSettings>().MovieCategory = null;
_config.Misc.enable_tv_sorting = true; _config.Misc.enable_tv_sorting = true;
_config.Misc.tv_categories = new[] { "Default" }; _config.Misc.tv_categories = new[] { "Default" };

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
@ -39,7 +39,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
protected override string AddFromNzbFile(RemoteMovie remoteMovie, string filename, byte[] fileContents) protected override string AddFromNzbFile(RemoteMovie remoteMovie, string filename, byte[] fileContents)
{ {
var category = Settings.TvCategory; var category = Settings.MovieCategory;
var priority = Settings.RecentTvPriority; var priority = Settings.RecentTvPriority;
var response = _proxy.DownloadNzb(fileContents, filename, category, priority, Settings); var response = _proxy.DownloadNzb(fileContents, filename, category, priority, Settings);
@ -119,7 +119,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
try try
{ {
sabHistory = _proxy.GetHistory(0, _configService.DownloadClientHistoryLimit, Settings.TvCategory, Settings); sabHistory = _proxy.GetHistory(0, _configService.DownloadClientHistoryLimit, Settings.MovieCategory, Settings);
} }
catch (DownloadClientException ex) catch (DownloadClientException ex)
{ {
@ -200,7 +200,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
{ {
foreach (var downloadClientItem in GetQueue().Concat(GetHistory())) foreach (var downloadClientItem in GetQueue().Concat(GetHistory()))
{ {
if (downloadClientItem.Category == Settings.TvCategory || downloadClientItem.Category == "*" && Settings.TvCategory.IsNullOrWhiteSpace()) if (downloadClientItem.Category == Settings.MovieCategory || downloadClientItem.Category == "*" && Settings.MovieCategory.IsNullOrWhiteSpace())
{ {
yield return downloadClientItem; yield return downloadClientItem;
} }
@ -254,7 +254,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
var config = _proxy.GetConfig(Settings); var config = _proxy.GetConfig(Settings);
var categories = GetCategories(config).ToArray(); var categories = GetCategories(config).ToArray();
var category = categories.FirstOrDefault(v => v.Name == Settings.TvCategory); var category = categories.FirstOrDefault(v => v.Name == Settings.MovieCategory);
if (category == null) if (category == null)
{ {
@ -366,7 +366,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
if (rawVersion.Equals("develop", StringComparison.InvariantCultureIgnoreCase)) if (rawVersion.Equals("develop", StringComparison.InvariantCultureIgnoreCase))
{ {
return new NzbDroneValidationFailure("Version", "Sabnzbd develop version, assuming version 1.1.0 or higher.") return new NzbDroneValidationFailure("Version", "SABnzbd develop version, assuming version 1.1.0 or higher.")
{ {
IsWarning = true, IsWarning = true,
DetailedDescription = "Radarr may not be able to support new features added to SABnzbd when running develop versions." DetailedDescription = "Radarr may not be able to support new features added to SABnzbd when running develop versions."
@ -419,10 +419,10 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
var config = _proxy.GetConfig(Settings); var config = _proxy.GetConfig(Settings);
if (config.Misc.pre_check && !HasVersion(1, 1)) if (config.Misc.pre_check && !HasVersion(1, 1))
{ {
return new NzbDroneValidationFailure("", "Disable 'Check before download' option in Sabnbzd") return new NzbDroneValidationFailure("", "Disable 'Check before download' option in SABnzbd")
{ {
InfoLink = string.Format("http://{0}:{1}/sabnzbd/config/switches/", Settings.Host, Settings.Port), InfoLink = string.Format("http://{0}:{1}/sabnzbd/config/switches/", Settings.Host, Settings.Port),
DetailedDescription = "Using Check before download affects Radarr ability to track new downloads. Also Sabnzbd recommends 'Abort jobs that cannot be completed' instead since it's more effective." DetailedDescription = "Using Check before download affects Radarr ability to track new downloads. Also SABnzbd recommends 'Abort jobs that cannot be completed' instead since it's more effective."
}; };
} }
@ -432,52 +432,52 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
private ValidationFailure TestCategory() private ValidationFailure TestCategory()
{ {
var config = _proxy.GetConfig(Settings); var config = _proxy.GetConfig(Settings);
var category = GetCategories(config).FirstOrDefault((SabnzbdCategory v) => v.Name == Settings.TvCategory); var category = GetCategories(config).FirstOrDefault((SabnzbdCategory v) => v.Name == Settings.MovieCategory);
if (category != null) if (category != null)
{ {
if (category.Dir.EndsWith("*")) if (category.Dir.EndsWith("*"))
{ {
return new NzbDroneValidationFailure("TvCategory", "Enable Job folders") return new NzbDroneValidationFailure("MovieCategory", "Enable Job folders")
{ {
InfoLink = string.Format("http://{0}:{1}/sabnzbd/config/categories/", Settings.Host, Settings.Port), InfoLink = string.Format("http://{0}:{1}/sabnzbd/config/categories/", Settings.Host, Settings.Port),
DetailedDescription = "Radarr prefers each download to have a separate folder. With * appended to the Folder/Path Sabnzbd will not create these job folders. Go to Sabnzbd to fix it." DetailedDescription = "Radarr prefers each download to have a separate folder. With * appended to the Folder/Path SABnzbd will not create these job folders. Go to SABnzbd to fix it."
}; };
} }
} }
else else
{ {
if (!Settings.TvCategory.IsNullOrWhiteSpace()) if (!Settings.MovieCategory.IsNullOrWhiteSpace())
{ {
return new NzbDroneValidationFailure("TvCategory", "Category does not exist") return new NzbDroneValidationFailure("MovieCategory", "Category does not exist")
{ {
InfoLink = string.Format("http://{0}:{1}/sabnzbd/config/categories/", Settings.Host, Settings.Port), InfoLink = string.Format("http://{0}:{1}/sabnzbd/config/categories/", Settings.Host, Settings.Port),
DetailedDescription = "The Category your entered doesn't exist in Sabnzbd. Go to Sabnzbd to create it." DetailedDescription = "The category you entered doesn't exist in SABnzbd. Go to SABnzbd to create it."
}; };
} }
} }
if (config.Misc.enable_tv_sorting && ContainsCategory(config.Misc.tv_categories, Settings.TvCategory)) if (config.Misc.enable_tv_sorting && ContainsCategory(config.Misc.tv_categories, Settings.MovieCategory))
{ {
return new NzbDroneValidationFailure("TvCategory", "Disable TV Sorting") return new NzbDroneValidationFailure("MovieCategory", "Disable TV Sorting")
{ {
InfoLink = string.Format("http://{0}:{1}/sabnzbd/config/sorting/", Settings.Host, Settings.Port), InfoLink = string.Format("http://{0}:{1}/sabnzbd/config/sorting/", Settings.Host, Settings.Port),
DetailedDescription = "You must disable Sabnzbd TV Sorting for the category Radarr uses to prevent import issues. Go to Sabnzbd to fix it." DetailedDescription = "You must disable SABnzbd TV Sorting for the category Radarr uses to prevent import issues. Go to SABnzbd to fix it."
}; };
} }
if (config.Misc.enable_movie_sorting && ContainsCategory(config.Misc.movie_categories, Settings.TvCategory)) if (config.Misc.enable_movie_sorting && ContainsCategory(config.Misc.movie_categories, Settings.MovieCategory))
{ {
return new NzbDroneValidationFailure("TvCategory", "Disable Movie Sorting") return new NzbDroneValidationFailure("MovieCategory", "Disable Movie Sorting")
{ {
InfoLink = string.Format("http://{0}:{1}/sabnzbd/config/sorting/", Settings.Host, Settings.Port), InfoLink = string.Format("http://{0}:{1}/sabnzbd/config/sorting/", Settings.Host, Settings.Port),
DetailedDescription = "You must disable Sabnzbd Movie Sorting for the category Radarr uses to prevent import issues. Go to Sabnzbd to fix it." DetailedDescription = "You must disable SABnzbd Movie Sorting for the category Radarr uses to prevent import issues. Go to SABnzbd to fix it."
}; };
} }
if (config.Misc.enable_date_sorting && ContainsCategory(config.Misc.date_categories, Settings.TvCategory)) if (config.Misc.enable_date_sorting && ContainsCategory(config.Misc.date_categories, Settings.MovieCategory))
{ {
return new NzbDroneValidationFailure("TvCategory", "Disable Date Sorting") return new NzbDroneValidationFailure("MovieCategory", "Disable Date Sorting")
{ {
InfoLink = string.Format("http://{0}:{1}/sabnzbd/config/sorting/", Settings.Host, Settings.Port), InfoLink = string.Format("http://{0}:{1}/sabnzbd/config/sorting/", Settings.Host, Settings.Port),
DetailedDescription = "You must disable Sabnzbd Date Sorting for the category Radarr uses to prevent import issues. Go to Sabnzbd to fix it." DetailedDescription = "You must disable SABnzbd Date Sorting for the category Radarr uses to prevent import issues. Go to SABnzbd to fix it."
}; };
} }

@ -1,4 +1,4 @@
using FluentValidation; using FluentValidation;
using NzbDrone.Core.Annotations; using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider; using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation; using NzbDrone.Core.Validation;
@ -24,7 +24,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
.WithMessage("Password is required when API key is not configured") .WithMessage("Password is required when API key is not configured")
.When(c => string.IsNullOrWhiteSpace(c.ApiKey)); .When(c => string.IsNullOrWhiteSpace(c.ApiKey));
RuleFor(c => c.TvCategory).NotEmpty() RuleFor(c => c.MovieCategory).NotEmpty()
.WithMessage("A category is recommended") .WithMessage("A category is recommended")
.AsWarning(); .AsWarning();
} }
@ -38,7 +38,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
{ {
Host = "localhost"; Host = "localhost";
Port = 8080; Port = 8080;
TvCategory = "movies"; MovieCategory = "movies";
RecentTvPriority = (int)SabnzbdPriority.Default; RecentTvPriority = (int)SabnzbdPriority.Default;
OlderTvPriority = (int)SabnzbdPriority.Default; OlderTvPriority = (int)SabnzbdPriority.Default;
} }
@ -59,7 +59,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
public string Password { get; set; } public string Password { get; set; }
[FieldDefinition(5, Label = "Category", Type = FieldType.Textbox, HelpText = "Adding a category specific to Radarr avoids conflicts with unrelated downloads, but it's optional")] [FieldDefinition(5, Label = "Category", Type = FieldType.Textbox, HelpText = "Adding a category specific to Radarr avoids conflicts with unrelated downloads, but it's optional")]
public string TvCategory { get; set; } public string MovieCategory { get; set; }
[FieldDefinition(6, Label = "Recent Priority", Type = FieldType.Select, SelectOptions = typeof(SabnzbdPriority), HelpText = "Priority to use when grabbing releases that aired within the last 14 days")] [FieldDefinition(6, Label = "Recent Priority", Type = FieldType.Select, SelectOptions = typeof(SabnzbdPriority), HelpText = "Priority to use when grabbing releases that aired within the last 14 days")]
public int RecentTvPriority { get; set; } public int RecentTvPriority { get; set; }

Loading…
Cancel
Save