Fixed: Calculates wrong age for releases pushed via ReleasePush api.

closes Zymest/autodl-curl-sonarr#3
pull/2070/head
Taloth Saldono 7 years ago
parent d4e771117d
commit c68ef626d2

@ -166,9 +166,9 @@ namespace NzbDrone.Api.Indexers
model.DownloadProtocol = resource.DownloadProtocol;
model.TvdbId = resource.TvdbId;
model.TvRageId = resource.TvRageId;
model.PublishDate = resource.PublishDate;
model.PublishDate = resource.PublishDate.ToUniversalTime();
return model;
}
}
}
}

@ -0,0 +1,31 @@
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Api.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<string, object>();
body.Add("guid", "sdfsdfsdf");
body.Add("title", "The.Series.S01E01");
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<ReleaseResource>(request, HttpStatusCode.OK);
result.Should().NotBeNull();
result.AgeHours.Should().BeApproximately(0, 0.1);
}
}
}

@ -0,0 +1,13 @@
using NzbDrone.Api.Indexers;
using RestSharp;
namespace NzbDrone.Integration.Test.Client
{
public class ReleasePushClient : ClientBase<ReleaseResource>
{
public ReleasePushClient(IRestClient restClient, string apiKey)
: base(restClient, apiKey, "release/push")
{
}
}
}

@ -48,6 +48,7 @@ namespace NzbDrone.Integration.Test
public NotificationClient Notifications;
public ClientBase<ProfileResource> Profiles;
public ReleaseClient Releases;
public ReleasePushClient ReleasePush;
public ClientBase<RootFolderResource> RootFolders;
public SeriesClient Series;
public ClientBase<TagResource> Tags;
@ -108,6 +109,7 @@ namespace NzbDrone.Integration.Test
Notifications = new NotificationClient(RestClient, ApiKey);
Profiles = new ClientBase<ProfileResource>(RestClient, ApiKey);
Releases = new ReleaseClient(RestClient, ApiKey);
ReleasePush = new ReleasePushClient(RestClient, ApiKey);
RootFolders = new ClientBase<RootFolderResource>(RestClient, ApiKey);
Series = new SeriesClient(RestClient, ApiKey);
Tags = new ClientBase<TagResource>(RestClient, ApiKey);
@ -272,7 +274,7 @@ namespace NzbDrone.Integration.Test
Commands.PostAndWait(new CommandResource { Name = "refreshseries", Body = new RefreshSeriesCommand(series.Id) });
Commands.WaitAll();
result = Episodes.GetEpisodesInSeries(series.Id).Single(v => v.SeasonNumber == season && v.EpisodeNumber == episode);
result.EpisodeFile.Should().NotBeNull();

@ -105,6 +105,7 @@
<Compile Include="ApiTests\DownloadClientFixture.cs" />
<Compile Include="ApiTests\EpisodeFileFixture.cs" />
<Compile Include="ApiTests\FileSystemFixture.cs" />
<Compile Include="ApiTests\ReleasePushFixture.cs" />
<Compile Include="ApiTests\SeriesLookupFixture.cs" />
<Compile Include="ApiTests\WantedFixture.cs" />
<Compile Include="Client\ClientBase.cs" />
@ -113,6 +114,7 @@
<Compile Include="Client\DownloadClientClient.cs" />
<Compile Include="Client\NotificationClient.cs" />
<Compile Include="Client\CommandClient.cs" />
<Compile Include="Client\ReleasePushClient.cs" />
<Compile Include="Client\ReleaseClient.cs" />
<Compile Include="Client\SeriesClient.cs" />
<Compile Include="ApiTests\CommandFixture.cs" />

Loading…
Cancel
Save