Switch Integration Tests to V3 API

This commit is contained in:
Qstick 2021-07-28 22:15:37 -04:00 committed by Mark McDowall
parent b819246655
commit fdecd1fea4
25 changed files with 60 additions and 56 deletions

View File

@ -1,6 +1,7 @@
using FluentAssertions; using FluentAssertions;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Api.Series; using Sonarr.Api.V3.Blocklist;
using Sonarr.Api.V3.Series;
namespace NzbDrone.Integration.Test.ApiTests namespace NzbDrone.Integration.Test.ApiTests
{ {
@ -15,7 +16,7 @@ namespace NzbDrone.Integration.Test.ApiTests
{ {
_series = EnsureSeries(266189, "The Blacklist"); _series = EnsureSeries(266189, "The Blacklist");
Blocklist.Post(new Api.Blocklist.BlocklistResource Blocklist.Post(new BlocklistResource
{ {
SeriesId = _series.Id, SeriesId = _series.Id,
SourceTitle = "Blacklist.S01E01.Brought.To.You.By-BoomBoxHD" SourceTitle = "Blacklist.S01E01.Brought.To.You.By-BoomBoxHD"

View File

@ -1,6 +1,6 @@
using FluentAssertions; using FluentAssertions;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Api.Episodes; using Sonarr.Api.V3.Episodes;
using NzbDrone.Integration.Test.Client; using NzbDrone.Integration.Test.Client;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,6 +1,6 @@
using FluentAssertions; using FluentAssertions;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Api.Commands; using Sonarr.Api.V3.Commands;
namespace NzbDrone.Integration.Test.ApiTests namespace NzbDrone.Integration.Test.ApiTests
{ {

View File

@ -1,7 +1,7 @@
using System.Linq; using System.Linq;
using FluentAssertions; using FluentAssertions;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Api.DiskSpace; using Sonarr.Api.V3.DiskSpace;
using NzbDrone.Integration.Test.Client; using NzbDrone.Integration.Test.Client;
namespace NzbDrone.Integration.Test.ApiTests namespace NzbDrone.Integration.Test.ApiTests

View File

@ -1,7 +1,7 @@
using System.Threading; using System.Threading;
using FluentAssertions; using FluentAssertions;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Api.Series; using Sonarr.Api.V3.Series;
using System.Linq; using System.Linq;
using NzbDrone.Test.Common; using NzbDrone.Test.Common;
@ -22,7 +22,7 @@ namespace NzbDrone.Integration.Test.ApiTests
{ {
var newSeries = Series.Lookup("archer").Single(c => c.TvdbId == 110381); var newSeries = Series.Lookup("archer").Single(c => c.TvdbId == 110381);
newSeries.ProfileId = 1; newSeries.QualityProfileId = 1;
newSeries.LanguageProfileId = 1; newSeries.LanguageProfileId = 1;
newSeries.Path = @"C:\Test\Archer".AsOsAgnostic(); newSeries.Path = @"C:\Test\Archer".AsOsAgnostic();

View File

@ -2,7 +2,7 @@
using FluentAssertions; using FluentAssertions;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Api.Indexers; using Sonarr.Api.V3.Indexers;
using NzbDrone.Core.ThingiProvider; using NzbDrone.Core.ThingiProvider;
using Sonarr.Http.ClientSchema; using Sonarr.Http.ClientSchema;
@ -28,7 +28,8 @@ namespace NzbDrone.Integration.Test.ApiTests
schema.Name = name; schema.Name = name;
schema.EnableRss = false; schema.EnableRss = false;
schema.EnableSearch = false; schema.EnableAutomaticSearch = false;
schema.EnableInteractiveSearch = false;
return schema; return schema;
} }
@ -39,7 +40,8 @@ namespace NzbDrone.Integration.Test.ApiTests
schema.Name = name; schema.Name = name;
schema.EnableRss = false; schema.EnableRss = false;
schema.EnableSearch = false; schema.EnableAutomaticSearch = false;
schema.EnableInteractiveSearch = false;
return schema; return schema;
} }

View File

@ -1,6 +1,6 @@
using FluentAssertions; using FluentAssertions;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Api.Indexers; using Sonarr.Api.V3.Indexers;
using System.Linq; using System.Linq;
using System.Net; using System.Net;

View File

@ -1,6 +1,6 @@
using FluentAssertions; using FluentAssertions;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Api.Indexers; using Sonarr.Api.V3.Indexers;
using System.Net; using System.Net;
using System.Collections.Generic; using System.Collections.Generic;
using System; using System;

View File

@ -1,7 +1,7 @@
using System; using System;
using FluentAssertions; using FluentAssertions;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Api.RootFolders; using Sonarr.Api.V3.RootFolders;
namespace NzbDrone.Integration.Test.ApiTests namespace NzbDrone.Integration.Test.ApiTests
{ {

View File

@ -14,7 +14,7 @@ namespace NzbDrone.Integration.Test.ApiTests
{ {
var newSeries = Series.Lookup(title).First(); var newSeries = Series.Lookup(title).First();
newSeries.ProfileId = 1; newSeries.QualityProfileId = 1;
newSeries.LanguageProfileId = 1; newSeries.LanguageProfileId = 1;
newSeries.Path = string.Format(@"C:\Test\{0}", title).AsOsAgnostic(); newSeries.Path = string.Format(@"C:\Test\{0}", title).AsOsAgnostic();
@ -31,13 +31,13 @@ namespace NzbDrone.Integration.Test.ApiTests
foreach (var s in series) foreach (var s in series)
{ {
s.ProfileId = 2; s.QualityProfileId = 2;
} }
var result = Series.Editor(series); var result = Series.Editor(series);
result.Should().HaveCount(2); result.Should().HaveCount(2);
result.TrueForAll(s => s.ProfileId == 2).Should().BeTrue(); result.TrueForAll(s => s.QualityProfileId == 2).Should().BeTrue();
} }
} }
} }

View File

@ -17,7 +17,7 @@ namespace NzbDrone.Integration.Test.ApiTests
var series = Series.Lookup("tvdb:266189").Single(); var series = Series.Lookup("tvdb:266189").Single();
series.ProfileId = 1; series.QualityProfileId = 1;
series.LanguageProfileId = 1; series.LanguageProfileId = 1;
series.Path = Path.Combine(SeriesRootFolder, series.Title); series.Path = Path.Combine(SeriesRootFolder, series.Title);
series.Tags = new HashSet<int>(); series.Tags = new HashSet<int>();
@ -48,7 +48,7 @@ namespace NzbDrone.Integration.Test.ApiTests
var series = Series.Lookup("tvdb:266189").Single(); var series = Series.Lookup("tvdb:266189").Single();
series.ProfileId = 1; series.QualityProfileId = 1;
Series.InvalidPost(series); Series.InvalidPost(series);
} }
@ -60,7 +60,7 @@ namespace NzbDrone.Integration.Test.ApiTests
var series = Series.Lookup("tvdb:266189").Single(); var series = Series.Lookup("tvdb:266189").Single();
series.ProfileId = 1; series.QualityProfileId = 1;
series.LanguageProfileId = 1; series.LanguageProfileId = 1;
series.Path = Path.Combine(SeriesRootFolder, series.Title); series.Path = Path.Combine(SeriesRootFolder, series.Title);
@ -68,7 +68,7 @@ namespace NzbDrone.Integration.Test.ApiTests
result.Should().NotBeNull(); result.Should().NotBeNull();
result.Id.Should().NotBe(0); result.Id.Should().NotBe(0);
result.ProfileId.Should().Be(1); result.QualityProfileId.Should().Be(1);
result.LanguageProfileId.Should().Be(1); result.LanguageProfileId.Should().Be(1);
result.Path.Should().Be(Path.Combine(SeriesRootFolder, series.Title)); result.Path.Should().Be(Path.Combine(SeriesRootFolder, series.Title));
} }
@ -107,16 +107,16 @@ namespace NzbDrone.Integration.Test.ApiTests
var series = EnsureSeries(266189, "The Blacklist"); var series = EnsureSeries(266189, "The Blacklist");
var profileId = 1; var profileId = 1;
if (series.ProfileId == profileId) if (series.QualityProfileId == profileId)
{ {
profileId = 2; profileId = 2;
} }
series.ProfileId = profileId; series.QualityProfileId = profileId;
var result = Series.Put(series); var result = Series.Put(series);
Series.Get(series.Id).ProfileId.Should().Be(profileId); Series.Get(series.Id).QualityProfileId.Should().Be(profileId);
} }
[Test, Order(3)] [Test, Order(3)]

