1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00

fixed server side indexer issue

This commit is contained in:
kay.one 2013-05-02 22:24:52 -07:00
parent 370ab86dca
commit 1877f70403
15 changed files with 104 additions and 63 deletions

View File

@ -1,6 +1,7 @@
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Api.ClientSchema;
using NzbDrone.Core.Annotations;
using NzbDrone.Test.Common;
namespace NzbDrone.Api.Test.ClientSchemaTests
@ -41,5 +42,7 @@ public class TestModel
[FieldDefinition(1, Label = "Last Name", HelpText = "Your Last Name")]
public string LastName { get; set; }
public string Other { get; set; }
}
}

View File

@ -2,17 +2,5 @@
namespace NzbDrone.Api.ClientSchema
{
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public class FieldDefinitionAttribute : Attribute
{
public FieldDefinitionAttribute(int order)
{
Order = order;
}
public int Order { get; private set; }
public string Label { get; set; }
public string HelpText { get; set; }
}
}

View File

@ -1,5 +1,6 @@
using System.Collections.Generic;
using NzbDrone.Common.Reflection;
using NzbDrone.Core.Annotations;
namespace NzbDrone.Api.ClientSchema
{
@ -13,24 +14,28 @@ public static List<Field> GenerateSchema(object model)
foreach (var propertyInfo in properties)
{
var fieldAttribute = propertyInfo.GetAttribute<FieldDefinitionAttribute>();
var fieldAttribute = propertyInfo.GetAttribute<FieldDefinitionAttribute>(false);
var field = new Field()
{
Name = propertyInfo.Name,
Label = fieldAttribute.Label,
HelpText = fieldAttribute.HelpText,
Order = fieldAttribute.Order,
};
var value = propertyInfo.GetValue(model, null);
if (value != null)
if (fieldAttribute != null)
{
field.Value = value.ToString();
}
result.Add(field);
var field = new Field()
{
Name = propertyInfo.Name,
Label = fieldAttribute.Label,
HelpText = fieldAttribute.HelpText,
Order = fieldAttribute.Order,
};
var value = propertyInfo.GetValue(model, null);
if (value != null)
{
field.Value = value.ToString();
}
result.Add(field);
}
}
return result;

View File

@ -15,7 +15,7 @@ public string Map(string resourceUrl)
path = path.Trim(Path.DirectorySeparatorChar).ToLower();
return Path.Combine("ui", path);
return Path.Combine(Directory.GetCurrentDirectory(), "ui", path);
}
}
}

View File

@ -21,11 +21,13 @@ private List<IndexerResource> GetAll()
var result = new List<IndexerResource>(indexers.Count);
foreach (var indexerDefinition in indexers)
foreach (var indexer in indexers)
{
var resource = new IndexerResource();
resource.InjectFrom(indexerDefinition);
resource.Fields = SchemaBuilder.GenerateSchema(indexerDefinition.Settings);
var indexerResource = new IndexerResource();
indexerResource.InjectFrom(indexer);
indexerResource.Fields = SchemaBuilder.GenerateSchema(indexer.Settings);
result.Add(indexerResource);
}
return result;

View File

@ -23,38 +23,8 @@
<NamedTestSelector>
<TestName>NzbDrone.Common.Test.EnviromentProviderTest.ApplicationPath_should_find_root_in_current_folder</TestName>
</NamedTestSelector>
<NamedTestSelector>
<TestName>NzbDrone.Common.Test.ProcessProviderTests.Should_be_able_to_kill_procces</TestName>
</NamedTestSelector>
<NamedTestSelector>
<TestName>NzbDrone.Common.Test.ProcessProviderTests.Should_be_able_to_start_process</TestName>
</NamedTestSelector>
<NamedTestSelector>
<TestName>NzbDrone.Common.Test.ServiceProviderTests.Service_should_be_installed_and_then_uninstalled</TestName>
</NamedTestSelector>
<NamedTestSelector>
<TestName>NzbDrone.Common.Test.ServiceProviderTests.Should_be_able_to_start_and_stop_service</TestName>
</NamedTestSelector>
<RegexTestSelector>
<RegularExpression>NzbDrone\.Common\.Test\.ConfigFileProviderTest\..*</RegularExpression>
</RegexTestSelector>
<RegexTestSelector>
<RegularExpression>NzbDrone\.Common\.Test\.EnvironmentProviderTest\..*</RegularExpression>
</RegexTestSelector>
<RegexTestSelector>
<RegularExpression>NzbDrone\.Common\.Test\.EventingTests\.ServiceNameFixture\..*</RegularExpression>
</RegexTestSelector>
<RegexTestSelector>
<RegularExpression>NzbDrone\.Common\.Test\.ProcessProviderTests\..*</RegularExpression>
</RegexTestSelector>
<RegexTestSelector>
<RegularExpression>NzbDrone\.Common\.Test\.ReportingService_ReportParseError_Fixture\..*</RegularExpression>
</RegexTestSelector>
<RegexTestSelector>
<RegularExpression>NzbDrone\.Common\.Test\.ServiceProviderTests\..*</RegularExpression>
</RegexTestSelector>
<RegexTestSelector>
<RegularExpression>NzbDrone\.Common\.Test\.WebClientTests\..*</RegularExpression>
</RegexTestSelector>
</IgnoredTests>
</ProjectConfiguration>

