1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-04-27 23:06:29 -04:00

Readded Movies cat to the end of the Newznab list

This commit is contained in:
Taloth Saldono
2020-11-14 22:33:03 +01:00
parent 158e31d54a
commit e5ec4e706a
5 changed files with 212 additions and 14 deletions
@@ -1,7 +1,10 @@
using System.Linq;
using FluentAssertions;
using Newtonsoft.Json.Linq;
using NUnit.Framework;
using NzbDrone.Api.Indexers;
using NzbDrone.Core.ThingiProvider;
using Sonarr.Http.ClientSchema;
namespace NzbDrone.Integration.Test.ApiTests
{
@@ -18,5 +21,183 @@ namespace NzbDrone.Integration.Test.ApiTests
indexers.Should().NotContain(c => string.IsNullOrWhiteSpace(c.Name));
indexers.Where(c => c.ConfigContract == typeof(NullConfig).Name).Should().OnlyContain(c => c.EnableRss);
}
private IndexerResource GetNewznabSchemav2(string name = null)
{
var schema = Indexers.Schema().First(v => v.Implementation == "Newznab");
schema.Name = name;
schema.EnableRss = false;
schema.EnableSearch = false;
return schema;
}
private IndexerResource GetNewznabSchemav3(string name = null)
{
var schema = Indexersv3.Schema().First(v => v.Implementation == "Newznab");
schema.Name = name;
schema.EnableRss = false;
schema.EnableSearch = false;
return schema;
}
private Field GetCategoriesField(IndexerResource resource)
{
var field = resource.Fields.First(v => v.Name == "categories");
return field;
}
[Test]
public void v2_categories_should_be_array()
{
var schema = GetNewznabSchemav2();
var categoriesField = GetCategoriesField(schema);
categoriesField.Value.Should().BeOfType<JArray>();
}
[Test]
public void v3_categories_should_be_array()
{
var schema = GetNewznabSchemav3();
var categoriesField = GetCategoriesField(schema);
categoriesField.Value.Should().BeOfType<JArray>();
}
[Test]
public void v2_categories_should_accept_null()
{
var schema = GetNewznabSchemav2("Testv2null");
var categoriesField = GetCategoriesField(schema);
categoriesField.Value = null;
var result = Indexers.Post(schema);
var resultArray = GetCategoriesField(result).Value;
resultArray.Should().BeOfType<JArray>();
resultArray.As<JArray>().Should().BeEmpty();
}
[Test]
public void v2_categories_should_accept_emptystring()
{
var schema = GetNewznabSchemav2("Testv2emptystring");
var categoriesField = GetCategoriesField(schema);
categoriesField.Value = "";
var result = Indexers.Post(schema);
var resultArray = GetCategoriesField(result).Value;
resultArray.Should().BeOfType<JArray>();
resultArray.As<JArray>().Should().BeEmpty();
}
[Test]
public void v2_categories_should_accept_string()
{
var schema = GetNewznabSchemav2("Testv2string");
var categoriesField = GetCategoriesField(schema);
categoriesField.Value = "1000,1010";
var result = Indexers.Post(schema);
var resultArray = GetCategoriesField(result).Value;
resultArray.Should().BeOfType<JArray>();
resultArray.As<JArray>().ToObject<int[]>().Should().BeEquivalentTo(new[] { 1000, 1010 });
}
[Test]
public void v2_categories_should_accept_array()
{
var schema = GetNewznabSchemav2("Testv2array");
var categoriesField = GetCategoriesField(schema);
categoriesField.Value = new object[] { 1000, 1010 };
var result = Indexers.Post(schema);
var resultArray = GetCategoriesField(result).Value;
resultArray.Should().BeOfType<JArray>();
resultArray.As<JArray>().ToObject<int[]>().Should().BeEquivalentTo(new[] { 1000, 1010 });
}
[Test]
public void v3_categories_should_accept_null()
{
var schema = GetNewznabSchemav3("Testv3null");
var categoriesField = GetCategoriesField(schema);
categoriesField.Value = null;
var result = Indexersv3.Post(schema);
var resultArray = GetCategoriesField(result).Value;
resultArray.Should().BeOfType<JArray>();
resultArray.As<JArray>().Should().BeEmpty();
}
[Test]
public void v3_categories_should_accept_emptystring()
{
var schema = GetNewznabSchemav3("Testv3emptystring");
var categoriesField = GetCategoriesField(schema);
categoriesField.Value = "";
var result = Indexersv3.Post(schema);
var resultArray = GetCategoriesField(result).Value;
resultArray.Should().BeOfType<JArray>();
resultArray.As<JArray>().Should().BeEmpty();
}
[Test]
public void v3_categories_should_accept_string()
{
var schema = GetNewznabSchemav3("Testv3string");
var categoriesField = GetCategoriesField(schema);
categoriesField.Value = "1000,1010";
var result = Indexersv3.Post(schema);
var resultArray = GetCategoriesField(result).Value;
resultArray.Should().BeOfType<JArray>();
resultArray.As<JArray>().ToObject<int[]>().Should().BeEquivalentTo(new[] { 1000, 1010 });
}
[Test]
public void v3_categories_should_accept_array()
{
var schema = GetNewznabSchemav3("Testv3array");
var categoriesField = GetCategoriesField(schema);
categoriesField.Value = new object[] { 1000, 1010 };
var result = Indexersv3.Post(schema);
var resultArray = GetCategoriesField(result).Value;
resultArray.Should().BeOfType<JArray>();
resultArray.As<JArray>().ToObject<int[]>().Should().BeEquivalentTo(new[] { 1000, 1010 });
}
}
}
@@ -1,4 +1,5 @@
using NzbDrone.Api.Indexers;
using System.Collections.Generic;
using NzbDrone.Api.Indexers;
using RestSharp;
namespace NzbDrone.Integration.Test.Client
@@ -9,5 +10,11 @@ namespace NzbDrone.Integration.Test.Client
: base(restClient, apiKey)
{
}
public List<IndexerResource> Schema()
{
var request = BuildRequest("/schema");
return Get<List<IndexerResource>>(request);
}
}
}
@@ -37,6 +37,7 @@ namespace NzbDrone.Integration.Test
public abstract class IntegrationTestBase
{
protected RestClient RestClient { get; private set; }
protected RestClient RestClientv3 { get; private set; }
public ClientBase<BlacklistResource> Blacklist;
public CommandClient Commands;
@@ -45,6 +46,7 @@ namespace NzbDrone.Integration.Test
public ClientBase<HistoryResource> History;
public ClientBase<HostConfigResource> HostConfig;
public IndexerClient Indexers;
public IndexerClient Indexersv3;
public LogsClient Logs;
public ClientBase<NamingConfigResource> NamingConfig;
public NotificationClient Notifications;
@@ -100,6 +102,10 @@ namespace NzbDrone.Integration.Test
RestClient.AddDefaultHeader("Authentication", ApiKey);
RestClient.AddDefaultHeader("X-Api-Key", ApiKey);
RestClientv3 = new RestClient(RootUrl + "api/v3/");
RestClientv3.AddDefaultHeader("Authentication", ApiKey);
RestClientv3.AddDefaultHeader("X-Api-Key", ApiKey);
Blacklist = new ClientBase<BlacklistResource>(RestClient, ApiKey);
Commands = new CommandClient(RestClient, ApiKey);
DownloadClients = new DownloadClientClient(RestClient, ApiKey);
@@ -107,6 +113,7 @@ namespace NzbDrone.Integration.Test
History = new ClientBase<HistoryResource>(RestClient, ApiKey);
HostConfig = new ClientBase<HostConfigResource>(RestClient, ApiKey, "config/host");
Indexers = new IndexerClient(RestClient, ApiKey);
Indexersv3 = new IndexerClient(RestClientv3, ApiKey);
Logs = new LogsClient(RestClient, ApiKey);
NamingConfig = new ClientBase<NamingConfigResource>(RestClient, ApiKey, "config/naming");
Notifications = new NotificationClient(RestClient, ApiKey);