From 641f8a88fad22bc0df224bfed354888da5e3297c Mon Sep 17 00:00:00 2001 From: Qstick Date: Sat, 28 Oct 2017 22:52:36 -0400 Subject: [PATCH] Fixed: Calculates wrong age for releases pushed via ReleasePush api --- src/Lidarr.Api.V3/Indexers/ReleaseResource.cs | 2 +- .../ApiTests/ReleasePushFixture.cs | 31 +++++++++++++++++++ .../Client/ReleasePushClient.cs | 13 ++++++++ .../IntegrationTestBase.cs | 2 ++ .../NzbDrone.Integration.Test.csproj | 2 ++ 5 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 src/NzbDrone.Integration.Test/ApiTests/ReleasePushFixture.cs create mode 100644 src/NzbDrone.Integration.Test/Client/ReleasePushClient.cs diff --git a/src/Lidarr.Api.V3/Indexers/ReleaseResource.cs b/src/Lidarr.Api.V3/Indexers/ReleaseResource.cs index d98e601cf..eb44fdaf6 100644 --- a/src/Lidarr.Api.V3/Indexers/ReleaseResource.cs +++ b/src/Lidarr.Api.V3/Indexers/ReleaseResource.cs @@ -139,7 +139,7 @@ namespace Lidarr.Api.V3.Indexers model.IndexerId = resource.IndexerId; model.Indexer = resource.Indexer; model.DownloadProtocol = resource.DownloadProtocol; - model.PublishDate = resource.PublishDate; + model.PublishDate = resource.PublishDate.ToUniversalTime(); return model; } diff --git a/src/NzbDrone.Integration.Test/ApiTests/ReleasePushFixture.cs b/src/NzbDrone.Integration.Test/ApiTests/ReleasePushFixture.cs new file mode 100644 index 000000000..f43576ba7 --- /dev/null +++ b/src/NzbDrone.Integration.Test/ApiTests/ReleasePushFixture.cs @@ -0,0 +1,31 @@ +using FluentAssertions; +using NUnit.Framework; +using Lidarr.Api.V3.Indexers; +using System.Linq; +using System.Net; +using System.Collections.Generic; +using System; +using System.Globalization; + +namespace NzbDrone.Integration.Test.ApiTests +{ + [TestFixture] + public class ReleasePushFixture : IntegrationTest + { + [Test] + public void should_have_utc_date() + { + var body = new Dictionary(); + body.Add("guid", "sdfsdfsdf"); + body.Add("title", "The Artist - The Album"); + body.Add("publishDate", DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ssZ", CultureInfo.InvariantCulture)); + + var request = ReleasePush.BuildRequest(); + request.AddBody(body); + var result = ReleasePush.Post(request, HttpStatusCode.OK); + + result.Should().NotBeNull(); + result.AgeHours.Should().BeApproximately(0, 0.1); + } + } +} diff --git a/src/NzbDrone.Integration.Test/Client/ReleasePushClient.cs b/src/NzbDrone.Integration.Test/Client/ReleasePushClient.cs new file mode 100644 index 000000000..5b660dfda --- /dev/null +++ b/src/NzbDrone.Integration.Test/Client/ReleasePushClient.cs @@ -0,0 +1,13 @@ +using Lidarr.Api.V3.Indexers; +using RestSharp; + +namespace NzbDrone.Integration.Test.Client +{ + public class ReleasePushClient : ClientBase + { + public ReleasePushClient(IRestClient restClient, string apiKey) + : base(restClient, apiKey, "release/push") + { + } + } +} diff --git a/src/NzbDrone.Integration.Test/IntegrationTestBase.cs b/src/NzbDrone.Integration.Test/IntegrationTestBase.cs index 115494e26..964c5e4c8 100644 --- a/src/NzbDrone.Integration.Test/IntegrationTestBase.cs +++ b/src/NzbDrone.Integration.Test/IntegrationTestBase.cs @@ -50,6 +50,7 @@ namespace NzbDrone.Integration.Test public NotificationClient Notifications; public ClientBase Profiles; public ReleaseClient Releases; + public ReleasePushClient ReleasePush; public ClientBase RootFolders; public ArtistClient Artist; public ClientBase Tags; @@ -111,6 +112,7 @@ namespace NzbDrone.Integration.Test Notifications = new NotificationClient(RestClient, ApiKey); Profiles = new ClientBase(RestClient, ApiKey); Releases = new ReleaseClient(RestClient, ApiKey); + ReleasePush = new ReleasePushClient(RestClient, ApiKey); RootFolders = new ClientBase(RestClient, ApiKey); Artist = new ArtistClient(RestClient, ApiKey); Tags = new ClientBase(RestClient, ApiKey); diff --git a/src/NzbDrone.Integration.Test/NzbDrone.Integration.Test.csproj b/src/NzbDrone.Integration.Test/NzbDrone.Integration.Test.csproj index 8bf66b9e7..509f762eb 100644 --- a/src/NzbDrone.Integration.Test/NzbDrone.Integration.Test.csproj +++ b/src/NzbDrone.Integration.Test/NzbDrone.Integration.Test.csproj @@ -99,12 +99,14 @@ + +