Update Integration Unit Tests

pull/6/head
Qstick 7 years ago
parent fd048bc92e
commit a69ceb35fb

@ -1,8 +1,4 @@
using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Commands;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Music.Commands namespace NzbDrone.Core.Music.Commands
{ {

@ -1,5 +1,6 @@
using FluentAssertions; using FluentAssertions;
using NUnit.Framework; using NUnit.Framework;
using Lidarr.Api.V3.Artist;
using System.Linq; using System.Linq;
using NzbDrone.Test.Common; using NzbDrone.Test.Common;
@ -10,11 +11,12 @@ namespace NzbDrone.Integration.Test.ApiTests
{ {
private void GivenExistingArtist() private void GivenExistingArtist()
{ {
foreach (var name in new[] { "90210", "Dexter" }) foreach (var name in new[] { "Alien Ant Farm", "Kiss" })
{ {
var newArtist = Artist.Lookup(name).First(); var newArtist = Artist.Lookup(name).First();
newArtist.QualityProfileId = 1; newArtist.QualityProfileId = 1;
newArtist.LanguageProfileId = 1;
newArtist.Path = string.Format(@"C:\Test\{0}", name).AsOsAgnostic(); newArtist.Path = string.Format(@"C:\Test\{0}", name).AsOsAgnostic();
Artist.Post(newArtist); Artist.Post(newArtist);
@ -28,12 +30,13 @@ namespace NzbDrone.Integration.Test.ApiTests
var artist = Artist.All(); var artist = Artist.All();
foreach (var s in artist) var artistEditor = new ArtistEditorResource
{ {
s.QualityProfileId = 2; QualityProfileId = 2,
} ArtistIds = artist.Select(o => o.Id).ToList()
};
var result = Artist.Editor(artist); var result = Artist.Editor(artistEditor);
result.Should().HaveCount(2); result.Should().HaveCount(2);
result.TrueForAll(s => s.QualityProfileId == 2).Should().BeTrue(); result.TrueForAll(s => s.QualityProfileId == 2).Should().BeTrue();

@ -18,6 +18,7 @@ namespace NzbDrone.Integration.Test.ApiTests
var artist = Artist.Lookup("lidarr:f59c5520-5f46-4d2c-b2c4-822eabf53419").Single(); var artist = Artist.Lookup("lidarr:f59c5520-5f46-4d2c-b2c4-822eabf53419").Single();
artist.QualityProfileId = 1; artist.QualityProfileId = 1;
artist.LanguageProfileId = 1;
artist.Path = Path.Combine(ArtistRootFolder, artist.ArtistName); artist.Path = Path.Combine(ArtistRootFolder, artist.ArtistName);
artist.Tags = new HashSet<int>(); artist.Tags = new HashSet<int>();
artist.Tags.Add(tag.Id); artist.Tags.Add(tag.Id);
@ -48,6 +49,7 @@ namespace NzbDrone.Integration.Test.ApiTests
var artist = Artist.Lookup("lidarr:f59c5520-5f46-4d2c-b2c4-822eabf53419").Single(); var artist = Artist.Lookup("lidarr:f59c5520-5f46-4d2c-b2c4-822eabf53419").Single();
artist.QualityProfileId = 1; artist.QualityProfileId = 1;
artist.LanguageProfileId = 1;
Artist.InvalidPost(artist); Artist.InvalidPost(artist);
} }
@ -60,6 +62,7 @@ namespace NzbDrone.Integration.Test.ApiTests
var artist = Artist.Lookup("lidarr:f59c5520-5f46-4d2c-b2c4-822eabf53419").Single(); var artist = Artist.Lookup("lidarr:f59c5520-5f46-4d2c-b2c4-822eabf53419").Single();
artist.QualityProfileId = 1; artist.QualityProfileId = 1;
artist.LanguageProfileId = 1;
artist.Path = Path.Combine(ArtistRootFolder, artist.ArtistName); artist.Path = Path.Combine(ArtistRootFolder, artist.ArtistName);
var result = Artist.Post(artist); var result = Artist.Post(artist);
@ -67,6 +70,7 @@ namespace NzbDrone.Integration.Test.ApiTests
result.Should().NotBeNull(); result.Should().NotBeNull();
result.Id.Should().NotBe(0); result.Id.Should().NotBe(0);
result.QualityProfileId.Should().Be(1); result.QualityProfileId.Should().Be(1);
result.LanguageProfileId.Should().Be(1);
result.Path.Should().Be(Path.Combine(ArtistRootFolder, artist.ArtistName)); result.Path.Should().Be(Path.Combine(ArtistRootFolder, artist.ArtistName));
} }
@ -74,22 +78,24 @@ namespace NzbDrone.Integration.Test.ApiTests
[Test, Order(2)] [Test, Order(2)]
public void get_all_artist() public void get_all_artist()
{ {
EnsureArtist("266189", "Alien Ant Farm"); EnsureArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm");
EnsureArtist("73065", "Coldplay"); EnsureArtist("cc197bad-dc9c-440d-a5b5-d52ba2e14234", "Coldplay");
Artist.All().Should().NotBeNullOrEmpty(); var artists = Artist.All();
Artist.All().Should().Contain(v => v.ForeignArtistId == "73065");
Artist.All().Should().Contain(v => v.ForeignArtistId == "266189"); artists.Should().NotBeNullOrEmpty();
artists.Should().Contain(v => v.ForeignArtistId == "8ac6cc32-8ddf-43b1-9ac4-4b04f9053176");
artists.Should().Contain(v => v.ForeignArtistId == "cc197bad-dc9c-440d-a5b5-d52ba2e14234");
} }
[Test, Order(2)] [Test, Order(2)]
public void get_artist_by_id() public void get_artist_by_id()
{ {
var artist = EnsureArtist("266189", "Alien Ant Farm"); var artist = EnsureArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm");
var result = Artist.Get(artist.Id); var result = Artist.Get(artist.Id);
result.ForeignArtistId.Should().Be("266189"); result.ForeignArtistId.Should().Be("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176");
} }
[Test] [Test]
@ -101,7 +107,7 @@ namespace NzbDrone.Integration.Test.ApiTests
[Test, Order(2)] [Test, Order(2)]
public void update_artist_profile_id() public void update_artist_profile_id()
{ {
var artist = EnsureArtist("266189", "Alien Ant Farm"); var artist = EnsureArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm");
var profileId = 1; var profileId = 1;
if (artist.QualityProfileId == profileId) if (artist.QualityProfileId == profileId)
@ -110,6 +116,7 @@ namespace NzbDrone.Integration.Test.ApiTests
} }
artist.QualityProfileId = profileId; artist.QualityProfileId = profileId;
artist.LanguageProfileId = profileId;
var result = Artist.Put(artist); var result = Artist.Put(artist);
@ -139,7 +146,7 @@ namespace NzbDrone.Integration.Test.ApiTests
[Test, Order(3)] [Test, Order(3)]
public void update_artist_tags() public void update_artist_tags()
{ {
var artist = EnsureArtist("266189", "Alien Ant Farm"); var artist = EnsureArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm");
var tag = EnsureTag("abc"); var tag = EnsureTag("abc");
if (artist.Tags.Contains(tag.Id)) if (artist.Tags.Contains(tag.Id))
@ -161,13 +168,13 @@ namespace NzbDrone.Integration.Test.ApiTests
[Test, Order(4)] [Test, Order(4)]
public void delete_artist() public void delete_artist()
{ {
var artist = EnsureArtist("266189", "Alien Ant Farm"); var artist = EnsureArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm");
Artist.Get(artist.Id).Should().NotBeNull(); Artist.Get(artist.Id).Should().NotBeNull();
Artist.Delete(artist.Id); Artist.Delete(artist.Id);
Artist.All().Should().NotContain(v => v.ForeignArtistId == "266189"); Artist.All().Should().NotContain(v => v.ForeignArtistId == "8ac6cc32-8ddf-43b1-9ac4-4b04f9053176");
} }
} }
} }

@ -6,8 +6,8 @@ namespace NzbDrone.Integration.Test.ApiTests
[TestFixture] [TestFixture]
public class ArtistLookupFixture : IntegrationTest public class ArtistLookupFixture : IntegrationTest
{ {
[TestCase("archer", "Archer (2009)")] [TestCase("Kiss", "Kiss")]
[TestCase("90210", "90210")] [TestCase("Linkin Park", "Linkin Park")]
public void lookup_new_artist_by_name(string term, string name) public void lookup_new_artist_by_name(string term, string name)
{ {
var artist = Artist.Lookup(term); var artist = Artist.Lookup(term);
@ -17,17 +17,17 @@ namespace NzbDrone.Integration.Test.ApiTests
} }
[Test] [Test]
public void lookup_new_series_by_tvdbid() public void lookup_new_artist_by_mbid()
{ {
var artist = Artist.Lookup("lidarr:266189"); var artist = Artist.Lookup("lidarr:f59c5520-5f46-4d2c-b2c4-822eabf53419");
artist.Should().NotBeEmpty(); artist.Should().NotBeEmpty();
artist.Should().Contain(c => c.ArtistName == "The Blacklist"); artist.Should().Contain(c => c.ArtistName == "Linkin Park");
} }
[Test] [Test]
[Ignore("Unreliable")] [Ignore("Unreliable")]
public void lookup_random_series_using_asterix() public void lookup_random_artist_using_asterix()
{ {
var artist = Artist.Lookup("*"); var artist = Artist.Lookup("*");

@ -11,7 +11,7 @@ namespace NzbDrone.Integration.Test.ApiTests
[Test, Order(0)] [Test, Order(0)]
public void missing_should_be_empty() public void missing_should_be_empty()
{ {
EnsureNoArtist("266189", "The Blacklist"); EnsureNoArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm");
var result = WantedMissing.GetPaged(0, 15, "releaseDate", "desc"); var result = WantedMissing.GetPaged(0, 15, "releaseDate", "desc");
@ -21,7 +21,7 @@ namespace NzbDrone.Integration.Test.ApiTests
[Test, Order(1)] [Test, Order(1)]
public void missing_should_have_monitored_items() public void missing_should_have_monitored_items()
{ {
EnsureArtist("266189", "The Blacklist", true); EnsureArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm", true);
var result = WantedMissing.GetPaged(0, 15, "releaseDate", "desc"); var result = WantedMissing.GetPaged(0, 15, "releaseDate", "desc");
@ -31,7 +31,7 @@ namespace NzbDrone.Integration.Test.ApiTests
[Test, Order(1)] [Test, Order(1)]
public void missing_should_have_artist() public void missing_should_have_artist()
{ {
EnsureArtist("266189", "The Blacklist", true); EnsureArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm", true);
var result = WantedMissing.GetPaged(0, 15, "releaseDate", "desc"); var result = WantedMissing.GetPaged(0, 15, "releaseDate", "desc");
@ -43,7 +43,7 @@ namespace NzbDrone.Integration.Test.ApiTests
public void cutoff_should_have_monitored_items() public void cutoff_should_have_monitored_items()
{ {
EnsureProfileCutoff(1, Quality.MP3_256); EnsureProfileCutoff(1, Quality.MP3_256);
var artist = EnsureArtist("266189", "The Blacklist", true); var artist = EnsureArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm", true);
EnsureTrackFile(artist, 1, 1, Quality.MP3_192); EnsureTrackFile(artist, 1, 1, Quality.MP3_192);
var result = WantedCutoffUnmet.GetPaged(0, 15, "releaseDate", "desc"); var result = WantedCutoffUnmet.GetPaged(0, 15, "releaseDate", "desc");
@ -54,7 +54,7 @@ namespace NzbDrone.Integration.Test.ApiTests
[Test, Order(1)] [Test, Order(1)]
public void missing_should_not_have_unmonitored_items() public void missing_should_not_have_unmonitored_items()
{ {
EnsureArtist("266189", "The Blacklist", false); EnsureArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm", false);
var result = WantedMissing.GetPaged(0, 15, "releaseDate", "desc"); var result = WantedMissing.GetPaged(0, 15, "releaseDate", "desc");
@ -65,7 +65,7 @@ namespace NzbDrone.Integration.Test.ApiTests
public void cutoff_should_not_have_unmonitored_items() public void cutoff_should_not_have_unmonitored_items()
{ {
EnsureProfileCutoff(1, Quality.MP3_256); EnsureProfileCutoff(1, Quality.MP3_256);
var artist = EnsureArtist("266189", "The Blacklist", false); var artist = EnsureArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm", false);
EnsureTrackFile(artist, 1, 1, Quality.MP3_192); EnsureTrackFile(artist, 1, 1, Quality.MP3_192);
var result = WantedCutoffUnmet.GetPaged(0, 15, "releaseDate", "desc"); var result = WantedCutoffUnmet.GetPaged(0, 15, "releaseDate", "desc");
@ -77,19 +77,19 @@ namespace NzbDrone.Integration.Test.ApiTests
public void cutoff_should_have_artist() public void cutoff_should_have_artist()
{ {
EnsureProfileCutoff(1, Quality.MP3_256); EnsureProfileCutoff(1, Quality.MP3_256);
var artist = EnsureArtist("266189", "The Blacklist", true); var artist = EnsureArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm", true);
EnsureTrackFile(artist, 1, 1, Quality.MP3_192); EnsureTrackFile(artist, 1, 1, Quality.MP3_192);
var result = WantedCutoffUnmet.GetPaged(0, 15, "releaseDate", "desc"); var result = WantedCutoffUnmet.GetPaged(0, 15, "releaseDate", "desc");
result.Records.First().Artist.Should().NotBeNull(); result.Records.First().Artist.Should().NotBeNull();
result.Records.First().Artist.ArtistName.Should().Be("The Blacklist"); result.Records.First().Artist.ArtistName.Should().Be("Alien Ant Farm");
} }
[Test, Order(2)] [Test, Order(2)]
public void missing_should_have_unmonitored_items() public void missing_should_have_unmonitored_items()
{ {
EnsureArtist("266189", "The Blacklist", false); EnsureArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm", false);
var result = WantedMissing.GetPaged(0, 15, "releaseDate", "desc", "monitored", "false"); var result = WantedMissing.GetPaged(0, 15, "releaseDate", "desc", "monitored", "false");
@ -100,7 +100,7 @@ namespace NzbDrone.Integration.Test.ApiTests
public void cutoff_should_have_unmonitored_items() public void cutoff_should_have_unmonitored_items()
{ {
EnsureProfileCutoff(1, Quality.MP3_256); EnsureProfileCutoff(1, Quality.MP3_256);
var artist = EnsureArtist("266189", "The Blacklist", false); var artist = EnsureArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm", false);
EnsureTrackFile(artist, 1, 1, Quality.MP3_192); EnsureTrackFile(artist, 1, 1, Quality.MP3_192);
var result = WantedCutoffUnmet.GetPaged(0, 15, "releaseDate", "desc", "monitored", "false"); var result = WantedCutoffUnmet.GetPaged(0, 15, "releaseDate", "desc", "monitored", "false");

@ -19,10 +19,10 @@ namespace NzbDrone.Integration.Test.Client
return Get<List<ArtistResource>>(request); return Get<List<ArtistResource>>(request);
} }
public List<ArtistResource> Editor(List<ArtistResource> series) public List<ArtistResource> Editor(ArtistEditorResource artist)
{ {
var request = BuildRequest("editor"); var request = BuildRequest("editor");
request.AddBody(series); request.AddBody(artist);
return Put<List<ArtistResource>>(request); return Put<List<ArtistResource>>(request);
} }

@ -20,6 +20,7 @@ using Lidarr.Api.V3.Profiles.Quality;
using Lidarr.Api.V3.RootFolders; using Lidarr.Api.V3.RootFolders;
using Lidarr.Api.V3.Artist; using Lidarr.Api.V3.Artist;
using Lidarr.Api.V3.Albums; using Lidarr.Api.V3.Albums;
using Lidarr.Api.V3.Tracks;
using Lidarr.Api.V3.Tags; using Lidarr.Api.V3.Tags;
using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Serializer; using NzbDrone.Common.Serializer;
@ -94,7 +95,7 @@ namespace NzbDrone.Integration.Test
protected virtual void InitRestClients() protected virtual void InitRestClients()
{ {
RestClient = new RestClient(RootUrl + "api/"); RestClient = new RestClient(RootUrl + "api/v3/");
RestClient.AddDefaultHeader("Authentication", ApiKey); RestClient.AddDefaultHeader("Authentication", ApiKey);
RestClient.AddDefaultHeader("X-Api-Key", ApiKey); RestClient.AddDefaultHeader("X-Api-Key", ApiKey);
@ -102,6 +103,7 @@ namespace NzbDrone.Integration.Test
Commands = new CommandClient(RestClient, ApiKey); Commands = new CommandClient(RestClient, ApiKey);
DownloadClients = new DownloadClientClient(RestClient, ApiKey); DownloadClients = new DownloadClientClient(RestClient, ApiKey);
Albums = new AlbumClient(RestClient, ApiKey); Albums = new AlbumClient(RestClient, ApiKey);
Tracks = new TrackClient(RestClient, ApiKey);
History = new ClientBase<HistoryResource>(RestClient, ApiKey); History = new ClientBase<HistoryResource>(RestClient, ApiKey);
HostConfig = new ClientBase<HostConfigResource>(RestClient, ApiKey, "config/host"); HostConfig = new ClientBase<HostConfigResource>(RestClient, ApiKey, "config/host");
Indexers = new IndexerClient(RestClient, ApiKey); Indexers = new IndexerClient(RestClient, ApiKey);

Loading…
Cancel
Save