View File

@ -0,0 +1,17 @@
using System;
namespace NzbDrone.Core.Annotations
{
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public class FieldDefinitionAttribute : Attribute
{
public FieldDefinitionAttribute(int order)
{
Order = order;
}
public int Order { get; private set; }
public string Label { get; set; }
public string HelpText { get; set; }
}
}

View File

@ -1,10 +1,14 @@
using System;
using NzbDrone.Core.Annotations;
namespace NzbDrone.Core.Indexers.Newznab
{
public class NewznabSettings : IIndexerSetting
{
[FieldDefinition(0, Label = "URL", HelpText = "NewzNab Host Url")]
public String Url { get; set; }
[FieldDefinition(1, Label = "API Key", HelpText = "Your API Key")]
public String ApiKey { get; set; }
public bool IsValid

View File

@ -1,12 +1,16 @@
using System;
using NzbDrone.Core.Annotations;
namespace NzbDrone.Core.Indexers.NzbsRUs
{
public class NzbsrusSetting : IIndexerSetting
{
[FieldDefinition(0, Label = "UID", HelpText = "Your NzbsRus User ID")]
public String Uid { get; set; }
[FieldDefinition(1, Label = "Hash", HelpText = "Your API Hash Key")]
public String Hash { get; set; }
public bool IsValid
{
get

View File

@ -1,10 +1,14 @@
using System;
using NzbDrone.Core.Annotations;
namespace NzbDrone.Core.Indexers.Omgwtfnzbs
{
public class OmgwtfnzbsSetting : IIndexerSetting
{
[FieldDefinition(0, Label = "Username", HelpText = "Your Username")]
public String Username { get; set; }
[FieldDefinition(1, Label = "API Key", HelpText = "Your API Key")]
public String ApiKey { get; set; }
public bool IsValid

View File

@ -176,6 +176,7 @@
<Compile Include="..\NzbDrone.Common\Properties\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Annotations\FieldDefinitionAttribute.cs" />
<Compile Include="Configuration\Config.cs" />
<Compile Include="Configuration\ConfigRepository.cs" />
<Compile Include="Configuration\IConfigService.cs" />

View File

@ -0,0 +1,16 @@
using NzbDrone.Api.Indexers;
using RestSharp;
namespace NzbDrone.Integration.Test.Client
{
public class IndexerClient : ClientBase<IndexerResource>
{
public IndexerClient(IRestClient restClient)
: base(restClient)
{
}
}
}

View File

@ -0,0 +1,22 @@
using System.IO;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Api.RootFolders;
namespace NzbDrone.Integration.Test
{
[TestFixture]
public class IndexerIntegrationFixture : IntegrationTest
{
[Test]
public void should_have_built_in_indexer()
{
var indexers = Indexers.All();
indexers.Should().NotBeEmpty();
indexers.Should().NotContain(c => string.IsNullOrWhiteSpace(c.Name));
}
}
}

View File

@ -7,6 +7,7 @@
using Nancy.Hosting.Self;
using NzbDrone.Api;
using NzbDrone.Api.Commands;
using NzbDrone.Api.Indexers;
using NzbDrone.Api.RootFolders;
using NzbDrone.Common;
using NzbDrone.Core.Datastore;
@ -32,6 +33,7 @@ public abstract class IntegrationTest
protected ClientBase<RootFolderResource> RootFolders;
protected ClientBase<CommandResource> Commands;
protected ReleaseClient Releases;
protected IndexerClient Indexers;
static IntegrationTest()
{
@ -89,6 +91,7 @@ public void SmokeTestSetup()
Releases = new ReleaseClient(RestClient);
RootFolders = new ClientBase<RootFolderResource>(RestClient);
Commands = new ClientBase<CommandResource>(RestClient);
Indexers = new IndexerClient(RestClient);
_host.Start();
}

View File

@ -68,9 +68,11 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Client\ClientBase.cs" />
<Compile Include="Client\IndexerClient.cs" />
<Compile Include="Client\SeriesClient - Copy.cs" />
<Compile Include="Client\SeriesClient.cs" />
<Compile Include="CommandIntegerationTests.cs" />
<Compile Include="IndexerIntegrationFixture.cs" />
<Compile Include="QualityProfileIntegrationTest.cs" />
<Compile Include="ReleaseIntegrationTest.cs" />
<Compile Include="IntegrationTest.cs" />