New: Option to control which new author books get monitored

This commit is contained in:
ta264
2021-12-01 21:23:23 +00:00
parent 1d694af98e
commit c51ae664aa
42 changed files with 774 additions and 265 deletions
@@ -62,7 +62,7 @@ namespace NzbDrone.Core.Test.MusicTests
Mocker.GetMock<IMetadataProfileService>()
.Setup(s => s.FilterBooks(It.IsAny<Author>(), It.IsAny<int>()))
.Returns(_books);
.Returns(_remoteBooks);
Mocker.GetMock<IProvideAuthorInfo>()
.Setup(s => s.GetAuthorAndBooks(It.IsAny<string>(), It.IsAny<double>()))
@@ -83,6 +83,10 @@ namespace NzbDrone.Core.Test.MusicTests
Mocker.GetMock<IRootFolderService>()
.Setup(x => x.All())
.Returns(new List<RootFolder>());
Mocker.GetMock<IMonitorNewBookService>()
.Setup(x => x.ShouldMonitorNewBook(It.IsAny<Book>(), It.IsAny<List<Book>>(), It.IsAny<NewItemMonitorTypes>()))
.Returns(true);
}
private void GivenNewAuthorInfo(Author author)
@@ -151,6 +155,29 @@ namespace NzbDrone.Core.Test.MusicTests
VerifyEventPublished<AuthorRefreshCompleteEvent>();
}
[Test]
public void should_call_new_book_monitor_service_when_adding_book()
{
var newBook = Builder<Book>.CreateNew()
.With(x => x.Id = 0)
.With(x => x.ForeignBookId = "3")
.Build();
_remoteBooks.Add(newBook);
var newAuthorInfo = _author.JsonClone();
newAuthorInfo.Metadata = _author.Metadata.Value.JsonClone();
newAuthorInfo.Books = _remoteBooks;
GivenNewAuthorInfo(newAuthorInfo);
GivenBooksForRefresh(_books);
AllowAuthorUpdate();
Subject.Execute(new RefreshAuthorCommand(_author.Id));
Mocker.GetMock<IMonitorNewBookService>()
.Verify(x => x.ShouldMonitorNewBook(newBook, _books, _author.MonitorNewItems), Times.Once());
}
[Test]
public void should_log_error_and_delete_if_musicbrainz_id_not_found_and_author_has_no_files()
{