View File

@ -2,7 +2,6 @@
using System.Net; using System.Net;
using FluentAssertions; using FluentAssertions;
using NLog; using NLog;
using NzbDrone.Api;
using Sonarr.Http.REST; using Sonarr.Http.REST;
using NzbDrone.Common.Serializer; using NzbDrone.Common.Serializer;
using RestSharp; using RestSharp;

View File

@ -1,4 +1,4 @@
using NzbDrone.Api.Commands; using Sonarr.Api.V3.Commands;
using RestSharp; using RestSharp;
using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Commands;
using FluentAssertions; using FluentAssertions;

View File

@ -1,5 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using NzbDrone.Api.DownloadClient; using Sonarr.Api.V3.DownloadClient;
using RestSharp; using RestSharp;
namespace NzbDrone.Integration.Test.Client namespace NzbDrone.Integration.Test.Client

View File

@ -1,5 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using NzbDrone.Api.Episodes; using Sonarr.Api.V3.Episodes;
using RestSharp; using RestSharp;
namespace NzbDrone.Integration.Test.Client namespace NzbDrone.Integration.Test.Client

View File

@ -1,5 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using NzbDrone.Api.Indexers; using Sonarr.Api.V3.Indexers;
using RestSharp; using RestSharp;
namespace NzbDrone.Integration.Test.Client namespace NzbDrone.Integration.Test.Client

