mirror of https://github.com/Radarr/Radarr
Added service integration tests.
This commit is contained in:
parent
2fc561f195
commit
02a3b38210
|
@ -0,0 +1,56 @@
|
|||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using Ninject;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using PetaPoco;
|
||||
|
||||
namespace NzbDrone.Core.Test.Integeration
|
||||
{
|
||||
[TestFixture(Category = "ServiceIngeneration")]
|
||||
[Explicit]
|
||||
public class ServiceIntegerationFixture : CoreTest
|
||||
{
|
||||
private KernelBase _kernel;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
WithRealDb();
|
||||
_kernel = new StandardKernel();
|
||||
_kernel.Bind<IDatabase>().ToConstant(Db);
|
||||
|
||||
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.ServiceRootUrl)
|
||||
.Returns("http://stage.services.nzbdrone.com");
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_able_to_update_scene_mapping()
|
||||
{
|
||||
_kernel.Get<SceneMappingProvider>().UpdateMappings();
|
||||
var mappings = Db.Fetch<SceneMapping>();
|
||||
|
||||
mappings.Should().NotBeEmpty();
|
||||
|
||||
mappings.Should().OnlyContain(c => !string.IsNullOrWhiteSpace(c.CleanTitle));
|
||||
mappings.Should().OnlyContain(c => !string.IsNullOrWhiteSpace(c.SceneName));
|
||||
mappings.Should().OnlyContain(c => c.SeriesId > 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_able_to_get_daily_series_ids()
|
||||
{
|
||||
var dailySeries = _kernel.Get<ReferenceDataProvider>().GetDailySeriesIds();
|
||||
|
||||
dailySeries.Should().NotBeEmpty();
|
||||
dailySeries.Should().OnlyContain(c => c > 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -104,6 +104,7 @@
|
|||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Integeration\ServiceIntegerationFixture.cs" />
|
||||
<Compile Include="JobTests\BacklogSearchJobTest.cs" />
|
||||
<Compile Include="JobTests\BannerDownloadJobTest.cs" />
|
||||
<Compile Include="JobTests\RecentBacklogSearchJobTest.cs" />
|
||||
|
|
|
@ -3,16 +3,12 @@ using System.Linq;
|
|||
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
using PetaPoco;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
|
@ -25,6 +21,14 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
|
||||
private const string url = "http://services.nzbdrone.com/DailySeries/AllIds";
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.ServiceRootUrl)
|
||||
.Returns("http://services.nzbdrone.com");
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void GetDailySeriesIds_should_return_list_of_int_when_all_are_valid()
|
||||
{
|
||||
|
|
|
@ -19,6 +19,13 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
{
|
||||
private const string SceneMappingUrl = "http://services.nzbdrone.com/SceneMapping/Active";
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.ServiceRootUrl)
|
||||
.Returns("http://services.nzbdrone.com");
|
||||
}
|
||||
|
||||
private void WithValidJson()
|
||||
{
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
|
|
|
@ -422,6 +422,11 @@ namespace NzbDrone.Core.Providers.Core
|
|||
set { SetValue("BlackholeDirectory", value); }
|
||||
}
|
||||
|
||||
public virtual string ServiceRootUrl
|
||||
{
|
||||
get { return "http://services.nzbdrone.com"; }
|
||||
}
|
||||
|
||||
public string UGuid
|
||||
{
|
||||
get { return GetValue("UGuid", Guid.NewGuid().ToString(), persist: true); }
|
||||
|
|
|
@ -15,13 +15,15 @@ namespace NzbDrone.Core.Providers
|
|||
{
|
||||
private readonly IDatabase _database;
|
||||
private readonly HttpProvider _httpProvider;
|
||||
private readonly ConfigProvider _configProvider;
|
||||
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public ReferenceDataProvider(IDatabase database, HttpProvider httpProvider)
|
||||
public ReferenceDataProvider(IDatabase database, HttpProvider httpProvider, ConfigProvider configProvider)
|
||||
{
|
||||
_database = database;
|
||||
_httpProvider = httpProvider;
|
||||
_configProvider = configProvider;
|
||||
}
|
||||
|
||||
public virtual void UpdateDailySeries()
|
||||
|
@ -46,7 +48,7 @@ namespace NzbDrone.Core.Providers
|
|||
{
|
||||
try
|
||||
{
|
||||
var dailySeriesIds = _httpProvider.DownloadString("http://services.nzbdrone.com/DailySeries/AllIds");
|
||||
var dailySeriesIds = _httpProvider.DownloadString(_configProvider.ServiceRootUrl + "/DailySeries/AllIds");
|
||||
|
||||
var seriesIds = JsonConvert.DeserializeObject<List<int>>(dailySeriesIds);
|
||||
|
||||
|
|
|
@ -14,11 +14,13 @@ namespace NzbDrone.Core.Providers
|
|||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
private readonly IDatabase _database;
|
||||
private readonly HttpProvider _httpProvider;
|
||||
private readonly ConfigProvider _configProvider;
|
||||
|
||||
public SceneMappingProvider(IDatabase database, HttpProvider httpProvider)
|
||||
public SceneMappingProvider(IDatabase database, HttpProvider httpProvider, ConfigProvider configProvider)
|
||||
{
|
||||
_database = database;
|
||||
_httpProvider = httpProvider;
|
||||
_configProvider = configProvider;
|
||||
}
|
||||
|
||||
public SceneMappingProvider()
|
||||
|
@ -30,9 +32,7 @@ namespace NzbDrone.Core.Providers
|
|||
{
|
||||
try
|
||||
{
|
||||
const string url = "http://services.nzbdrone.com/SceneMapping/Active";
|
||||
|
||||
var mappingsJson = _httpProvider.DownloadString(url);
|
||||
var mappingsJson = _httpProvider.DownloadString(_configProvider.ServiceRootUrl + "/SceneMapping/Active");
|
||||
var mappings = JsonConvert.DeserializeObject<List<SceneMapping>>(mappingsJson);
|
||||
|
||||
Logger.Debug("Deleting all existing Scene Mappings.");
|
||||
|
|
Loading…
Reference in New Issue