Fixed cutoff unmet integration tests

Closes #1692

(cherry picked from commit c1e5b7f642d03414f7c5587d4db377ef979f2067)
This commit is contained in:
Mark McDowall 2022-05-23 20:52:27 -07:00 committed by Qstick
parent de46816cdb
commit 388fb52644
3 changed files with 113 additions and 75 deletions

View file

@ -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);

View file

@ -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();
}
}
}

View file

@ -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);
}