View File

@ -1,5 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using NzbDrone.Api.Notifications; using Sonarr.Api.V3.Notifications;
using RestSharp; using RestSharp;
namespace NzbDrone.Integration.Test.Client namespace NzbDrone.Integration.Test.Client

View File

@ -1,4 +1,4 @@
using NzbDrone.Api.Indexers; using Sonarr.Api.V3.Indexers;
using RestSharp; using RestSharp;
namespace NzbDrone.Integration.Test.Client namespace NzbDrone.Integration.Test.Client

View File

@ -1,4 +1,4 @@
using NzbDrone.Api.Indexers; using Sonarr.Api.V3.Indexers;
using RestSharp; using RestSharp;
namespace NzbDrone.Integration.Test.Client namespace NzbDrone.Integration.Test.Client

View File

@ -1,6 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Net; using System.Net;
using NzbDrone.Api.Series; using Sonarr.Api.V3.Series;
using RestSharp; using RestSharp;
namespace NzbDrone.Integration.Test.Client namespace NzbDrone.Integration.Test.Client

View File

@ -2,6 +2,7 @@ using System;
using System.Linq; using System.Linq;
using FluentAssertions; using FluentAssertions;
using NUnit.Framework; using NUnit.Framework;
using Sonarr.Api.V3.Series;
namespace NzbDrone.Integration.Test namespace NzbDrone.Integration.Test
{ {
@ -20,7 +21,7 @@ namespace NzbDrone.Integration.Test
var logFile = "sonarr.trace.txt"; var logFile = "sonarr.trace.txt";
var logLines = Logs.GetLogFileLines(logFile); var logLines = Logs.GetLogFileLines(logFile);
var resultPost = Series.InvalidPost(new Api.Series.SeriesResource()); var resultPost = Series.InvalidPost(new SeriesResource());
// Skip 2 and 1 to ignore the logs endpoint // Skip 2 and 1 to ignore the logs endpoint
logLines = Logs.GetLogFileLines(logFile).Skip(logLines.Length + 2).ToArray(); logLines = Logs.GetLogFileLines(logFile).Skip(logLines.Length + 2).ToArray();

View File

@ -1,6 +1,7 @@
using NLog; using NLog;
using NzbDrone.Core.Indexers.Newznab; using NzbDrone.Core.Indexers.Newznab;
using NzbDrone.Test.Common; using NzbDrone.Test.Common;
using Sonarr.Api.V3.Indexers;
using Sonarr.Http.ClientSchema; using Sonarr.Http.ClientSchema;
namespace NzbDrone.Integration.Test namespace NzbDrone.Integration.Test
@ -25,10 +26,11 @@ namespace NzbDrone.Integration.Test
protected override void InitializeTestTarget() protected override void InitializeTestTarget()
{ {
Indexers.Post(new Api.Indexers.IndexerResource Indexers.Post(new IndexerResource
{ {
EnableRss = false, EnableRss = false,
EnableSearch = false, EnableAutomaticSearch = false,
EnableInteractiveSearch = false,
ConfigContract = nameof(NewznabSettings), ConfigContract = nameof(NewznabSettings),
Implementation = nameof(Newznab), Implementation = nameof(Newznab),
Name = "NewznabTest", Name = "NewznabTest",

View File

@ -11,17 +11,17 @@ using NLog;
using NLog.Config; using NLog.Config;
using NLog.Targets; using NLog.Targets;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Api.Blocklist; using Sonarr.Api.V3.Blocklist;
using NzbDrone.Api.Commands; using Sonarr.Api.V3.Commands;
using NzbDrone.Api.Config; using Sonarr.Api.V3.Config;
using NzbDrone.Api.DownloadClient; using Sonarr.Api.V3.DownloadClient;
using NzbDrone.Api.EpisodeFiles; using Sonarr.Api.V3.EpisodeFiles;
using NzbDrone.Api.Episodes; using Sonarr.Api.V3.Episodes;
using NzbDrone.Api.History; using Sonarr.Api.V3.History;
using NzbDrone.Api.Profiles; using Sonarr.Api.V3.Profiles.Quality;
using NzbDrone.Api.RootFolders; using Sonarr.Api.V3.RootFolders;
using NzbDrone.Api.Series; using Sonarr.Api.V3.Series;
using NzbDrone.Api.Tags; using Sonarr.Api.V3.Tags;
using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Serializer; using NzbDrone.Common.Serializer;
using NzbDrone.Core.Qualities; using NzbDrone.Core.Qualities;
@ -50,7 +50,7 @@ namespace NzbDrone.Integration.Test
public LogsClient Logs; public LogsClient Logs;
public ClientBase<NamingConfigResource> NamingConfig; public ClientBase<NamingConfigResource> NamingConfig;
public NotificationClient Notifications; public NotificationClient Notifications;
public ClientBase<ProfileResource> Profiles; public ClientBase<QualityProfileResource> Profiles;
public ReleaseClient Releases; public ReleaseClient Releases;
public ReleasePushClient ReleasePush; public ReleasePushClient ReleasePush;
public ClientBase<RootFolderResource> RootFolders; public ClientBase<RootFolderResource> RootFolders;
@ -117,7 +117,7 @@ namespace NzbDrone.Integration.Test
Logs = new LogsClient(RestClient, ApiKey); Logs = new LogsClient(RestClient, ApiKey);
NamingConfig = new ClientBase<NamingConfigResource>(RestClient, ApiKey, "config/naming"); NamingConfig = new ClientBase<NamingConfigResource>(RestClient, ApiKey, "config/naming");
Notifications = new NotificationClient(RestClient, ApiKey); Notifications = new NotificationClient(RestClient, ApiKey);
Profiles = new ClientBase<ProfileResource>(RestClient, ApiKey); Profiles = new ClientBase<QualityProfileResource>(RestClient, ApiKey);
Releases = new ReleaseClient(RestClient, ApiKey); Releases = new ReleaseClient(RestClient, ApiKey);
ReleasePush = new ReleasePushClient(RestClient, ApiKey); ReleasePush = new ReleasePushClient(RestClient, ApiKey);
RootFolders = new ClientBase<RootFolderResource>(RestClient, ApiKey); RootFolders = new ClientBase<RootFolderResource>(RestClient, ApiKey);
@ -236,7 +236,7 @@ namespace NzbDrone.Integration.Test
{ {
var lookup = Series.Lookup("tvdb:" + tvdbId); var lookup = Series.Lookup("tvdb:" + tvdbId);
var series = lookup.First(); var series = lookup.First();
series.ProfileId = 1; series.QualityProfileId = 1;
series.LanguageProfileId = 1; series.LanguageProfileId = 1;
series.Path = Path.Combine(SeriesRootFolder, series.Title); series.Path = Path.Combine(SeriesRootFolder, series.Title);
series.Monitored = true; series.Monitored = true;
@ -308,14 +308,14 @@ namespace NzbDrone.Integration.Test
return result.EpisodeFile; return result.EpisodeFile;
} }
public ProfileResource EnsureProfileCutoff(int profileId, Quality cutoff, bool upgradeAllowed) public QualityProfileResource EnsureProfileCutoff(int profileId, Quality cutoff, bool upgradeAllowed)
{ {
var needsUpdate = false; var needsUpdate = false;
var profile = Profiles.Get(profileId); var profile = Profiles.Get(profileId);
if (profile.Cutoff != cutoff) if (profile.Cutoff != cutoff.Id)
{ {
profile.Cutoff = cutoff; profile.Cutoff = cutoff.Id;
needsUpdate = true; needsUpdate = true;
} }

View File

@ -7,7 +7,8 @@
<PackageReference Include="Microsoft.AspNet.SignalR.Client" Version="2.4.0" /> <PackageReference Include="Microsoft.AspNet.SignalR.Client" Version="2.4.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\NzbDrone.Api\Sonarr.Api.csproj" />
<ProjectReference Include="..\NzbDrone.Test.Common\Sonarr.Test.Common.csproj" /> <ProjectReference Include="..\NzbDrone.Test.Common\Sonarr.Test.Common.csproj" />
<ProjectReference Include="..\Sonarr.Api.V3\Sonarr.Api.V3.csproj" />
<ProjectReference Include="..\Sonarr.Http\Sonarr.Http.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -5,10 +5,8 @@ using Nancy.Bootstrapper;
using NLog; using NLog;
using NzbDrone.Common.Extensions; using NzbDrone.Common.Extensions;
using Sonarr.Http.ErrorManagement; using Sonarr.Http.ErrorManagement;
using Sonarr.Http.Extensions;
using Sonarr.Http.Extensions.Pipelines;
namespace NzbDrone.Api.Extensions.Pipelines namespace Sonarr.Http.Extensions.Pipelines
{ {
public class RequestLoggingPipeline : IRegisterNancyPipeline public class RequestLoggingPipeline : IRegisterNancyPipeline
{ {