diff --git a/src/NzbDrone.Integration.Test/ApiTests/WantedFixture.cs b/src/NzbDrone.Integration.Test/ApiTests/WantedTests/CutoffUnmetFixture.cs similarity index 53% rename from src/NzbDrone.Integration.Test/ApiTests/WantedFixture.cs rename to src/NzbDrone.Integration.Test/ApiTests/WantedTests/CutoffUnmetFixture.cs index 3b98cb06e..0d1047fd3 100644 --- a/src/NzbDrone.Integration.Test/ApiTests/WantedFixture.cs +++ b/src/NzbDrone.Integration.Test/ApiTests/WantedTests/CutoffUnmetFixture.cs @@ -5,10 +5,10 @@ using NzbDrone.Core.Qualities; using Readarr.Api.V1.RootFolders; -namespace NzbDrone.Integration.Test.ApiTests +namespace NzbDrone.Integration.Test.ApiTests.WantedTests { [TestFixture] - public class WantedFixture : IntegrationTest + public class CutoffUnmetFixture : IntegrationTest { [SetUp] public void Setup() @@ -24,56 +24,11 @@ public void Setup() }); } - [Test] - [Order(0)] - public void missing_should_be_empty() - { - EnsureNoAuthor("14586394", "Andrew Hunter Murray"); - - var result = WantedMissing.GetPaged(0, 15, "releaseDate", "desc"); - - result.Records.Should().BeEmpty(); - } - - [Test] - [Order(1)] - public void missing_should_have_monitored_items() - { - EnsureAuthor("14586394", "43765115", "Andrew Hunter Murray", true); - - var result = WantedMissing.GetPaged(0, 15, "releaseDate", "desc"); - - result.Records.Should().NotBeEmpty(); - } - - [Test] - [Order(1)] - public void missing_should_have_author() - { - EnsureAuthor("14586394", "43765115", "Andrew Hunter Murray", true); - - var result = WantedMissing.GetPagedIncludeAuthor(0, 15, "releaseDate", "desc", includeAuthor: true); - - result.Records.First().Author.Should().NotBeNull(); - result.Records.First().Author.AuthorName.Should().Be("Andrew Hunter Murray"); - } - - [Test] - [Order(1)] - public void missing_should_not_have_author() - { - EnsureAuthor("14586394", "43765115", "Andrew Hunter Murray", true); - - var result = WantedMissing.GetPagedIncludeAuthor(0, 15, "releaseDate", "desc", includeAuthor: false); - - result.Records.First().Author.Should().BeNull(); - } - [Test] [Order(2)] public void cutoff_should_have_monitored_items() { - EnsureProfileCutoff(1, Quality.AZW3); + EnsureProfileCutoff(1, Quality.AZW3, true); var author = EnsureAuthor("14586394", "43765115", "Andrew Hunter Murray", true); EnsureBookFile(author, 1, "43765115", Quality.MOBI); @@ -82,22 +37,11 @@ public void cutoff_should_have_monitored_items() result.Records.Should().NotBeEmpty(); } - [Test] - [Order(1)] - public void missing_should_not_have_unmonitored_items() - { - EnsureAuthor("14586394", "43765115", "Andrew Hunter Murray", false); - - var result = WantedMissing.GetPaged(0, 15, "releaseDate", "desc"); - - result.Records.Should().BeEmpty(); - } - [Test] [Order(2)] public void cutoff_should_not_have_unmonitored_items() { - EnsureProfileCutoff(1, Quality.AZW3); + EnsureProfileCutoff(1, Quality.AZW3, true); var author = EnsureAuthor("14586394", "43765115", "Andrew Hunter Murray", false); EnsureBookFile(author, 1, "43765115", Quality.MOBI); @@ -110,7 +54,7 @@ public void cutoff_should_not_have_unmonitored_items() [Order(2)] public void cutoff_should_have_author() { - EnsureProfileCutoff(1, Quality.AZW3); + EnsureProfileCutoff(1, Quality.AZW3, true); var author = EnsureAuthor("14586394", "43765115", "Andrew Hunter Murray", true); EnsureBookFile(author, 1, "43765115", Quality.MOBI); @@ -124,7 +68,7 @@ public void cutoff_should_have_author() [Order(2)] public void cutoff_should_not_have_author() { - EnsureProfileCutoff(1, Quality.AZW3); + EnsureProfileCutoff(1, Quality.AZW3, true); var author = EnsureAuthor("14586394", "43765115", "Andrew Hunter Murray", true); EnsureBookFile(author, 1, "43765115", Quality.MOBI); @@ -133,22 +77,11 @@ public void cutoff_should_not_have_author() result.Records.First().Author.Should().BeNull(); } - [Test] - [Order(1)] - public void missing_should_have_unmonitored_items() - { - EnsureAuthor("14586394", "43765115", "Andrew Hunter Murray", false); - - var result = WantedMissing.GetPaged(0, 15, "releaseDate", "desc", "monitored", "false"); - - result.Records.Should().NotBeEmpty(); - } - [Test] [Order(2)] public void cutoff_should_have_unmonitored_items() { - EnsureProfileCutoff(1, Quality.AZW3); + EnsureProfileCutoff(1, Quality.AZW3, true); var author = EnsureAuthor("14586394", "43765115", "Andrew Hunter Murray", false); EnsureBookFile(author, 1, "43765115", Quality.MOBI); diff --git a/src/NzbDrone.Integration.Test/ApiTests/WantedTests/MissingFixture.cs b/src/NzbDrone.Integration.Test/ApiTests/WantedTests/MissingFixture.cs new file mode 100644 index 000000000..dc52fba21 --- /dev/null +++ b/src/NzbDrone.Integration.Test/ApiTests/WantedTests/MissingFixture.cs @@ -0,0 +1,93 @@ +using System.Linq; +using FluentAssertions; +using NUnit.Framework; +using NzbDrone.Core.Books; +using Readarr.Api.V1.RootFolders; + +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 = AuthorRootFolder, + DefaultMetadataProfileId = 1, + DefaultQualityProfileId = 1, + DefaultMonitorOption = MonitorTypes.All + }); + } + + [Test] + [Order(0)] + public void missing_should_be_empty() + { + EnsureNoAuthor("14586394", "Andrew Hunter Murray"); + + var result = WantedMissing.GetPaged(0, 15, "releaseDate", "desc"); + + result.Records.Should().BeEmpty(); + } + + [Test] + [Order(1)] + public void missing_should_have_monitored_items() + { + EnsureAuthor("14586394", "43765115", "Andrew Hunter Murray", true); + + var result = WantedMissing.GetPaged(0, 15, "releaseDate", "desc"); + + result.Records.Should().NotBeEmpty(); + } + + [Test] + [Order(1)] + public void missing_should_have_author() + { + EnsureAuthor("14586394", "43765115", "Andrew Hunter Murray", true); + + var result = WantedMissing.GetPagedIncludeAuthor(0, 15, "releaseDate", "desc", includeAuthor: true); + + result.Records.First().Author.Should().NotBeNull(); + result.Records.First().Author.AuthorName.Should().Be("Andrew Hunter Murray"); + } + + [Test] + [Order(1)] + public void missing_should_not_have_author() + { + EnsureAuthor("14586394", "43765115", "Andrew Hunter Murray", true); + + var result = WantedMissing.GetPagedIncludeAuthor(0, 15, "releaseDate", "desc", includeAuthor: false); + + result.Records.First().Author.Should().BeNull(); + } + + [Test] + [Order(1)] + public void missing_should_not_have_unmonitored_items() + { + EnsureAuthor("14586394", "43765115", "Andrew Hunter Murray", false); + + var result = WantedMissing.GetPaged(0, 15, "releaseDate", "desc"); + + result.Records.Should().BeEmpty(); + } + + [Test] + [Order(2)] + public void missing_should_have_unmonitored_items() + { + EnsureAuthor("14586394", "43765115", "Andrew Hunter Murray", false); + + var result = WantedMissing.GetPaged(0, 15, "releaseDate", "desc", "monitored", "false"); + + result.Records.Should().NotBeEmpty(); + } + } +} diff --git a/src/NzbDrone.Integration.Test/IntegrationTestBase.cs b/src/NzbDrone.Integration.Test/IntegrationTestBase.cs index 84b5d567f..7f1ec642a 100644 --- a/src/NzbDrone.Integration.Test/IntegrationTestBase.cs +++ b/src/NzbDrone.Integration.Test/IntegrationTestBase.cs @@ -328,13 +328,25 @@ public void EnsureBookFile(AuthorResource author, int bookId, string foreignEdit } } - public QualityProfileResource EnsureProfileCutoff(int profileId, Quality cutoff) + public QualityProfileResource EnsureProfileCutoff(int profileId, Quality cutoff, bool upgradeAllowed) { + var needsUpdate = false; var profile = Profiles.Get(profileId); if (profile.Cutoff != cutoff.Id) { profile.Cutoff = cutoff.Id; + needsUpdate = true; + } + + if (profile.UpgradeAllowed != upgradeAllowed) + { + profile.UpgradeAllowed = upgradeAllowed; + needsUpdate = true; + } + + if (needsUpdate) + { profile = Profiles.Put(profile); }