Fixed cutoff unmet integration tests

Closes #2822

(cherry picked from commit c1e5b7f642d03414f7c5587d4db377ef979f2067)
pull/3313/head
Mark McDowall 2 years ago committed by Qstick
parent 418cb78f29
commit 79973594c2

@ -5,10 +5,10 @@ using NUnit.Framework;
using NzbDrone.Core.Music; using NzbDrone.Core.Music;
using NzbDrone.Core.Qualities; using NzbDrone.Core.Qualities;
namespace NzbDrone.Integration.Test.ApiTests namespace NzbDrone.Integration.Test.ApiTests.WantedTests
{ {
[TestFixture] [TestFixture]
public class WantedFixture : IntegrationTest public class CutoffUnmetFixture : IntegrationTest
{ {
[SetUp] [SetUp]
public void Setup() public void Setup()
@ -24,45 +24,11 @@ namespace NzbDrone.Integration.Test.ApiTests
}); });
} }
[Test]
[Order(0)]
public void missing_should_be_empty()
{
EnsureNoArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm");
var result = WantedMissing.GetPaged(0, 15, "releaseDate", "desc");
result.Records.Should().BeEmpty();
}
[Test]
[Order(1)]
public void missing_should_have_monitored_items()
{
EnsureArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm", true);
var result = WantedMissing.GetPaged(0, 15, "releaseDate", "desc");
result.Records.Should().NotBeEmpty();
}
[Test]
[Order(1)]
public void missing_should_have_artist()
{
EnsureArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm", true);
var result = WantedMissing.GetPaged(0, 15, "releaseDate", "desc");
result.Records.First().Artist.Should().NotBeNull();
result.Records.First().Artist.ArtistName.Should().Be("Alien Ant Farm");
}
[Test] [Test]
[Order(1)] [Order(1)]
public void cutoff_should_have_monitored_items() public void cutoff_should_have_monitored_items()
{ {
EnsureProfileCutoff(1, "Lossless"); EnsureProfileCutoff(1, "Lossless", true);
var artist = EnsureArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm", true); var artist = EnsureArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm", true);
EnsureTrackFile(artist, 1, 1, 1, Quality.MP3_192); EnsureTrackFile(artist, 1, 1, 1, Quality.MP3_192);
@ -71,22 +37,11 @@ namespace NzbDrone.Integration.Test.ApiTests
result.Records.Should().NotBeEmpty(); result.Records.Should().NotBeEmpty();
} }
[Test]
[Order(1)]
public void missing_should_not_have_unmonitored_items()
{
EnsureArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm", false);
var result = WantedMissing.GetPaged(0, 15, "releaseDate", "desc");
result.Records.Should().BeEmpty();
}
[Test] [Test]
[Order(1)] [Order(1)]
public void cutoff_should_not_have_unmonitored_items() public void cutoff_should_not_have_unmonitored_items()
{ {
EnsureProfileCutoff(1, "Lossless"); EnsureProfileCutoff(1, "Lossless", true);
var artist = EnsureArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm", false); var artist = EnsureArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm", false);
EnsureTrackFile(artist, 1, 1, 1, Quality.MP3_192); EnsureTrackFile(artist, 1, 1, 1, Quality.MP3_192);
@ -99,7 +54,7 @@ namespace NzbDrone.Integration.Test.ApiTests
[Order(1)] [Order(1)]
public void cutoff_should_have_artist() public void cutoff_should_have_artist()
{ {
EnsureProfileCutoff(1, "Lossless"); EnsureProfileCutoff(1, "Lossless", true);
var artist = EnsureArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm", true); var artist = EnsureArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm", true);
EnsureTrackFile(artist, 1, 1, 1, Quality.MP3_192); EnsureTrackFile(artist, 1, 1, 1, Quality.MP3_192);
@ -109,22 +64,11 @@ namespace NzbDrone.Integration.Test.ApiTests
result.Records.First().Artist.ArtistName.Should().Be("Alien Ant Farm"); result.Records.First().Artist.ArtistName.Should().Be("Alien Ant Farm");
} }
[Test]
[Order(2)]
public void missing_should_have_unmonitored_items()
{
EnsureArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm", false);
var result = WantedMissing.GetPaged(0, 15, "releaseDate", "desc", "monitored", "false");
result.Records.Should().NotBeEmpty();
}
[Test] [Test]
[Order(2)] [Order(2)]
public void cutoff_should_have_unmonitored_items() public void cutoff_should_have_unmonitored_items()
{ {
EnsureProfileCutoff(1, "Lossless"); EnsureProfileCutoff(1, "Lossless", true);
var artist = EnsureArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm", false); var artist = EnsureArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm", false);
EnsureTrackFile(artist, 1, 1, 1, Quality.MP3_192); EnsureTrackFile(artist, 1, 1, 1, Quality.MP3_192);

@ -0,0 +1,84 @@
using System.Linq;
using FluentAssertions;
using Lidarr.Api.V1.RootFolders;
using NUnit.Framework;
using NzbDrone.Core.Music;
using NzbDrone.Core.Qualities;
namespace NzbDrone.Integration.Test.ApiTests.WantedTests
{
[TestFixture]
public class MissingFixture : IntegrationTest
{
[SetUp]
public void Setup()
{
// Add a root folder
RootFolders.Post(new RootFolderResource
{
Name = "TestLibrary",
Path = ArtistRootFolder,
DefaultMetadataProfileId = 1,
DefaultQualityProfileId = 1,
DefaultMonitorOption = MonitorTypes.All
});
}
[Test]
[Order(0)]
public void missing_should_be_empty()
{
EnsureNoArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm");
var result = WantedMissing.GetPaged(0, 15, "releaseDate", "desc");
result.Records.Should().BeEmpty();
}
[Test]
[Order(1)]
public void missing_should_have_monitored_items()
{
EnsureArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm", true);
var result = WantedMissing.GetPaged(0, 15, "releaseDate", "desc");
result.Records.Should().NotBeEmpty();
}
[Test]
[Order(1)]
public void missing_should_have_artist()
{
EnsureArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm", true);
var result = WantedMissing.GetPaged(0, 15, "releaseDate", "desc");
result.Records.First().Artist.Should().NotBeNull();
result.Records.First().Artist.ArtistName.Should().Be("Alien Ant Farm");
}
[Test]
[Order(1)]
public void missing_should_not_have_unmonitored_items()
{
EnsureArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm", false);
var result = WantedMissing.GetPaged(0, 15, "releaseDate", "desc");
result.Records.Should().BeEmpty();
}
[Test]
[Order(2)]
public void missing_should_have_unmonitored_items()
{
EnsureArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm", false);
var result = WantedMissing.GetPaged(0, 15, "releaseDate", "desc", "monitored", "false");
result.Records.Should().NotBeEmpty();
}
}
}

@ -331,14 +331,26 @@ namespace NzbDrone.Integration.Test
} }
} }
public QualityProfileResource EnsureProfileCutoff(int profileId, string cutoff) public QualityProfileResource EnsureProfileCutoff(int profileId, string cutoff, bool upgradeAllowed)
{ {
var needsUpdate = false;
var profile = Profiles.Get(profileId); var profile = Profiles.Get(profileId);
var cutoffItem = profile.Items.First(x => x.Name == cutoff); var cutoffItem = profile.Items.First(x => x.Name == cutoff);
if (profile.Cutoff != cutoffItem.Id) if (profile.Cutoff != cutoffItem.Id)
{ {
profile.Cutoff = cutoffItem.Id; profile.Cutoff = cutoffItem.Id;
needsUpdate = true;
}
if (profile.UpgradeAllowed != upgradeAllowed)
{
profile.UpgradeAllowed = upgradeAllowed;
needsUpdate = true;
}
if (needsUpdate)
{
profile = Profiles.Put(profile); profile = Profiles.Put(profile);
} }

Loading…
Cancel
Save