mirror of
https://github.com/fergalmoran/Readarr.git
synced 2026-01-06 16:55:49 +00:00
Merge branch 'develop'
This commit is contained in:
@@ -10,20 +10,28 @@ namespace NzbDrone.Integration.Test
|
||||
[TestFixture]
|
||||
public class EpisodeIntegrationTests : IntegrationTest
|
||||
{
|
||||
private SeriesResource series;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
series = GivenSeriesWithEpisodes();
|
||||
}
|
||||
|
||||
private SeriesResource GivenSeriesWithEpisodes()
|
||||
{
|
||||
var series = Series.Lookup("archer").First();
|
||||
var newSeries = Series.Lookup("archer").First();
|
||||
|
||||
series.QualityProfileId = 1;
|
||||
series.Path = @"C:\Test\Archer".AsOsAgnostic();
|
||||
newSeries.QualityProfileId = 1;
|
||||
newSeries.Path = @"C:\Test\Archer".AsOsAgnostic();
|
||||
|
||||
series = Series.Post(series);
|
||||
newSeries = Series.Post(newSeries);
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (Episodes.GetEpisodesInSeries(series.Id).Count > 0)
|
||||
if (Episodes.GetEpisodesInSeries(newSeries.Id).Count > 0)
|
||||
{
|
||||
return series;
|
||||
return newSeries;
|
||||
}
|
||||
|
||||
Thread.Sleep(1000);
|
||||
@@ -33,28 +41,33 @@ namespace NzbDrone.Integration.Test
|
||||
[Test]
|
||||
public void should_be_able_to_get_all_episodes_in_series()
|
||||
{
|
||||
var series = GivenSeriesWithEpisodes();
|
||||
Episodes.GetEpisodesInSeries(series.Id).Count.Should().BeGreaterThan(0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_able_to_get_a_single_episode()
|
||||
{
|
||||
var series = GivenSeriesWithEpisodes();
|
||||
var episodes = Episodes.GetEpisodesInSeries(series.Id);
|
||||
|
||||
Episodes.Get(episodes.First().Id).Should().NotBeNull();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_able_to_set_monitor_status_via_api()
|
||||
public void should_be_able_to_set_monitor_status()
|
||||
{
|
||||
var series = GivenSeriesWithEpisodes();
|
||||
var episodes = Episodes.GetEpisodesInSeries(series.Id);
|
||||
var updatedEpisode = episodes.First();
|
||||
updatedEpisode.Monitored = false;
|
||||
|
||||
Episodes.Put(updatedEpisode).Monitored.Should().BeFalse();
|
||||
}
|
||||
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
Series.Delete(series.Id);
|
||||
Thread.Sleep(2000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.AspNet.SignalR.Client;
|
||||
using Microsoft.AspNet.SignalR.Client.Transports;
|
||||
using NLog;
|
||||
using NLog.Config;
|
||||
using NLog.Targets;
|
||||
using NUnit.Framework;
|
||||
@@ -7,7 +12,10 @@ using NzbDrone.Api.Config;
|
||||
using NzbDrone.Api.History;
|
||||
using NzbDrone.Api.RootFolders;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Common.Serializer;
|
||||
using NzbDrone.Integration.Test.Client;
|
||||
using NzbDrone.SignalR;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Test.Common.Categories;
|
||||
using RestSharp;
|
||||
|
||||
@@ -29,6 +37,16 @@ namespace NzbDrone.Integration.Test
|
||||
protected ClientBase<NamingConfigResource> NamingConfig;
|
||||
|
||||
private NzbDroneRunner _runner;
|
||||
private List<SignalRMessage> _signalRReceived;
|
||||
private Connection _signalrConnection;
|
||||
|
||||
protected IEnumerable<SignalRMessage> SignalRMessages
|
||||
{
|
||||
get
|
||||
{
|
||||
return _signalRReceived;
|
||||
}
|
||||
}
|
||||
|
||||
public IntegrationTest()
|
||||
{
|
||||
@@ -40,8 +58,8 @@ namespace NzbDrone.Integration.Test
|
||||
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Trace, consoleTarget));
|
||||
}
|
||||
|
||||
//[TestFixtureSetUp]
|
||||
[SetUp]
|
||||
[TestFixtureSetUp]
|
||||
//[SetUp]
|
||||
public void SmokeTestSetup()
|
||||
{
|
||||
_runner = new NzbDroneRunner();
|
||||
@@ -64,11 +82,61 @@ namespace NzbDrone.Integration.Test
|
||||
NamingConfig = new ClientBase<NamingConfigResource>(RestClient, _runner.ApiKey, "config/naming");
|
||||
}
|
||||
|
||||
//[TestFixtureTearDown]
|
||||
[TearDown]
|
||||
[TestFixtureTearDown]
|
||||
//[TearDown]
|
||||
public void SmokeTestTearDown()
|
||||
{
|
||||
_runner.KillAll();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void IntegrationSetup()
|
||||
{
|
||||
if (_signalrConnection != null)
|
||||
{
|
||||
switch (_signalrConnection.State)
|
||||
{
|
||||
case ConnectionState.Connected:
|
||||
case ConnectionState.Connecting:
|
||||
{
|
||||
_signalrConnection.Stop();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_signalrConnection = null;
|
||||
_signalRReceived = new List<SignalRMessage>();
|
||||
}
|
||||
}
|
||||
|
||||
protected void ConnectSignalR()
|
||||
{
|
||||
_signalRReceived = new List<SignalRMessage>();
|
||||
_signalrConnection = new Connection("http://localhost:8989/signalr");
|
||||
_signalrConnection.Start(new LongPollingTransport()).ContinueWith(task =>
|
||||
{
|
||||
if (task.IsFaulted)
|
||||
{
|
||||
Assert.Fail("SignalrConnection failed. {0}", task.Exception.GetBaseException());
|
||||
}
|
||||
});
|
||||
|
||||
var retryCount = 0;
|
||||
|
||||
while (_signalrConnection.State != ConnectionState.Connected)
|
||||
{
|
||||
if (retryCount > 25)
|
||||
{
|
||||
Assert.Fail("Couldn't establish signalr connection. State: {0}", _signalrConnection.State);
|
||||
}
|
||||
|
||||
retryCount++;
|
||||
Console.WriteLine("Connecting to signalR" + _signalrConnection.State);
|
||||
Thread.Sleep(200);
|
||||
}
|
||||
|
||||
_signalrConnection.Received += json => _signalRReceived.Add(Json.Deserialize<SignalRMessage>(json)); ;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,11 +37,12 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\FluentAssertions.2.1.0.0\lib\net40\FluentAssertions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FluentValidation, Version=4.0.0.1, Culture=neutral, processorArchitecture=MSIL">
|
||||
<Reference Include="FluentValidation, Version=5.0.0.1, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\FluentValidation.4.0.0.1\lib\Net40\FluentValidation.dll</HintPath>
|
||||
<HintPath>..\packages\FluentValidation.5.0.0.1\lib\Net40\FluentValidation.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.AspNet.SignalR.Client">
|
||||
<Reference Include="Microsoft.AspNet.SignalR.Client, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Microsoft.AspNet.SignalR.Client.1.1.3\lib\net40\Microsoft.AspNet.SignalR.Client.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Owin">
|
||||
@@ -59,20 +60,21 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Nancy, Version=0.20.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<Reference Include="Nancy, Version=0.21.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Nancy.0.20.0\lib\net40\Nancy.dll</HintPath>
|
||||
<HintPath>..\packages\Nancy.0.21.1\lib\net40\Nancy.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Nancy.Owin, Version=0.20.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<Reference Include="Nancy.Owin, Version=0.21.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Nancy.Owin.0.20.0\lib\net40\Nancy.Owin.dll</HintPath>
|
||||
<HintPath>..\packages\Nancy.Owin.0.21.1\lib\net40\Nancy.Owin.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Newtonsoft.Json.5.0.6\lib\net40\Newtonsoft.Json.dll</HintPath>
|
||||
<HintPath>..\packages\Newtonsoft.Json.5.0.8\lib\net40\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NLog">
|
||||
<HintPath>..\packages\NLog.2.0.1.2\lib\net40\NLog.dll</HintPath>
|
||||
<Reference Include="NLog, Version=2.1.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\NLog.2.1.0\lib\net40\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework">
|
||||
<HintPath>..\packages\NUnit.2.6.2\lib\nunit.framework.dll</HintPath>
|
||||
@@ -81,9 +83,9 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RestSharp, Version=104.2.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<Reference Include="RestSharp, Version=104.3.3.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\RestSharp.104.2.0\lib\net4\RestSharp.dll</HintPath>
|
||||
<HintPath>..\packages\RestSharp.104.3.3\lib\net4\RestSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
@@ -105,7 +107,6 @@
|
||||
<Compile Include="EpisodeIntegrationTests.cs" />
|
||||
<Compile Include="IndexerIntegrationFixture.cs" />
|
||||
<Compile Include="IntegrationTestDirectoryInfo.cs" />
|
||||
<Compile Include="NzbDroneRunner.cs" />
|
||||
<Compile Include="QualityProfileIntegrationTest.cs" />
|
||||
<Compile Include="ReleaseIntegrationTest.cs" />
|
||||
<Compile Include="IntegrationTest.cs" />
|
||||
@@ -136,6 +137,10 @@
|
||||
<Project>{95C11A9E-56ED-456A-8447-2C89C1139266}</Project>
|
||||
<Name>NzbDrone.Host</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\NzbDrone.SignalR\NzbDrone.SignalR.csproj">
|
||||
<Project>{7C2CC69F-5CA0-4E5C-85CB-983F9F6C3B36}</Project>
|
||||
<Name>NzbDrone.SignalR</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\NzbDrone.Test.Common\NzbDrone.Test.Common.csproj">
|
||||
<Project>{CADDFCE0-7509-4430-8364-2074E1EEFCA2}</Project>
|
||||
<Name>NzbDrone.Test.Common</Name>
|
||||
|
||||
@@ -1,115 +0,0 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Xml.Linq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Common.Processes;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using RestSharp;
|
||||
|
||||
namespace NzbDrone.Integration.Test
|
||||
{
|
||||
public class NzbDroneRunner
|
||||
{
|
||||
private readonly IProcessProvider _processProvider;
|
||||
private readonly IRestClient _restClient;
|
||||
private Process _nzbDroneProcess;
|
||||
|
||||
public string AppData { get; private set; }
|
||||
public string ApiKey { get; private set; }
|
||||
|
||||
public NzbDroneRunner(int port = 8989)
|
||||
{
|
||||
_processProvider = new ProcessProvider();
|
||||
_restClient = new RestClient("http://localhost:8989/api");
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
AppData = Path.Combine(Directory.GetCurrentDirectory(), "_intg_" + DateTime.Now.Ticks);
|
||||
|
||||
var nzbdroneConsoleExe = "NzbDrone.Console.exe";
|
||||
|
||||
if (OsInfo.IsMono)
|
||||
{
|
||||
nzbdroneConsoleExe = "NzbDrone.exe";
|
||||
}
|
||||
|
||||
if (BuildInfo.IsDebug)
|
||||
{
|
||||
|
||||
Start("..\\..\\..\\..\\_output\\NzbDrone.Console.exe");
|
||||
}
|
||||
else
|
||||
{
|
||||
Start(Path.Combine("bin", nzbdroneConsoleExe));
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
_nzbDroneProcess.Refresh();
|
||||
|
||||
if (_nzbDroneProcess.HasExited)
|
||||
{
|
||||
Assert.Fail("Process has exited");
|
||||
}
|
||||
|
||||
SetApiKey();
|
||||
|
||||
var request = new RestRequest("system/status");
|
||||
request.AddHeader("Authorization", ApiKey);
|
||||
|
||||
var statusCall = _restClient.Get(request);
|
||||
|
||||
if (statusCall.ResponseStatus == ResponseStatus.Completed)
|
||||
{
|
||||
Console.WriteLine("NzbDrone is started. Running Tests");
|
||||
return;
|
||||
}
|
||||
|
||||
Console.WriteLine("Waiting for NzbDrone to start. Response Status : {0} [{1}] {2}", statusCall.ResponseStatus, statusCall.StatusDescription, statusCall.ErrorException);
|
||||
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
}
|
||||
|
||||
public void KillAll()
|
||||
{
|
||||
_processProvider.KillAll(ProcessProvider.NZB_DRONE_CONSOLE_PROCESS_NAME);
|
||||
_processProvider.KillAll(ProcessProvider.NZB_DRONE_PROCESS_NAME);
|
||||
}
|
||||
|
||||
private void Start(string outputNzbdroneConsoleExe)
|
||||
{
|
||||
var args = "-nobrowser -data=\"" + AppData + "\"";
|
||||
_nzbDroneProcess = _processProvider.Start(outputNzbdroneConsoleExe, args, OnOutputDataReceived, OnOutputDataReceived);
|
||||
|
||||
}
|
||||
|
||||
private void OnOutputDataReceived(string data)
|
||||
{
|
||||
Console.WriteLine(data);
|
||||
|
||||
if (data.Contains("Press enter to exit"))
|
||||
{
|
||||
_nzbDroneProcess.StandardInput.WriteLine(" ");
|
||||
}
|
||||
}
|
||||
|
||||
private void SetApiKey()
|
||||
{
|
||||
var configFile = Path.Combine(AppData, "config.xml");
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(ApiKey)) return;
|
||||
if (!File.Exists(configFile)) return;
|
||||
|
||||
var xDoc = XDocument.Load(configFile);
|
||||
var config = xDoc.Descendants(ConfigFileProvider.CONFIG_ELEMENT_NAME).Single();
|
||||
ApiKey = config.Descendants("ApiKey").Single().Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FluentAssertions;
|
||||
using Microsoft.AspNet.SignalR.Client;
|
||||
using Microsoft.AspNet.SignalR.Client.Transports;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Api.RootFolders;
|
||||
|
||||
@@ -11,39 +8,25 @@ namespace NzbDrone.Integration.Test
|
||||
[TestFixture]
|
||||
public class RootFolderIntegrationTest : IntegrationTest
|
||||
{
|
||||
private Connection _connection;
|
||||
private List<object> _signalRReceived;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_signalRReceived = new List<object>();
|
||||
_connection = new Connection("http://localhost:8989/signalr/rootfolder");
|
||||
_connection.Start(new LongPollingTransport()).ContinueWith(task =>
|
||||
{
|
||||
if (task.IsFaulted)
|
||||
{
|
||||
Assert.Fail("SignalrConnection failed. {0}", task.Exception.GetBaseException());
|
||||
}
|
||||
});
|
||||
|
||||
_connection.Received += _connection_Received;
|
||||
}
|
||||
|
||||
private void _connection_Received(string obj)
|
||||
{
|
||||
_signalRReceived.Add(obj);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_have_no_root_folder_initially()
|
||||
{
|
||||
RootFolders.All().Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_add_and_delete_root_folders()
|
||||
{
|
||||
|
||||
ConnectSignalR();
|
||||
|
||||
var rootFolder = new RootFolderResource
|
||||
{
|
||||
Path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
|
||||
};
|
||||
{
|
||||
Path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
|
||||
};
|
||||
|
||||
var postResponse = RootFolders.Post(rootFolder);
|
||||
|
||||
@@ -56,6 +39,11 @@ namespace NzbDrone.Integration.Test
|
||||
RootFolders.Delete(postResponse.Id);
|
||||
|
||||
RootFolders.All().Should().BeEmpty();
|
||||
|
||||
|
||||
SignalRMessages.Should().Contain(c => c.Name == "rootfolder");
|
||||
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="FluentAssertions" version="2.1.0.0" targetFramework="net40" />
|
||||
<package id="FluentValidation" version="4.0.0.1" targetFramework="net40" />
|
||||
<package id="FluentValidation" version="5.0.0.1" targetFramework="net40" />
|
||||
<package id="Microsoft.AspNet.SignalR.Client" version="1.1.3" targetFramework="net40" />
|
||||
<package id="Microsoft.Owin" version="1.1.0-beta2" targetFramework="net40" />
|
||||
<package id="Microsoft.Owin.Host.HttpListener" version="1.1.0-beta2" targetFramework="net40" />
|
||||
<package id="Microsoft.Owin.Hosting" version="1.1.0-beta2" targetFramework="net40" />
|
||||
<package id="Moq" version="4.0.10827" targetFramework="net40" />
|
||||
<package id="Nancy" version="0.20.0" targetFramework="net40" />
|
||||
<package id="Nancy.Owin" version="0.20.0" targetFramework="net40" />
|
||||
<package id="Newtonsoft.Json" version="5.0.6" targetFramework="net40" />
|
||||
<package id="NLog" version="2.0.1.2" targetFramework="net40" />
|
||||
<package id="Nancy" version="0.21.1" targetFramework="net40" />
|
||||
<package id="Nancy.Owin" version="0.21.1" targetFramework="net40" />
|
||||
<package id="Newtonsoft.Json" version="5.0.8" targetFramework="net40" />
|
||||
<package id="NLog" version="2.1.0" targetFramework="net40" />
|
||||
<package id="NUnit" version="2.6.2" targetFramework="net40" />
|
||||
<package id="Owin" version="1.0" targetFramework="net40" />
|
||||
<package id="RestSharp" version="104.2.0" targetFramework="net40" />
|
||||
<package id="RestSharp" version="104.3.3" targetFramework="net40" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user