mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 05:53:33 -07:00
release endpoint now returns fully parsed rss info with decisions.
This commit is contained in:
parent
7e473ca78d
commit
ca8eba9cf1
43 changed files with 458 additions and 336 deletions
|
@ -3,6 +3,7 @@ using System.Net;
|
|||
using FluentAssertions;
|
||||
using NLog;
|
||||
using NzbDrone.Api.REST;
|
||||
using NzbDrone.Common;
|
||||
using RestSharp;
|
||||
|
||||
namespace NzbDrone.Integration.Test.Client
|
||||
|
@ -13,6 +14,7 @@ namespace NzbDrone.Integration.Test.Client
|
|||
private readonly string _resource;
|
||||
|
||||
private readonly Logger _logger;
|
||||
private readonly JsonSerializer _jsonSerializer;
|
||||
|
||||
public ClientBase(IRestClient restClient, string resource = null)
|
||||
{
|
||||
|
@ -23,6 +25,11 @@ namespace NzbDrone.Integration.Test.Client
|
|||
|
||||
_restClient = restClient;
|
||||
_resource = resource;
|
||||
|
||||
_jsonSerializer = new JsonSerializer();
|
||||
|
||||
|
||||
|
||||
_logger = LogManager.GetLogger("REST");
|
||||
}
|
||||
|
||||
|
@ -60,13 +67,13 @@ namespace NzbDrone.Integration.Test.Client
|
|||
};
|
||||
}
|
||||
|
||||
protected T Get<T>(IRestRequest request, HttpStatusCode statusCode = HttpStatusCode.OK) where T : new()
|
||||
protected T Get<T>(IRestRequest request, HttpStatusCode statusCode = HttpStatusCode.OK) where T : class, new()
|
||||
{
|
||||
request.Method = Method.GET;
|
||||
return Execute<T>(request, statusCode);
|
||||
}
|
||||
|
||||
public T Post<T>(IRestRequest request, HttpStatusCode statusCode = HttpStatusCode.Created) where T : new()
|
||||
public T Post<T>(IRestRequest request, HttpStatusCode statusCode = HttpStatusCode.Created) where T : class, new()
|
||||
{
|
||||
request.Method = Method.POST;
|
||||
return Execute<T>(request, statusCode);
|
||||
|
@ -78,11 +85,11 @@ namespace NzbDrone.Integration.Test.Client
|
|||
Execute<object>(request, statusCode);
|
||||
}
|
||||
|
||||
private T Execute<T>(IRestRequest request, HttpStatusCode statusCode) where T : new()
|
||||
private T Execute<T>(IRestRequest request, HttpStatusCode statusCode) where T : class, new()
|
||||
{
|
||||
_logger.Info("{0}: {1}", request.Method, _restClient.BuildUri(request));
|
||||
|
||||
var response = _restClient.Execute<T>(request);
|
||||
var response = _restClient.Execute(request);
|
||||
_logger.Info("Response: {0}", response.Content);
|
||||
|
||||
response.StatusCode.Should().Be(statusCode);
|
||||
|
@ -94,7 +101,7 @@ namespace NzbDrone.Integration.Test.Client
|
|||
|
||||
response.ErrorMessage.Should().BeBlank();
|
||||
|
||||
return response.Data;
|
||||
return _jsonSerializer.Deserialize<T>(response.Content);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
16
NzbDrone.Integration.Test/Client/SeriesClient - Copy.cs
Normal file
16
NzbDrone.Integration.Test/Client/SeriesClient - Copy.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
using NzbDrone.Api.Indexers;
|
||||
using RestSharp;
|
||||
|
||||
namespace NzbDrone.Integration.Test.Client
|
||||
{
|
||||
public class ReleaseClient : ClientBase<ReleaseResource>
|
||||
{
|
||||
public ReleaseClient(IRestClient restClient)
|
||||
: base(restClient)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -31,15 +31,16 @@ namespace NzbDrone.Integration.Test
|
|||
protected SeriesClient Series;
|
||||
protected ClientBase<RootFolderResource> RootFolders;
|
||||
protected ClientBase<CommandResource> Commands;
|
||||
protected ReleaseClient Releases;
|
||||
|
||||
static IntegrationTest()
|
||||
{
|
||||
if (LogManager.Configuration == null || LogManager.Configuration is XmlLoggingConfiguration)
|
||||
{
|
||||
LogManager.Configuration = new LoggingConfiguration();
|
||||
var consoleTarget = new ConsoleTarget { Layout = "${logger} - ${message} ${exception}" };
|
||||
var consoleTarget = new ConsoleTarget { Layout = "${time} - ${logger} - ${message} ${exception}" };
|
||||
LogManager.Configuration.AddTarget(consoleTarget.GetType().Name, consoleTarget);
|
||||
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Info, consoleTarget));
|
||||
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Trace, consoleTarget));
|
||||
}
|
||||
|
||||
|
||||
|
@ -85,6 +86,7 @@ namespace NzbDrone.Integration.Test
|
|||
|
||||
RestClient = new RestClient(url + "/api/");
|
||||
Series = new SeriesClient(RestClient);
|
||||
Releases = new ReleaseClient(RestClient);
|
||||
RootFolders = new ClientBase<RootFolderResource>(RestClient);
|
||||
Commands = new ClientBase<CommandResource>(RestClient);
|
||||
|
||||
|
|
|
@ -75,8 +75,10 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Client\ClientBase.cs" />
|
||||
<Compile Include="Client\SeriesClient - Copy.cs" />
|
||||
<Compile Include="Client\SeriesClient.cs" />
|
||||
<Compile Include="CommandIntegerationTests.cs" />
|
||||
<Compile Include="ReleaseIntegrationTest.cs" />
|
||||
<Compile Include="IntegrationTest.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RootFolderIntegrationTest.cs" />
|
||||
|
|
17
NzbDrone.Integration.Test/ReleaseIntegrationTest.cs
Normal file
17
NzbDrone.Integration.Test/ReleaseIntegrationTest.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace NzbDrone.Integration.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class ReleaseIntegrationTest : IntegrationTest
|
||||
{
|
||||
[Test]
|
||||
public void should_only_have_unknown_series_releases()
|
||||
{
|
||||
Releases.All().Should().OnlyContain(c => c.Rejections.Contains("Unknown Series"));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue