mirror of
https://github.com/Radarr/Radarr
synced 2024-12-25 01:11:43 +00:00
added /api/resource/{id} route to fancy
stopped scheduler from running during integration tests.
This commit is contained in:
parent
e8d8588199
commit
90fa261a00
5 changed files with 33 additions and 4 deletions
|
@ -8,7 +8,6 @@ public abstract class NzbDroneApiModule : NancyModule
|
|||
protected NzbDroneApiModule(string resource)
|
||||
: base("/api/" + resource.Trim('/'))
|
||||
{
|
||||
Options["/"] = x => new Response();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Nancy.Security;
|
||||
using NzbDrone.Api.REST;
|
||||
using NzbDrone.Api.Validation;
|
||||
using NzbDrone.Core.Datastore;
|
||||
|
|
|
@ -145,6 +145,14 @@ protected Func<TResource, TResource> UpdateResource
|
|||
var resource = UpdateResource(ReadFromRequest());
|
||||
return resource.AsResponse(HttpStatusCode.Accepted);
|
||||
};
|
||||
|
||||
Put[ID_ROUTE] = options =>
|
||||
{
|
||||
var model = ReadFromRequest();
|
||||
model.Id = options.Id;
|
||||
var resource = UpdateResource(model);
|
||||
return resource.AsResponse(HttpStatusCode.Accepted);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -153,6 +161,11 @@ private TResource ReadFromRequest()
|
|||
//TODO: handle when request is null
|
||||
var resource = Request.Body.FromJson<TResource>();
|
||||
|
||||
if (resource == null)
|
||||
{
|
||||
throw new BadRequestException("Request body can't be empty");
|
||||
}
|
||||
|
||||
var errors = SharedValidator.Validate(resource).Errors.ToList();
|
||||
|
||||
if (Request.Method.Equals("POST", StringComparison.InvariantCultureIgnoreCase))
|
||||
|
|
|
@ -1,18 +1,23 @@
|
|||
using Nancy;
|
||||
using Nancy.Routing;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Api.Extensions;
|
||||
using System.Linq;
|
||||
|
||||
namespace NzbDrone.Api.System
|
||||
{
|
||||
public class SystemModule : NzbDroneApiModule
|
||||
{
|
||||
private readonly IEnvironmentProvider _environmentProvider;
|
||||
private readonly IRouteCacheProvider _routeCacheProvider;
|
||||
|
||||
public SystemModule(IEnvironmentProvider environmentProvider)
|
||||
public SystemModule(IEnvironmentProvider environmentProvider, IRouteCacheProvider routeCacheProvider)
|
||||
: base("system")
|
||||
{
|
||||
_environmentProvider = environmentProvider;
|
||||
_routeCacheProvider = routeCacheProvider;
|
||||
Get["/status"] = x => GetStatus();
|
||||
Get["/routes"] = x => GetRoutes();
|
||||
}
|
||||
|
||||
private Response GetStatus()
|
||||
|
@ -29,9 +34,15 @@ private Response GetStatus()
|
|||
IsMono = EnvironmentProvider.IsMono,
|
||||
IsProduction = EnvironmentProvider.IsProduction,
|
||||
IsDebug = EnvironmentProvider.IsDebug,
|
||||
IsLinux = EnvironmentProvider.IsLinux
|
||||
IsLinux = EnvironmentProvider.IsLinux,
|
||||
}.AsResponse();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private Response GetRoutes()
|
||||
{
|
||||
return _routeCacheProvider.GetCache().Values.AsResponse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Moq;
|
||||
|
@ -13,6 +14,7 @@
|
|||
using NzbDrone.Common.Composition;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Jobs;
|
||||
using NzbDrone.Integration.Test.Client;
|
||||
using NzbDrone.Owin;
|
||||
using NzbDrone.Owin.MiddleWare;
|
||||
|
@ -85,6 +87,11 @@ public void SmokeTestSetup()
|
|||
|
||||
InitDatabase();
|
||||
|
||||
var taskManagerMock = new Mock<ITaskManager>();
|
||||
taskManagerMock.Setup(c => c.GetPending()).Returns(new List<ScheduledTask>());
|
||||
|
||||
Container.TinyContainer.Register(taskManagerMock.Object);
|
||||
|
||||
_bootstrapper = new NancyBootstrapper(Container.TinyContainer);
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue