1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-26 22:46:53 -04:00

Fixed: Automation/Integration/Unit Tests

This commit is contained in:
Qstick
2019-09-02 22:22:25 -04:00
parent 944f420270
commit 7f221c7834
123 changed files with 1384 additions and 1191 deletions
@@ -2,7 +2,6 @@ using System.Collections.Generic;
using System.Net;
using FluentAssertions;
using NLog;
using NzbDrone.Api;
using Radarr.Http.REST;
using Radarr.Http;
using NzbDrone.Common.Serializer;
@@ -40,7 +39,7 @@ namespace NzbDrone.Integration.Test.Client
return request;
}
public T Execute<T>(IRestRequest request, HttpStatusCode statusCode) where T : class, new()
public string Execute(IRestRequest request, HttpStatusCode statusCode)
{
_logger.Info("{0}: {1}", request.Method, _restClient.BuildUri(request));
@@ -58,7 +57,14 @@ namespace NzbDrone.Integration.Test.Client
response.StatusCode.Should().Be(statusCode);
return Json.Deserialize<T>(response.Content);
return response.Content;
}
public T Execute<T>(IRestRequest request, HttpStatusCode statusCode) where T : class, new()
{
var content = Execute(request, statusCode);
return Json.Deserialize<T>(content);
}
private static void AssertDisableCache(IList<Parameter> headers)
@@ -1,23 +1,47 @@
using NzbDrone.Api.Commands;
using RestSharp;
using RestSharp;
using NzbDrone.Core.Messaging.Commands;
using FluentAssertions;
using System.Threading;
using NUnit.Framework;
using System.Linq;
using System;
using Radarr.Http.REST;
using Newtonsoft.Json;
namespace NzbDrone.Integration.Test.Client
{
public class CommandClient : ClientBase<CommandResource>
public class SimpleCommandResource : RestResource
{
public string Name { get; set; }
public string CommandName { get; set; }
public string Message { get; set; }
public CommandPriority Priority { get; set; }
public CommandStatus Status { get; set; }
public DateTime Queued { get; set; }
public DateTime? Started { get; set; }
public DateTime? Ended { get; set; }
public TimeSpan? Duration { get; set; }
public string Exception { get; set; }
public CommandTrigger Trigger { get; set; }
[JsonIgnore]
public Command Body { get; set; }
[JsonProperty("body")]
public Command BodyReadOnly { get { return Body; } }
}
public class CommandClient : ClientBase<SimpleCommandResource>
{
public CommandClient(IRestClient restClient, string apiKey)
: base(restClient, apiKey)
: base(restClient, apiKey, "command")
{
}
public CommandResource PostAndWait(CommandResource command)
public SimpleCommandResource PostAndWait<T>(T command) where T : Command, new()
{
var result = Post(command);
var request = BuildRequest();
request.AddBody(command);
var result = Post<SimpleCommandResource>(request);
result.Id.Should().NotBe(0);
for (var i = 0; i < 50; i++)
@@ -1,5 +1,5 @@
using System.Collections.Generic;
using NzbDrone.Api.DownloadClient;
using Radarr.Api.V2.DownloadClient;
using RestSharp;
namespace NzbDrone.Integration.Test.Client
@@ -1,4 +1,4 @@
using NzbDrone.Api.Indexers;
using Radarr.Api.V2.Indexers;
using RestSharp;
namespace NzbDrone.Integration.Test.Client
@@ -0,0 +1,24 @@
using System;
using RestSharp;
namespace NzbDrone.Integration.Test.Client
{
public class LogsClient : ClientBase
{
public LogsClient(IRestClient restClient, string apiKey)
: base(restClient, apiKey, "log/file")
{
}
public string[] GetLogFileLines(string filename)
{
var request = BuildRequest(filename);
var content = Execute(request, System.Net.HttpStatusCode.OK);
var lines = content.Split('\n');
lines = Array.ConvertAll(lines, s => s.TrimEnd('\r'));
Array.Resize(ref lines, lines.Length - 1);
return lines;
}
}
}
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using System.Net;
using NzbDrone.Api.Movies;
using Radarr.Api.V2.Movies;
using RestSharp;
namespace NzbDrone.Integration.Test.Client
@@ -19,7 +19,7 @@ namespace NzbDrone.Integration.Test.Client
return Get<List<MovieResource>>(request);
}
public List<MovieResource> Editor(List<MovieResource> movie)
public List<MovieResource> Editor(MovieEditorResource movie)
{
var request = BuildRequest("editor");
request.AddJsonBody(movie);
@@ -1,5 +1,5 @@
using System.Collections.Generic;
using NzbDrone.Api.Notifications;
using Radarr.Api.V2.Notifications;
using RestSharp;
namespace NzbDrone.Integration.Test.Client
@@ -1,4 +1,4 @@
using NzbDrone.Api.Indexers;
using Radarr.Api.V2.Indexers;
using RestSharp;
namespace NzbDrone.Integration.Test.Client