From 242d530bb4f0538d05b2230f39f84dd2ca50a751 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sun, 14 Jul 2019 21:18:03 -0400 Subject: [PATCH] Fixed: Unit Test Fixes --- src/NzbDrone.Api/Config/HostConfigResource.cs | 2 + src/NzbDrone.Common.Test/WebClientTests.cs | 12 ++- .../Properties/SharedAssemblyInfo.cs | 3 +- .../IndexerTests/PTPTests/PTPFixture.cs | 2 +- .../Configuration/ConfigFileProvider.cs | 3 + .../PassThePopcorn/PassThePopcornParser.cs | 2 - .../PassThePopcornRequestGenerator.cs | 63 +-------------- .../PassThePopcorn/PassThePopcornSettings.cs | 20 +---- .../Instrumentation/ReconfigureLogging.cs | 11 ++- .../Update/InstallUpdateService.cs | 18 +++-- .../Update/UpdateCheckService.cs | 3 +- .../ApiTests/CommandFixture.cs | 1 - .../CutoffUnmetFixture.cs} | 64 +++++---------- .../ApiTests/WantedTests/MissingFixture.cs | 81 +++++++++++++++++++ .../Client/ClientBase.cs | 2 +- .../IntegrationTest.cs | 5 ++ .../IntegrationTestBase.cs | 8 +- .../NzbDrone.Integration.Test.csproj | 3 +- .../Config/HostConfigResource.cs | 2 + 19 files changed, 167 insertions(+), 138 deletions(-) rename src/NzbDrone.Integration.Test/ApiTests/{WantedFixture.cs => WantedTests/CutoffUnmetFixture.cs} (57%) create mode 100644 src/NzbDrone.Integration.Test/ApiTests/WantedTests/MissingFixture.cs diff --git a/src/NzbDrone.Api/Config/HostConfigResource.cs b/src/NzbDrone.Api/Config/HostConfigResource.cs index a7e042db1..a63cc876a 100644 --- a/src/NzbDrone.Api/Config/HostConfigResource.cs +++ b/src/NzbDrone.Api/Config/HostConfigResource.cs @@ -18,6 +18,7 @@ namespace NzbDrone.Api.Config public string Username { get; set; } public string Password { get; set; } public string LogLevel { get; set; } + public string ConsoleLogLevel { get; set; } public string Branch { get; set; } public string ApiKey { get; set; } public string SslCertHash { get; set; } @@ -55,6 +56,7 @@ namespace NzbDrone.Api.Config //Username //Password LogLevel = model.LogLevel, + ConsoleLogLevel = model.ConsoleLogLevel, Branch = model.Branch, ApiKey = model.ApiKey, SslCertHash = model.SslCertHash, diff --git a/src/NzbDrone.Common.Test/WebClientTests.cs b/src/NzbDrone.Common.Test/WebClientTests.cs index 899fbadbd..234e26275 100644 --- a/src/NzbDrone.Common.Test/WebClientTests.cs +++ b/src/NzbDrone.Common.Test/WebClientTests.cs @@ -21,10 +21,20 @@ namespace NzbDrone.Common.Test [TestCase("")] [TestCase("http://")] - public void DownloadString_should_throw_on_error(string url) + public void DownloadString_should_throw_on_error_windows(string url) { + WindowsOnly(); Assert.Throws(() => Subject.DownloadString(url)); ExceptionVerification.ExpectedWarns(1); } + + + [TestCase("http://")] + public void DownloadString_should_throw_on_not_supported_string_mono(string url) + { + MonoOnly(); + Assert.Throws(() => Subject.DownloadString(url)); + ExceptionVerification.ExpectedWarns(1); + } } } diff --git a/src/NzbDrone.Common/Properties/SharedAssemblyInfo.cs b/src/NzbDrone.Common/Properties/SharedAssemblyInfo.cs index cdb59506a..e2dbb8e0a 100644 --- a/src/NzbDrone.Common/Properties/SharedAssemblyInfo.cs +++ b/src/NzbDrone.Common/Properties/SharedAssemblyInfo.cs @@ -1,7 +1,8 @@ using System.Reflection; using System.Runtime.InteropServices; -[assembly: AssemblyConfiguration("")] +[assembly: AssemblyConfiguration("debug")] + [assembly: AssemblyCompany("radarr.video")] [assembly: AssemblyProduct("Radarr")] [assembly: AssemblyVersion("10.0.0.*")] diff --git a/src/NzbDrone.Core.Test/IndexerTests/PTPTests/PTPFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/PTPTests/PTPFixture.cs index 1507ca96c..c655bcf9d 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/PTPTests/PTPFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/PTPTests/PTPFixture.cs @@ -23,7 +23,7 @@ namespace NzbDrone.Core.Test.IndexerTests.PTPTests Subject.Definition = new IndexerDefinition() { Name = "PTP", - Settings = new PassThePopcornSettings() { Passkey = "fakekey", Username = "asdf", Password = "sad" } + Settings = new PassThePopcornSettings() { APIUser = "asdf", APIKey = "sad" } }; } diff --git a/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs b/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs index 86162cbf8..ebce65468 100644 --- a/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs +++ b/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs @@ -9,6 +9,7 @@ using NzbDrone.Common.Cache; using NzbDrone.Common.Disk; using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.Extensions; +using NzbDrone.Common.Instrumentation; using NzbDrone.Core.Authentication; using NzbDrone.Core.Configuration.Events; using NzbDrone.Core.Lifecycle; @@ -32,6 +33,7 @@ namespace NzbDrone.Core.Configuration AuthenticationType AuthenticationMethod { get; } bool AnalyticsEnabled { get; } string LogLevel { get; } + string ConsoleLogLevel { get; } string Branch { get; } string ApiKey { get; } string SslCertHash { get; } @@ -179,6 +181,7 @@ namespace NzbDrone.Core.Configuration public string Branch => GetValue("Branch", "develop").ToLowerInvariant(); public string LogLevel => GetValue("LogLevel", "Info"); + public string ConsoleLogLevel => GetValue("ConsoleLogLevel", string.Empty, persist: false); public string SslCertHash => GetValue("SslCertHash", ""); diff --git a/src/NzbDrone.Core/Indexers/PassThePopcorn/PassThePopcornParser.cs b/src/NzbDrone.Core/Indexers/PassThePopcorn/PassThePopcornParser.cs index 8f831b1c7..95d55eb32 100644 --- a/src/NzbDrone.Core/Indexers/PassThePopcorn/PassThePopcornParser.cs +++ b/src/NzbDrone.Core/Indexers/PassThePopcorn/PassThePopcornParser.cs @@ -5,9 +5,7 @@ using Newtonsoft.Json; using NzbDrone.Common.Http; using NzbDrone.Core.Indexers.Exceptions; using NzbDrone.Core.Parser.Model; -using System.Linq; using NLog; -using NzbDrone.Common.Cache; using NzbDrone.Common.Extensions; namespace NzbDrone.Core.Indexers.PassThePopcorn diff --git a/src/NzbDrone.Core/Indexers/PassThePopcorn/PassThePopcornRequestGenerator.cs b/src/NzbDrone.Core/Indexers/PassThePopcorn/PassThePopcornRequestGenerator.cs index eb966252d..df61e205d 100644 --- a/src/NzbDrone.Core/Indexers/PassThePopcorn/PassThePopcornRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/PassThePopcorn/PassThePopcornRequestGenerator.cs @@ -2,10 +2,8 @@ using System; using System.Collections.Generic; using NzbDrone.Common.Http; using NzbDrone.Core.IndexerSearch.Definitions; -using NzbDrone.Common.Cache; using NLog; using NzbDrone.Common.Extensions; -using NzbDrone.Common.Serializer; namespace NzbDrone.Core.Indexers.PassThePopcorn { @@ -44,20 +42,9 @@ namespace NzbDrone.Core.Indexers.PassThePopcorn new IndexerRequest( $"{Settings.BaseUrl.Trim().TrimEnd('/')}/torrents.php?action=advanced&json=noredirect&searchstr={searchParameters}", HttpAccept.Json); - - if (Settings.APIKey.IsNullOrWhiteSpace()) - { - Cookies = GetCookies(); - - Authenticate(); - - Logger.Warn("You are using the old method of logging into PassThePopcorn. Please switch to the new method using APIUser & APIKey."); - } - else - { - request.HttpRequest.Headers["ApiUser"] = Settings.APIUser; - request.HttpRequest.Headers["ApiKey"] = Settings.APIKey; - } + + request.HttpRequest.Headers["ApiUser"] = Settings.APIUser; + request.HttpRequest.Headers["ApiKey"] = Settings.APIKey; if (Settings.APIKey.IsNullOrWhiteSpace()) { @@ -71,49 +58,5 @@ namespace NzbDrone.Core.Indexers.PassThePopcorn yield return request; } - - private void Authenticate() - { - if (Cookies == null) - { - var requestBuilder = new HttpRequestBuilder($"{Settings.BaseUrl.Trim().TrimEnd('/')}") - { - LogResponseContent = true - }; - - requestBuilder.Method = HttpMethod.POST; - requestBuilder.Resource("ajax.php?action=login"); - requestBuilder.PostProcess += r => r.RequestTimeout = TimeSpan.FromSeconds(15); - - var authLoginRequest = requestBuilder - .AddFormParameter("username", Settings.Username) - .AddFormParameter("password", Settings.Password) - .AddFormParameter("passkey", Settings.Passkey) - .AddFormParameter("keeplogged", "1") - .SetHeader("Content-Type", "multipart/form-data") - .Accept(HttpAccept.Json) - .Build(); - - authLoginRequest.AllowAutoRedirect = true; - // We want clean cookies for the auth request. - authLoginRequest.StoreRequestCookie = false; - authLoginRequest.StoreResponseCookie = false; - authLoginRequest.Cookies.Clear(); - authLoginRequest.IgnorePersistentCookies = true; - var response = HttpClient.Execute(authLoginRequest); - var result = Json.Deserialize(response.Content); - - if (result?.Result != "Ok" || string.IsNullOrWhiteSpace(result.Result)) - { - Logger.Debug("PassThePopcorn authentication failed."); - throw new Exception("Failed to authenticate with PassThePopcorn."); - } - - Logger.Debug("PassThePopcorn authentication succeeded."); - - Cookies = response.GetCookies(); - requestBuilder.SetCookies(Cookies); - } - } } } diff --git a/src/NzbDrone.Core/Indexers/PassThePopcorn/PassThePopcornSettings.cs b/src/NzbDrone.Core/Indexers/PassThePopcorn/PassThePopcornSettings.cs index 6949409ab..75eed989c 100644 --- a/src/NzbDrone.Core/Indexers/PassThePopcorn/PassThePopcornSettings.cs +++ b/src/NzbDrone.Core/Indexers/PassThePopcorn/PassThePopcornSettings.cs @@ -15,9 +15,6 @@ namespace NzbDrone.Core.Indexers.PassThePopcorn public PassThePopcornSettingsValidator() { RuleFor(c => c.BaseUrl).ValidRootUrl(); - RuleFor(c => c.Username).Empty(); - RuleFor(c => c.Password).Empty(); - RuleFor(c => c.Passkey).Empty(); RuleFor(c => c.APIUser).NotEmpty(); RuleFor(c => c.APIKey).NotEmpty(); @@ -44,26 +41,17 @@ namespace NzbDrone.Core.Indexers.PassThePopcorn [FieldDefinition(2, Label = "APIKey", Type = FieldType.Password)] public string APIKey { get; set; } - - [FieldDefinition(3, Label = "DEPRECATED: User", HelpText = "Please use APIKey & APIUser instead. PTP Username")] - public string Username { get; set; } - - [FieldDefinition(4, Label = "DEPRECATED: Pass", Type = FieldType.Password, HelpText = "Please use APIKey & APIUser instead. PTP Password")] - public string Password { get; set; } - - [FieldDefinition(5, Label = "DEPRECATED: Passkey", HelpText = "Please use APIKey & APIUser instead. PTP Passkey")] - public string Passkey { get; set; } - // [FieldDefinition(6, Type = FieldType.Tag, SelectOptions = typeof(Language), Label = "Multi Languages", HelpText = "What languages are normally in a multi release on this indexer?", Advanced = true)] + // [FieldDefinition(3, Type = FieldType.Tag, SelectOptions = typeof(Language), Label = "Multi Languages", HelpText = "What languages are normally in a multi release on this indexer?", Advanced = true)] public IEnumerable MultiLanguages { get; set; } - [FieldDefinition(7, Type = FieldType.Textbox, Label = "Minimum Seeders", HelpText = "Minimum number of seeders required.", Advanced = true)] + [FieldDefinition(4, Type = FieldType.Textbox, Label = "Minimum Seeders", HelpText = "Minimum number of seeders required.", Advanced = true)] public int MinimumSeeders { get; set; } - [FieldDefinition(8)] + [FieldDefinition(5)] public SeedCriteriaSettings SeedCriteria { get; } = new SeedCriteriaSettings(); - [FieldDefinition(9, Type = FieldType.Tag, SelectOptions = typeof(IndexerFlags), Label = "Required Flags", HelpText = "What indexer flags are required?", HelpLink = "https://github.com/Radarr/Radarr/wiki/Indexer-Flags#1-required-flags", Advanced = true)] + [FieldDefinition(6, Type = FieldType.Tag, SelectOptions = typeof(IndexerFlags), Label = "Required Flags", HelpText = "What indexer flags are required?", HelpLink = "https://github.com/Radarr/Radarr/wiki/Indexer-Flags#1-required-flags", Advanced = true)] public IEnumerable RequiredFlags { get; set; } public NzbDroneValidationResult Validate() diff --git a/src/NzbDrone.Core/Instrumentation/ReconfigureLogging.cs b/src/NzbDrone.Core/Instrumentation/ReconfigureLogging.cs index e53bea79a..a79ba682a 100644 --- a/src/NzbDrone.Core/Instrumentation/ReconfigureLogging.cs +++ b/src/NzbDrone.Core/Instrumentation/ReconfigureLogging.cs @@ -2,6 +2,7 @@ using System.Linq; using NLog; using NLog.Config; +using NzbDrone.Common.Extensions; using NzbDrone.Core.Configuration; using NzbDrone.Core.Configuration.Events; using NzbDrone.Core.Messaging.Events; @@ -20,11 +21,19 @@ namespace NzbDrone.Core.Instrumentation public void Reconfigure() { var minimumLogLevel = LogLevel.FromString(_configFileProvider.LogLevel); + LogLevel minimumConsoleLogLevel; + + if (_configFileProvider.ConsoleLogLevel.IsNotNullOrWhiteSpace()) + minimumConsoleLogLevel = LogLevel.FromString(_configFileProvider.ConsoleLogLevel); + else if (minimumLogLevel > LogLevel.Info) + minimumConsoleLogLevel = minimumLogLevel; + else + minimumConsoleLogLevel = LogLevel.Info; var rules = LogManager.Configuration.LoggingRules; //Console - SetMinimumLogLevel(rules, "consoleLogger", minimumLogLevel); + SetMinimumLogLevel(rules, "consoleLogger", minimumConsoleLogLevel); //Log Files SetMinimumLogLevel(rules, "appFileInfo", minimumLogLevel <= LogLevel.Info ? LogLevel.Info : LogLevel.Off); diff --git a/src/NzbDrone.Core/Update/InstallUpdateService.cs b/src/NzbDrone.Core/Update/InstallUpdateService.cs index 42970ba19..0fe04070e 100644 --- a/src/NzbDrone.Core/Update/InstallUpdateService.cs +++ b/src/NzbDrone.Core/Update/InstallUpdateService.cs @@ -50,7 +50,7 @@ namespace NzbDrone.Core.Update { if (configFileProvider == null) { - throw new ArgumentNullException("configFileProvider"); + throw new ArgumentNullException(nameof(configFileProvider)); } _checkUpdateService = checkUpdateService; _appFolderInfo = appFolderInfo; @@ -87,6 +87,12 @@ namespace NzbDrone.Core.Update } } + if (_appFolderInfo.StartUpFolder.EndsWith("_output")) + { + _logger.ProgressDebug("Running in developer environment, not updating."); + return; + } + var updateSandboxFolder = _appFolderInfo.GetUpdateSandboxFolder(); var packageDestination = Path.Combine(updateSandboxFolder, updatePackage.FileName); @@ -148,7 +154,7 @@ namespace NzbDrone.Core.Update } catch (Exception e) { - _logger.Error(e, string.Format("Couldn't change the branch from [{0}] to [{1}].", currentBranch, package.Branch)); + _logger.Error(e, "Couldn't change the branch from [{0}] to [{1}].", currentBranch, package.Branch); } } } @@ -178,9 +184,8 @@ namespace NzbDrone.Core.Update { var processId = _processProvider.GetCurrentProcess().Id.ToString(); var executingApplication = _runtimeInfo.ExecutingApplication; - var args = string.Join(" ", processId, updateSandboxFolder.TrimEnd(Path.DirectorySeparatorChar).WrapInQuotes(), executingApplication.WrapInQuotes(), _startupContext.PreservedArguments); - _logger.Info("Updater Arguments: " + args); - return args; + + return string.Join(" ", processId, updateSandboxFolder.TrimEnd(Path.DirectorySeparatorChar).WrapInQuotes(), executingApplication.WrapInQuotes(), _startupContext.PreservedArguments); } private void EnsureAppDataSafety() @@ -200,7 +205,7 @@ namespace NzbDrone.Core.Update if (latestAvailable == null) { - _logger.ProgressDebug("No update available."); + _logger.ProgressDebug("No update available"); return; } @@ -213,6 +218,7 @@ namespace NzbDrone.Core.Update try { InstallUpdate(latestAvailable); + _logger.ProgressDebug("Restarting Radarr to apply updates"); } catch (UpdateFolderNotWritableException ex) { diff --git a/src/NzbDrone.Core/Update/UpdateCheckService.cs b/src/NzbDrone.Core/Update/UpdateCheckService.cs index 46e4b6b63..ad0f04f11 100644 --- a/src/NzbDrone.Core/Update/UpdateCheckService.cs +++ b/src/NzbDrone.Core/Update/UpdateCheckService.cs @@ -13,6 +13,7 @@ namespace NzbDrone.Core.Update private readonly IUpdatePackageProvider _updatePackageProvider; private readonly IConfigFileProvider _configFileProvider; + public CheckUpdateService(IUpdatePackageProvider updatePackageProvider, IConfigFileProvider configFileProvider) { @@ -25,4 +26,4 @@ namespace NzbDrone.Core.Update return _updatePackageProvider.GetLatestUpdate(_configFileProvider.Branch, BuildInfo.Version); } } -} +} \ No newline at end of file diff --git a/src/NzbDrone.Integration.Test/ApiTests/CommandFixture.cs b/src/NzbDrone.Integration.Test/ApiTests/CommandFixture.cs index bf17b6d12..2c3da675c 100644 --- a/src/NzbDrone.Integration.Test/ApiTests/CommandFixture.cs +++ b/src/NzbDrone.Integration.Test/ApiTests/CommandFixture.cs @@ -5,7 +5,6 @@ using NzbDrone.Api.Commands; namespace NzbDrone.Integration.Test.ApiTests { [TestFixture] - [Ignore("Not ready to be used on this branch")] public class CommandFixture : IntegrationTest { [Test] diff --git a/src/NzbDrone.Integration.Test/ApiTests/WantedFixture.cs b/src/NzbDrone.Integration.Test/ApiTests/WantedTests/CutoffUnmetFixture.cs similarity index 57% rename from src/NzbDrone.Integration.Test/ApiTests/WantedFixture.cs rename to src/NzbDrone.Integration.Test/ApiTests/WantedTests/CutoffUnmetFixture.cs index 12b1cad0d..5b3c0a06f 100644 --- a/src/NzbDrone.Integration.Test/ApiTests/WantedFixture.cs +++ b/src/NzbDrone.Integration.Test/ApiTests/WantedTests/CutoffUnmetFixture.cs @@ -3,41 +3,11 @@ using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.Qualities; -namespace NzbDrone.Integration.Test.ApiTests +namespace NzbDrone.Integration.Test.ApiTests.WantedTests { [TestFixture] - public class WantedFixture : IntegrationTest + public class CutoffUnmetFixture : IntegrationTest { - [Test, Order(0)] - public void missing_should_be_empty() - { - EnsureNoMovie(680, "Pulp Fiction"); - - var result = WantedMissing.GetPaged(0, 15, "physicalRelease", "desc"); - - result.Records.Should().BeEmpty(); - } - - [Test, Order(1)] - public void missing_should_have_monitored_items() - { - EnsureMovie(680, "Pulp Fiction", true); - - var result = WantedMissing.GetPaged(0, 15, "physicalRelease", "desc"); - - result.Records.Should().NotBeEmpty(); - } - - [Test, Order(1)] - public void missing_should_have_movie() - { - EnsureMovie(680, "Pulp Fiction", true); - - var result = WantedMissing.GetPaged(0, 15, "physicalRelease", "desc"); - - result.Records.First().Title.Should().Be("Pulp Fiction"); - } - [Test, Order(1)] public void cutoff_should_have_monitored_items() { @@ -45,29 +15,31 @@ namespace NzbDrone.Integration.Test.ApiTests var movie = EnsureMovie(680, "Pulp Fiction", true); EnsureMovieFile(movie, Quality.SDTV); - var result = WantedCutoffUnmet.GetPaged(0, 15, "physicalRelease", "desc"); + var result = WantedCutoffUnmet.GetPaged(0, 15, "physicalRelease", "desc", "monitored", "true"); result.Records.Should().NotBeEmpty(); } [Test, Order(1)] - public void missing_should_not_have_unmonitored_items() + public void cutoff_should_not_have_unmonitored_items() { - EnsureMovie(680, "Pulp Fiction", false); + EnsureProfileCutoff(1, Quality.HDTV720p); + var movie = EnsureMovie(680, "Pulp Fiction", false); + EnsureMovieFile(movie, Quality.SDTV); - var result = WantedMissing.GetPaged(0, 15, "physicalRelease", "desc"); + var result = WantedCutoffUnmet.GetPaged(0, 15, "physicalRelease", "desc", "monitored", "true"); result.Records.Should().BeEmpty(); } [Test, Order(1)] - public void cutoff_should_not_have_unmonitored_items() + public void cutoff_should_not_have_released_items() { EnsureProfileCutoff(1, Quality.HDTV720p); - var movie = EnsureMovie(680, "Pulp Fiction", false); + var movie = EnsureMovie(680, "Pulp Fiction", true); EnsureMovieFile(movie, Quality.SDTV); - var result = WantedCutoffUnmet.GetPaged(0, 15, "physicalRelease", "desc"); + var result = WantedCutoffUnmet.GetPaged(0, 15, "physicalRelease", "desc", "status", "inCinemas"); result.Records.Should().BeEmpty(); } @@ -85,25 +57,27 @@ namespace NzbDrone.Integration.Test.ApiTests } [Test, Order(2)] - public void missing_should_have_unmonitored_items() + public void cutoff_should_have_unmonitored_items() { - EnsureMovie(680, "Pulp Fiction", false); + EnsureProfileCutoff(1, Quality.HDTV720p); + var movie = EnsureMovie(680, "Pulp Fiction", false); + EnsureMovieFile(movie, Quality.SDTV); - var result = WantedMissing.GetPaged(0, 15, "physicalRelease", "desc", "monitored", "false"); + var result = WantedCutoffUnmet.GetPaged(0, 15, "physicalRelease", "desc", "monitored", "false"); result.Records.Should().NotBeEmpty(); } [Test, Order(2)] - public void cutoff_should_have_unmonitored_items() + public void cutoff_should_have_released_items() { EnsureProfileCutoff(1, Quality.HDTV720p); var movie = EnsureMovie(680, "Pulp Fiction", false); EnsureMovieFile(movie, Quality.SDTV); - var result = WantedCutoffUnmet.GetPaged(0, 15, "physicalRelease", "desc", "monitored", "false"); + var result = WantedCutoffUnmet.GetPaged(0, 15, "physicalRelease", "desc", "status", "released"); result.Records.Should().NotBeEmpty(); } } -} +} \ No newline at end of file diff --git a/src/NzbDrone.Integration.Test/ApiTests/WantedTests/MissingFixture.cs b/src/NzbDrone.Integration.Test/ApiTests/WantedTests/MissingFixture.cs new file mode 100644 index 000000000..62e594381 --- /dev/null +++ b/src/NzbDrone.Integration.Test/ApiTests/WantedTests/MissingFixture.cs @@ -0,0 +1,81 @@ +using System.Linq; +using FluentAssertions; +using NUnit.Framework; +using NzbDrone.Core.Qualities; + +namespace NzbDrone.Integration.Test.ApiTests.WantedTests +{ + [TestFixture] + public class MissingFixture : IntegrationTest + { + [Test, Order(0)] + public void missing_should_be_empty() + { + EnsureNoMovie(680, "Pulp Fiction"); + + var result = WantedMissing.GetPaged(0, 15, "physicalRelease", "desc"); + + result.Records.Should().BeEmpty(); + } + + [Test, Order(1)] + public void missing_should_have_monitored_items() + { + EnsureMovie(680, "Pulp Fiction", true); + + var result = WantedMissing.GetPaged(0, 15, "physicalRelease", "desc", "monitored", "true"); + + result.Records.Should().NotBeEmpty(); + } + + [Test, Order(1)] + public void missing_should_have_movie() + { + EnsureMovie(680, "Pulp Fiction", true); + + var result = WantedMissing.GetPaged(0, 15, "physicalRelease", "desc"); + + result.Records.First().Title.Should().Be("Pulp Fiction"); + } + + [Test, Order(1)] + public void missing_should_not_have_unmonitored_items() + { + EnsureMovie(680, "Pulp Fiction", false); + + var result = WantedMissing.GetPaged(0, 15, "physicalRelease", "desc", "monitored", "true"); + + result.Records.Should().BeEmpty(); + } + + [Test, Order(1)] + public void missing_should_not_have_released_items() + { + EnsureMovie(680, "Pulp Fiction", false); + + var result = WantedMissing.GetPaged(0, 15, "physicalRelease", "desc", "status", "inCinemas"); + + result.Records.Should().BeEmpty(); + } + + [Test, Order(2)] + public void missing_should_have_unmonitored_items() + { + EnsureMovie(680, "Pulp Fiction", false); + + var result = WantedMissing.GetPaged(0, 15, "physicalRelease", "desc", "monitored", "false"); + + result.Records.Should().NotBeEmpty(); + } + + [Test, Order(2)] + public void missing_should_have_released_items() + { + EnsureMovie(680, "Pulp Fiction", false); + + var result = WantedMissing.GetPaged(0, 15, "physicalRelease", "desc", "status", "released"); + + result.Records.Should().NotBeEmpty(); + } + } +} \ No newline at end of file diff --git a/src/NzbDrone.Integration.Test/Client/ClientBase.cs b/src/NzbDrone.Integration.Test/Client/ClientBase.cs index 5ea21256c..85c2a32b3 100644 --- a/src/NzbDrone.Integration.Test/Client/ClientBase.cs +++ b/src/NzbDrone.Integration.Test/Client/ClientBase.cs @@ -63,7 +63,7 @@ namespace NzbDrone.Integration.Test.Client private static void AssertDisableCache(IList headers) { - headers.Single(c => c.Name == "Cache-Control").Value.Should().Be("no-cache, no-store, must-revalidate"); + headers.Single(c => c.Name == "Cache-Control").Value.Should().Be("no-cache, no-store, must-revalidate, max-age=0"); headers.Single(c => c.Name == "Pragma").Value.Should().Be("no-cache"); headers.Single(c => c.Name == "Expires").Value.Should().Be("0"); } diff --git a/src/NzbDrone.Integration.Test/IntegrationTest.cs b/src/NzbDrone.Integration.Test/IntegrationTest.cs index 0c725dbac..2e6020ac8 100644 --- a/src/NzbDrone.Integration.Test/IntegrationTest.cs +++ b/src/NzbDrone.Integration.Test/IntegrationTest.cs @@ -36,6 +36,11 @@ namespace NzbDrone.Integration.Test Protocol = Core.Indexers.DownloadProtocol.Usenet, Fields = SchemaBuilder.ToSchema(new NewznabSettings()) }); + + // Change Console Log Level to Debug so we get more details. + var config = HostConfig.Get(1); + config.ConsoleLogLevel = "Debug"; + HostConfig.Put(config); } protected override void StopTestTarget() diff --git a/src/NzbDrone.Integration.Test/IntegrationTestBase.cs b/src/NzbDrone.Integration.Test/IntegrationTestBase.cs index 55014f5b5..e51bed674 100644 --- a/src/NzbDrone.Integration.Test/IntegrationTestBase.cs +++ b/src/NzbDrone.Integration.Test/IntegrationTestBase.cs @@ -238,6 +238,8 @@ namespace NzbDrone.Integration.Test } } + Commands.WaitAll(); + return result; } @@ -257,9 +259,13 @@ namespace NzbDrone.Integration.Test if (result.MovieFile == null) { - var path = Path.Combine(MovieRootFolder, movie.Title, string.Format("{0} - {1}.mkv", movie.Title, quality.Name)); + var path = Path.Combine(MovieRootFolder, movie.Title, string.Format("{0} ({1}) - {2}.strm", movie.Title, movie.Year, quality.Name)); Directory.CreateDirectory(Path.GetDirectoryName(path)); + + var sourcePath = Path.Combine(TestContext.CurrentContext.TestDirectory, "ApiTests", "Files", "H264_sample.mp4"); + + //File.Copy(sourcePath, path); File.WriteAllText(path, "Fake Movie"); Commands.PostAndWait(new CommandResource { Name = "refreshmovie", Body = new RefreshMovieCommand(movie.Id) }); diff --git a/src/NzbDrone.Integration.Test/NzbDrone.Integration.Test.csproj b/src/NzbDrone.Integration.Test/NzbDrone.Integration.Test.csproj index 1ac85d644..21a1fb3a1 100644 --- a/src/NzbDrone.Integration.Test/NzbDrone.Integration.Test.csproj +++ b/src/NzbDrone.Integration.Test/NzbDrone.Integration.Test.csproj @@ -107,7 +107,8 @@ - + + diff --git a/src/Radarr.Api.V2/Config/HostConfigResource.cs b/src/Radarr.Api.V2/Config/HostConfigResource.cs index 8a01eb2a9..cbf35d69f 100644 --- a/src/Radarr.Api.V2/Config/HostConfigResource.cs +++ b/src/Radarr.Api.V2/Config/HostConfigResource.cs @@ -19,6 +19,7 @@ namespace Radarr.Api.V2.Config public string Username { get; set; } public string Password { get; set; } public string LogLevel { get; set; } + public string ConsoleLogLevel { get; set; } public string Branch { get; set; } public string ApiKey { get; set; } public string SslCertHash { get; set; } @@ -57,6 +58,7 @@ namespace Radarr.Api.V2.Config //Username //Password LogLevel = model.LogLevel, + ConsoleLogLevel = model.ConsoleLogLevel, Branch = model.Branch, ApiKey = model.ApiKey, SslCertHash = model.SslCertHash,