mirror of
https://github.com/Sonarr/Sonarr
synced 2026-05-08 21:21:47 +02:00
Switch integration tests to v5 API
This commit is contained in:
parent
bf5d48c76a
commit
2114c0c6e6
4 changed files with 7 additions and 54 deletions
|
|
@ -23,7 +23,7 @@ public List<SeriesResource> Editor(SeriesEditorResource series)
|
|||
{
|
||||
var request = BuildRequest("editor");
|
||||
request.AddJsonBody(series);
|
||||
return Put<List<SeriesResource>>(request);
|
||||
return Put<List<SeriesResource>>(request, HttpStatusCode.OK);
|
||||
}
|
||||
|
||||
public SeriesResource Get(string slug, HttpStatusCode statusCode = HttpStatusCode.OK)
|
||||
|
|
|
|||
|
|
@ -1,47 +0,0 @@
|
|||
using System.Net;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using RestSharp;
|
||||
|
||||
namespace NzbDrone.Integration.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class GenericApiFixture : IntegrationTest
|
||||
{
|
||||
[TestCase("application/json")]
|
||||
[TestCase("text/html, application/json")]
|
||||
[TestCase("application/xml, application/json")]
|
||||
[TestCase("text/html, */*")]
|
||||
[TestCase("*/*")]
|
||||
[TestCase("")]
|
||||
public void should_get_json_with_accept_header(string header)
|
||||
{
|
||||
var request = new RestRequest("system/status")
|
||||
{
|
||||
RequestFormat = DataFormat.None
|
||||
};
|
||||
request.AddHeader("Accept", header);
|
||||
|
||||
var response = RestClient.Execute(request);
|
||||
|
||||
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||
response.ContentType.Should().Be("application/json; charset=utf-8");
|
||||
}
|
||||
|
||||
[TestCase("application/xml")]
|
||||
[TestCase("text/html")]
|
||||
[TestCase("application/junk")]
|
||||
public void should_get_unacceptable_with_accept_header(string header)
|
||||
{
|
||||
var request = new RestRequest("system/status")
|
||||
{
|
||||
RequestFormat = DataFormat.None
|
||||
};
|
||||
request.AddHeader("Accept", header);
|
||||
|
||||
var response = RestClient.Execute(request);
|
||||
|
||||
response.StatusCode.Should().Be(HttpStatusCode.NotAcceptable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -16,20 +16,20 @@ public void should_log_on_error()
|
|||
config.LogLevel = "Trace";
|
||||
HostConfig.Put(config);
|
||||
|
||||
var resultGet = Series.All();
|
||||
Series.All();
|
||||
|
||||
var logFile = "sonarr.trace.txt";
|
||||
var logLines = Logs.GetLogFileLines(logFile);
|
||||
|
||||
var resultPost = Series.InvalidPost(new SeriesResource());
|
||||
Series.InvalidPost(new SeriesResource());
|
||||
|
||||
// Skip 2 and 1 to ignore the logs endpoint
|
||||
logLines = Logs.GetLogFileLines(logFile).Skip(logLines.Length + 2).ToArray();
|
||||
Array.Resize(ref logLines, logLines.Length - 1);
|
||||
|
||||
logLines.Should().Contain(v => v.Contains("|Trace|Http|Req") && v.Contains("/api/v3/series/"));
|
||||
logLines.Should().Contain(v => v.Contains("|Trace|Http|Res") && v.Contains("/api/v3/series/: 400.BadRequest"));
|
||||
logLines.Should().Contain(v => v.Contains("|Debug|Api|") && v.Contains("/api/v3/series/: 400.BadRequest"));
|
||||
logLines.Should().Contain(v => v.Contains("|Trace|Http|Req") && v.Contains("/api/v5/series/"));
|
||||
logLines.Should().Contain(v => v.Contains("|Trace|Http|Res") && v.Contains("/api/v5/series/: 400.BadRequest"));
|
||||
logLines.Should().Contain(v => v.Contains("|Debug|Api|") && v.Contains("/api/v5/series/: 400.BadRequest"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ public void SmokeTestSetup()
|
|||
|
||||
protected virtual void InitRestClients()
|
||||
{
|
||||
RestClient = new RestClient(RootUrl + "api/v3/");
|
||||
RestClient = new RestClient(RootUrl + "api/v5/");
|
||||
RestClient.AddDefaultHeader("Authentication", ApiKey);
|
||||
RestClient.AddDefaultHeader("X-Api-Key", ApiKey);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue