mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-25 22:36:59 -04:00
New: Use Goodreads directly, allow multiple editions of a book (new DB required)
This commit is contained in:
@@ -315,8 +315,12 @@ namespace NzbDrone.Core.Test.MediaFiles.AudioTagServiceFixture
|
||||
.With(x => x.Author = artist)
|
||||
.Build();
|
||||
|
||||
var file = Builder<BookFile>.CreateNew()
|
||||
var edition = Builder<Edition>.CreateNew()
|
||||
.With(x => x.Book = album)
|
||||
.Build();
|
||||
|
||||
var file = Builder<BookFile>.CreateNew()
|
||||
.With(x => x.Edition = edition)
|
||||
.With(x => x.Author = artist)
|
||||
.Build();
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles.Qualities;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.RootFolders;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
@@ -43,6 +44,14 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||
.With(e => e.Author = artist)
|
||||
.Build();
|
||||
|
||||
var edition = Builder<Edition>.CreateNew()
|
||||
.With(e => e.Book = album)
|
||||
.Build();
|
||||
|
||||
var rootFolder = Builder<RootFolder>.CreateNew()
|
||||
.With(r => r.IsCalibreLibrary = false)
|
||||
.Build();
|
||||
|
||||
_rejectedDecisions.Add(new ImportDecision<LocalBook>(new LocalBook(), new Rejection("Rejected!")));
|
||||
_rejectedDecisions.Add(new ImportDecision<LocalBook>(new LocalBook(), new Rejection("Rejected!")));
|
||||
_rejectedDecisions.Add(new ImportDecision<LocalBook>(new LocalBook(), new Rejection("Rejected!")));
|
||||
@@ -52,6 +61,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||
{
|
||||
Author = artist,
|
||||
Book = album,
|
||||
Edition = edition,
|
||||
Path = Path.Combine(artist.Path, "Alien Ant Farm - 01 - Pilot.mp3"),
|
||||
Quality = new QualityModel(Quality.MP3_320),
|
||||
FileTrackInfo = new ParsedTrackInfo
|
||||
@@ -69,6 +79,10 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||
Mocker.GetMock<IMediaFileService>()
|
||||
.Setup(s => s.GetFilesByBook(It.IsAny<int>()))
|
||||
.Returns(new List<BookFile>());
|
||||
|
||||
Mocker.GetMock<IRootFolderService>()
|
||||
.Setup(s => s.GetBestRootFolder(It.IsAny<string>()))
|
||||
.Returns(rootFolder);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -152,6 +166,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||
{
|
||||
Author = fileDecision.Item.Author,
|
||||
Book = fileDecision.Item.Book,
|
||||
Edition = fileDecision.Item.Edition,
|
||||
Path = @"C:\Test\Music\Alien Ant Farm\Alien Ant Farm - 01 - Pilot.mp3".AsOsAgnostic(),
|
||||
Quality = new QualityModel(Quality.MP3_320),
|
||||
Size = 80.Megabytes()
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||
{
|
||||
private Author _artist;
|
||||
private Book _album;
|
||||
private Edition _edition;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
@@ -37,12 +38,20 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||
.Build();
|
||||
Db.Insert(_album);
|
||||
|
||||
_edition = Builder<Edition>.CreateNew()
|
||||
.With(a => a.Id = 0)
|
||||
.With(a => a.BookId = _album.Id)
|
||||
.Build();
|
||||
Db.Insert(_edition);
|
||||
|
||||
var files = Builder<BookFile>.CreateListOfSize(10)
|
||||
.All()
|
||||
.With(c => c.Id = 0)
|
||||
.With(c => c.Quality = new QualityModel(Quality.MP3_320))
|
||||
.TheFirst(5)
|
||||
.With(c => c.BookId = _album.Id)
|
||||
.With(c => c.EditionId = _edition.Id)
|
||||
.TheRest()
|
||||
.With(c => c.EditionId = 0)
|
||||
.TheFirst(1)
|
||||
.With(c => c.Path = @"C:\Test\Path\Artist\somefile1.flac".AsOsAgnostic())
|
||||
.TheNext(1)
|
||||
@@ -109,8 +118,8 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||
var file = Subject.GetFileWithPath(@"C:\Test\Path\Artist\somefile2.flac".AsOsAgnostic());
|
||||
|
||||
file.Should().NotBeNull();
|
||||
file.Book.IsLoaded.Should().BeTrue();
|
||||
file.Book.Value.Should().NotBeNull();
|
||||
file.Edition.IsLoaded.Should().BeTrue();
|
||||
file.Edition.Value.Should().NotBeNull();
|
||||
file.Author.IsLoaded.Should().BeTrue();
|
||||
file.Author.Value.Should().NotBeNull();
|
||||
}
|
||||
@@ -122,7 +131,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||
var files = Subject.GetFilesByBook(_album.Id);
|
||||
VerifyEagerLoaded(files);
|
||||
|
||||
files.Should().OnlyContain(c => c.BookId == _album.Id);
|
||||
files.Should().OnlyContain(c => c.EditionId == _album.Id);
|
||||
}
|
||||
|
||||
private void VerifyData()
|
||||
@@ -136,8 +145,8 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||
{
|
||||
foreach (var file in files)
|
||||
{
|
||||
file.Book.IsLoaded.Should().BeTrue();
|
||||
file.Book.Value.Should().NotBeNull();
|
||||
file.Edition.IsLoaded.Should().BeTrue();
|
||||
file.Edition.Value.Should().NotBeNull();
|
||||
file.Author.IsLoaded.Should().BeTrue();
|
||||
file.Author.Value.Should().NotBeNull();
|
||||
file.Author.Value.Metadata.IsLoaded.Should().BeTrue();
|
||||
@@ -149,8 +158,8 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||
{
|
||||
foreach (var file in files)
|
||||
{
|
||||
file.Book.IsLoaded.Should().BeFalse();
|
||||
file.Book.Value.Should().BeNull();
|
||||
file.Edition.IsLoaded.Should().BeFalse();
|
||||
file.Edition.Value.Should().BeNull();
|
||||
file.Author.IsLoaded.Should().BeFalse();
|
||||
file.Author.Value.Should().BeNull();
|
||||
}
|
||||
@@ -162,7 +171,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||
Db.Delete(_album);
|
||||
Subject.DeleteFilesByBook(_album.Id);
|
||||
|
||||
Db.All<BookFile>().Where(x => x.BookId == _album.Id).Should().HaveCount(0);
|
||||
Db.All<BookFile>().Where(x => x.EditionId == _album.Id).Should().HaveCount(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaFileServiceTests
|
||||
Path = "C:\\file2.avi".AsOsAgnostic(),
|
||||
Size = 10,
|
||||
Modified = _lastWrite,
|
||||
Book = new LazyLoaded<Book>(null)
|
||||
Edition = new LazyLoaded<Edition>(null)
|
||||
}
|
||||
});
|
||||
|
||||
@@ -239,7 +239,7 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaFileServiceTests
|
||||
Path = "C:\\file2.avi".AsOsAgnostic(),
|
||||
Size = 10,
|
||||
Modified = _lastWrite,
|
||||
Book = Builder<Book>.CreateNew().Build()
|
||||
Edition = Builder<Edition>.CreateNew().Build()
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -24,9 +24,9 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackFileMovingServiceTests
|
||||
|
||||
_trackFiles = Builder<BookFile>.CreateListOfSize(3)
|
||||
.TheFirst(2)
|
||||
.With(f => f.BookId = _album.Id)
|
||||
.With(f => f.EditionId = _album.Id)
|
||||
.TheNext(1)
|
||||
.With(f => f.BookId = 0)
|
||||
.With(f => f.EditionId = 0)
|
||||
.Build().ToList();
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -43,15 +43,15 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackFileMovingServiceTests
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<IBuildFileNames>()
|
||||
.Setup(s => s.BuildBookFileName(It.IsAny<Author>(), It.IsAny<Book>(), It.IsAny<BookFile>(), null, null))
|
||||
.Setup(s => s.BuildBookFileName(It.IsAny<Author>(), It.IsAny<Edition>(), It.IsAny<BookFile>(), null, null))
|
||||
.Returns("File Name");
|
||||
|
||||
Mocker.GetMock<IBuildFileNames>()
|
||||
.Setup(s => s.BuildBookFilePath(It.IsAny<Author>(), It.IsAny<Book>(), It.IsAny<string>(), It.IsAny<string>()))
|
||||
.Setup(s => s.BuildBookFilePath(It.IsAny<Author>(), It.IsAny<Edition>(), It.IsAny<string>(), It.IsAny<string>()))
|
||||
.Returns(@"C:\Test\Music\Artist\Album\File Name.mp3".AsOsAgnostic());
|
||||
|
||||
Mocker.GetMock<IBuildFileNames>()
|
||||
.Setup(s => s.BuildBookPath(It.IsAny<Author>(), It.IsAny<Book>()))
|
||||
.Setup(s => s.BuildBookPath(It.IsAny<Author>()))
|
||||
.Returns(@"C:\Test\Music\Artist\Album".AsOsAgnostic());
|
||||
|
||||
var rootFolder = @"C:\Test\Music\".AsOsAgnostic();
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@ namespace NzbDrone.Core.Test.MediaFiles.BookImport.Aggregation.Aggregators
|
||||
[TestFixture]
|
||||
public class AggregateFilenameInfoFixture : CoreTest<AggregateFilenameInfo>
|
||||
{
|
||||
private LocalAlbumRelease GivenTracks(List<string> files, string root)
|
||||
private LocalEdition GivenTracks(List<string> files, string root)
|
||||
{
|
||||
var tracks = files.Select(x => new LocalBook
|
||||
{
|
||||
@@ -25,7 +25,7 @@ namespace NzbDrone.Core.Test.MediaFiles.BookImport.Aggregation.Aggregators
|
||||
TrackNumbers = new[] { 0 },
|
||||
}
|
||||
}).ToList();
|
||||
return new LocalAlbumRelease(tracks);
|
||||
return new LocalEdition(tracks);
|
||||
}
|
||||
|
||||
private void VerifyData(LocalBook track, string artist, string title, int trackNum, int disc)
|
||||
|
||||
+7
-7
@@ -19,7 +19,7 @@ using NzbDrone.Core.MediaFiles.BookImport.Aggregation.Aggregators;
|
||||
using NzbDrone.Core.MediaFiles.BookImport.Identification;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
using NzbDrone.Core.MetadataSource;
|
||||
using NzbDrone.Core.MetadataSource.SkyHook;
|
||||
using NzbDrone.Core.MetadataSource.Goodreads;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles.Metadata;
|
||||
@@ -32,7 +32,7 @@ namespace NzbDrone.Core.Test.MediaFiles.BookImport.Identification
|
||||
public class IdentificationServiceFixture : DbTest
|
||||
{
|
||||
private AuthorService _authorService;
|
||||
private AddArtistService _addAuthorService;
|
||||
private AddAuthorService _addAuthorService;
|
||||
private RefreshAuthorService _refreshArtistService;
|
||||
|
||||
private IdentificationService _Subject;
|
||||
@@ -59,10 +59,10 @@ namespace NzbDrone.Core.Test.MediaFiles.BookImport.Identification
|
||||
Mocker.SetConstant<IMediaFileService>(Mocker.Resolve<MediaFileService>());
|
||||
|
||||
Mocker.SetConstant<IConfigService>(Mocker.Resolve<IConfigService>());
|
||||
Mocker.SetConstant<IProvideAuthorInfo>(Mocker.Resolve<SkyHookProxy>());
|
||||
Mocker.SetConstant<IProvideBookInfo>(Mocker.Resolve<SkyHookProxy>());
|
||||
Mocker.SetConstant<IProvideAuthorInfo>(Mocker.Resolve<GoodreadsProxy>());
|
||||
Mocker.SetConstant<IProvideBookInfo>(Mocker.Resolve<GoodreadsProxy>());
|
||||
|
||||
_addAuthorService = Mocker.Resolve<AddArtistService>();
|
||||
_addAuthorService = Mocker.Resolve<AddAuthorService>();
|
||||
|
||||
Mocker.SetConstant<IRefreshBookService>(Mocker.Resolve<RefreshBookService>());
|
||||
_refreshArtistService = Mocker.Resolve<RefreshAuthorService>();
|
||||
@@ -73,11 +73,11 @@ namespace NzbDrone.Core.Test.MediaFiles.BookImport.Identification
|
||||
Mocker.SetConstant<ICandidateService>(Mocker.Resolve<CandidateService>());
|
||||
|
||||
// set up the augmenters
|
||||
List<IAggregate<LocalAlbumRelease>> aggregators = new List<IAggregate<LocalAlbumRelease>>
|
||||
List<IAggregate<LocalEdition>> aggregators = new List<IAggregate<LocalEdition>>
|
||||
{
|
||||
Mocker.Resolve<AggregateFilenameInfo>()
|
||||
};
|
||||
Mocker.SetConstant<IEnumerable<IAggregate<LocalAlbumRelease>>>(aggregators);
|
||||
Mocker.SetConstant<IEnumerable<IAggregate<LocalEdition>>>(aggregators);
|
||||
Mocker.SetConstant<IAugmentingService>(Mocker.Resolve<AugmentingService>());
|
||||
|
||||
_Subject = Mocker.Resolve<IdentificationService>();
|
||||
|
||||
@@ -1,192 +0,0 @@
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.MediaFiles.BookImport.Identification;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.MediaFiles.BookImport.Identification
|
||||
{
|
||||
[TestFixture]
|
||||
public class MunkresFixture : TestBase
|
||||
{
|
||||
// 2d arrays don't play nicely with attributes
|
||||
public void RunTest(double[,] costMatrix, double expectedCost)
|
||||
{
|
||||
var m = new Munkres(costMatrix);
|
||||
m.Run();
|
||||
m.Cost.Should().Be(expectedCost);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MunkresSquareTest1()
|
||||
{
|
||||
var c = new double[,]
|
||||
{
|
||||
{ 1, 2, 3 },
|
||||
{ 2, 4, 6 },
|
||||
{ 3, 6, 9 }
|
||||
};
|
||||
|
||||
RunTest(c, 10);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MunkresSquareTest2()
|
||||
{
|
||||
var c = new double[,]
|
||||
{
|
||||
{ 400, 150, 400 },
|
||||
{ 400, 450, 600 },
|
||||
{ 300, 225, 300 }
|
||||
};
|
||||
|
||||
RunTest(c, 850);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MunkresSquareTest3()
|
||||
{
|
||||
var c = new double[,]
|
||||
{
|
||||
{ 10, 10, 8 },
|
||||
{ 9, 8, 1 },
|
||||
{ 9, 7, 4 }
|
||||
};
|
||||
|
||||
RunTest(c, 18);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MunkresSquareTest4()
|
||||
{
|
||||
var c = new double[,]
|
||||
{
|
||||
{ 5, 9, 1 },
|
||||
{ 10, 3, 2 },
|
||||
{ 8, 7, 4 }
|
||||
};
|
||||
|
||||
RunTest(c, 12);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MunkresSquareTest5()
|
||||
{
|
||||
var c = new double[,]
|
||||
{
|
||||
{ 12, 26, 17, 0, 0 },
|
||||
{ 49, 43, 36, 10, 5 },
|
||||
{ 97, 9, 66, 34, 0 },
|
||||
{ 52, 42, 19, 36, 0 },
|
||||
{ 15, 93, 55, 80, 0 }
|
||||
};
|
||||
|
||||
RunTest(c, 48);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Munkres5x5Test()
|
||||
{
|
||||
var c = new double[,]
|
||||
{
|
||||
{ 12, 9, 27, 10, 23 },
|
||||
{ 7, 13, 13, 30, 19 },
|
||||
{ 25, 18, 26, 11, 26 },
|
||||
{ 9, 28, 26, 23, 13 },
|
||||
{ 16, 16, 24, 6, 9 }
|
||||
};
|
||||
|
||||
RunTest(c, 51);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Munkres10x10Test()
|
||||
{
|
||||
var c = new double[,]
|
||||
{
|
||||
{ 37, 34, 29, 26, 19, 8, 9, 23, 19, 29 },
|
||||
{ 9, 28, 20, 8, 18, 20, 14, 33, 23, 14 },
|
||||
{ 15, 26, 12, 28, 6, 17, 9, 13, 21, 7 },
|
||||
{ 2, 8, 38, 36, 39, 5, 36, 2, 38, 27 },
|
||||
{ 30, 3, 33, 16, 21, 39, 7, 23, 28, 36 },
|
||||
{ 7, 5, 19, 22, 36, 36, 24, 19, 30, 2 },
|
||||
{ 34, 20, 13, 36, 12, 33, 9, 10, 23, 5 },
|
||||
{ 7, 37, 22, 39, 33, 39, 10, 3, 13, 26 },
|
||||
{ 21, 25, 23, 39, 31, 37, 32, 33, 38, 1 },
|
||||
{ 17, 34, 40, 10, 29, 37, 40, 3, 25, 3 }
|
||||
};
|
||||
|
||||
RunTest(c, 66);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Munkres20x20Test()
|
||||
{
|
||||
var c = new double[,]
|
||||
{
|
||||
{ 5, 4, 3, 9, 8, 9, 3, 5, 6, 9, 4, 10, 3, 5, 6, 6, 1, 8, 10, 2 },
|
||||
{ 10, 9, 9, 2, 8, 3, 9, 9, 10, 1, 7, 10, 8, 4, 2, 1, 4, 8, 4, 8 },
|
||||
{ 10, 4, 4, 3, 1, 3, 5, 10, 6, 8, 6, 8, 4, 10, 7, 2, 4, 5, 1, 8 },
|
||||
{ 2, 1, 4, 2, 3, 9, 3, 4, 7, 3, 4, 1, 3, 2, 9, 8, 6, 5, 7, 8 },
|
||||
{ 3, 4, 4, 1, 4, 10, 1, 2, 6, 4, 5, 10, 2, 2, 3, 9, 10, 9, 9, 10 },
|
||||
{ 1, 10, 1, 8, 1, 3, 1, 7, 1, 1, 2, 1, 2, 6, 3, 3, 4, 4, 8, 6 },
|
||||
{ 1, 8, 7, 10, 10, 3, 4, 6, 1, 6, 6, 4, 9, 6, 9, 6, 4, 5, 4, 7 },
|
||||
{ 8, 10, 3, 9, 4, 9, 3, 3, 4, 6, 4, 2, 6, 7, 7, 4, 4, 3, 4, 7 },
|
||||
{ 1, 3, 8, 2, 6, 9, 2, 7, 4, 8, 10, 8, 10, 5, 1, 3, 10, 10, 2, 9 },
|
||||
{ 2, 4, 1, 9, 2, 9, 7, 8, 2, 1, 4, 10, 5, 2, 7, 6, 5, 7, 2, 6 },
|
||||
{ 4, 5, 1, 4, 2, 3, 3, 4, 1, 8, 8, 2, 6, 9, 5, 9, 6, 3, 9, 3 },
|
||||
{ 3, 1, 1, 8, 6, 8, 8, 7, 9, 3, 2, 1, 8, 2, 4, 7, 3, 1, 2, 4 },
|
||||
{ 5, 9, 8, 6, 10, 4, 10, 3, 4, 10, 10, 10, 1, 7, 8, 8, 7, 7, 8, 8 },
|
||||
{ 1, 4, 6, 1, 6, 1, 2, 10, 5, 10, 2, 6, 2, 4, 5, 5, 3, 5, 1, 5 },
|
||||
{ 5, 6, 9, 10, 6, 6, 10, 6, 4, 1, 5, 3, 9, 5, 2, 10, 9, 9, 5, 1 },
|
||||
{ 10, 9, 4, 6, 9, 5, 3, 7, 10, 1, 6, 8, 1, 1, 10, 9, 5, 7, 7, 5 },
|
||||
{ 2, 6, 6, 6, 6, 2, 9, 4, 7, 5, 3, 2, 10, 3, 4, 5, 10, 9, 1, 7 },
|
||||
{ 5, 2, 4, 9, 8, 4, 8, 2, 4, 1, 3, 7, 6, 8, 1, 6, 8, 8, 10, 10 },
|
||||
{ 9, 6, 3, 1, 8, 5, 7, 8, 7, 2, 1, 8, 2, 8, 3, 7, 4, 8, 7, 7 },
|
||||
{ 8, 4, 4, 9, 7, 10, 6, 2, 1, 5, 8, 5, 1, 1, 1, 9, 1, 3, 5, 3 }
|
||||
};
|
||||
|
||||
RunTest(c, 22);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MunkresRectangularTest1()
|
||||
{
|
||||
var c = new double[,]
|
||||
{
|
||||
{ 400, 150, 400, 1 },
|
||||
{ 400, 450, 600, 2 },
|
||||
{ 300, 225, 300, 3 }
|
||||
};
|
||||
|
||||
RunTest(c, 452);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MunkresRectangularTest2()
|
||||
{
|
||||
var c = new double[,]
|
||||
{
|
||||
{ 10, 10, 8, 11 },
|
||||
{ 9, 8, 1, 1 },
|
||||
{ 9, 7, 4, 10 }
|
||||
};
|
||||
|
||||
RunTest(c, 15);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MunkresRectangularTest3()
|
||||
{
|
||||
var c = new double[,]
|
||||
{
|
||||
{ 34, 26, 17, 12 },
|
||||
{ 43, 43, 36, 10 },
|
||||
{ 97, 47, 66, 34 },
|
||||
{ 52, 42, 19, 36 },
|
||||
{ 15, 93, 55, 80 }
|
||||
};
|
||||
|
||||
RunTest(c, 70);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,18 +28,19 @@ namespace NzbDrone.Core.Test.MediaFiles.BookImport
|
||||
private LocalBook _localTrack;
|
||||
private Author _artist;
|
||||
private Book _album;
|
||||
private Edition _edition;
|
||||
private QualityModel _quality;
|
||||
|
||||
private IdentificationOverrides _idOverrides;
|
||||
private ImportDecisionMakerConfig _idConfig;
|
||||
|
||||
private Mock<IImportDecisionEngineSpecification<LocalAlbumRelease>> _albumpass1;
|
||||
private Mock<IImportDecisionEngineSpecification<LocalAlbumRelease>> _albumpass2;
|
||||
private Mock<IImportDecisionEngineSpecification<LocalAlbumRelease>> _albumpass3;
|
||||
private Mock<IImportDecisionEngineSpecification<LocalEdition>> _albumpass1;
|
||||
private Mock<IImportDecisionEngineSpecification<LocalEdition>> _albumpass2;
|
||||
private Mock<IImportDecisionEngineSpecification<LocalEdition>> _albumpass3;
|
||||
|
||||
private Mock<IImportDecisionEngineSpecification<LocalAlbumRelease>> _albumfail1;
|
||||
private Mock<IImportDecisionEngineSpecification<LocalAlbumRelease>> _albumfail2;
|
||||
private Mock<IImportDecisionEngineSpecification<LocalAlbumRelease>> _albumfail3;
|
||||
private Mock<IImportDecisionEngineSpecification<LocalEdition>> _albumfail1;
|
||||
private Mock<IImportDecisionEngineSpecification<LocalEdition>> _albumfail2;
|
||||
private Mock<IImportDecisionEngineSpecification<LocalEdition>> _albumfail3;
|
||||
|
||||
private Mock<IImportDecisionEngineSpecification<LocalBook>> _pass1;
|
||||
private Mock<IImportDecisionEngineSpecification<LocalBook>> _pass2;
|
||||
@@ -52,13 +53,13 @@ namespace NzbDrone.Core.Test.MediaFiles.BookImport
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_albumpass1 = new Mock<IImportDecisionEngineSpecification<LocalAlbumRelease>>();
|
||||
_albumpass2 = new Mock<IImportDecisionEngineSpecification<LocalAlbumRelease>>();
|
||||
_albumpass3 = new Mock<IImportDecisionEngineSpecification<LocalAlbumRelease>>();
|
||||
_albumpass1 = new Mock<IImportDecisionEngineSpecification<LocalEdition>>();
|
||||
_albumpass2 = new Mock<IImportDecisionEngineSpecification<LocalEdition>>();
|
||||
_albumpass3 = new Mock<IImportDecisionEngineSpecification<LocalEdition>>();
|
||||
|
||||
_albumfail1 = new Mock<IImportDecisionEngineSpecification<LocalAlbumRelease>>();
|
||||
_albumfail2 = new Mock<IImportDecisionEngineSpecification<LocalAlbumRelease>>();
|
||||
_albumfail3 = new Mock<IImportDecisionEngineSpecification<LocalAlbumRelease>>();
|
||||
_albumfail1 = new Mock<IImportDecisionEngineSpecification<LocalEdition>>();
|
||||
_albumfail2 = new Mock<IImportDecisionEngineSpecification<LocalEdition>>();
|
||||
_albumfail3 = new Mock<IImportDecisionEngineSpecification<LocalEdition>>();
|
||||
|
||||
_pass1 = new Mock<IImportDecisionEngineSpecification<LocalBook>>();
|
||||
_pass2 = new Mock<IImportDecisionEngineSpecification<LocalBook>>();
|
||||
@@ -68,13 +69,13 @@ namespace NzbDrone.Core.Test.MediaFiles.BookImport
|
||||
_fail2 = new Mock<IImportDecisionEngineSpecification<LocalBook>>();
|
||||
_fail3 = new Mock<IImportDecisionEngineSpecification<LocalBook>>();
|
||||
|
||||
_albumpass1.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>(), It.IsAny<DownloadClientItem>())).Returns(Decision.Accept());
|
||||
_albumpass2.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>(), It.IsAny<DownloadClientItem>())).Returns(Decision.Accept());
|
||||
_albumpass3.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>(), It.IsAny<DownloadClientItem>())).Returns(Decision.Accept());
|
||||
_albumpass1.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalEdition>(), It.IsAny<DownloadClientItem>())).Returns(Decision.Accept());
|
||||
_albumpass2.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalEdition>(), It.IsAny<DownloadClientItem>())).Returns(Decision.Accept());
|
||||
_albumpass3.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalEdition>(), It.IsAny<DownloadClientItem>())).Returns(Decision.Accept());
|
||||
|
||||
_albumfail1.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>(), It.IsAny<DownloadClientItem>())).Returns(Decision.Reject("_albumfail1"));
|
||||
_albumfail2.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>(), It.IsAny<DownloadClientItem>())).Returns(Decision.Reject("_albumfail2"));
|
||||
_albumfail3.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>(), It.IsAny<DownloadClientItem>())).Returns(Decision.Reject("_albumfail3"));
|
||||
_albumfail1.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalEdition>(), It.IsAny<DownloadClientItem>())).Returns(Decision.Reject("_albumfail1"));
|
||||
_albumfail2.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalEdition>(), It.IsAny<DownloadClientItem>())).Returns(Decision.Reject("_albumfail2"));
|
||||
_albumfail3.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalEdition>(), It.IsAny<DownloadClientItem>())).Returns(Decision.Reject("_albumfail3"));
|
||||
|
||||
_pass1.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalBook>(), It.IsAny<DownloadClientItem>())).Returns(Decision.Accept());
|
||||
_pass2.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalBook>(), It.IsAny<DownloadClientItem>())).Returns(Decision.Accept());
|
||||
@@ -93,6 +94,10 @@ namespace NzbDrone.Core.Test.MediaFiles.BookImport
|
||||
.With(x => x.Author = _artist)
|
||||
.Build();
|
||||
|
||||
_edition = Builder<Edition>.CreateNew()
|
||||
.With(x => x.Book = _album)
|
||||
.Build();
|
||||
|
||||
_quality = new QualityModel(Quality.MP3_320);
|
||||
|
||||
_localTrack = new LocalBook
|
||||
@@ -116,9 +121,9 @@ namespace NzbDrone.Core.Test.MediaFiles.BookImport
|
||||
.Setup(s => s.Identify(It.IsAny<List<LocalBook>>(), It.IsAny<IdentificationOverrides>(), It.IsAny<ImportDecisionMakerConfig>()))
|
||||
.Returns((List<LocalBook> tracks, IdentificationOverrides idOverrides, ImportDecisionMakerConfig config) =>
|
||||
{
|
||||
var ret = new LocalAlbumRelease(tracks);
|
||||
ret.Book = _album;
|
||||
return new List<LocalAlbumRelease> { ret };
|
||||
var ret = new LocalEdition(tracks);
|
||||
ret.Edition = _edition;
|
||||
return new List<LocalEdition> { ret };
|
||||
});
|
||||
|
||||
Mocker.GetMock<IMediaFileService>()
|
||||
@@ -164,12 +169,12 @@ namespace NzbDrone.Core.Test.MediaFiles.BookImport
|
||||
|
||||
Subject.GetImportDecisions(_fileInfos, null, itemInfo, _idConfig);
|
||||
|
||||
_albumfail1.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>(), It.IsAny<DownloadClientItem>()), Times.Once());
|
||||
_albumfail2.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>(), It.IsAny<DownloadClientItem>()), Times.Once());
|
||||
_albumfail3.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>(), It.IsAny<DownloadClientItem>()), Times.Once());
|
||||
_albumpass1.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>(), It.IsAny<DownloadClientItem>()), Times.Once());
|
||||
_albumpass2.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>(), It.IsAny<DownloadClientItem>()), Times.Once());
|
||||
_albumpass3.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>(), It.IsAny<DownloadClientItem>()), Times.Once());
|
||||
_albumfail1.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalEdition>(), It.IsAny<DownloadClientItem>()), Times.Once());
|
||||
_albumfail2.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalEdition>(), It.IsAny<DownloadClientItem>()), Times.Once());
|
||||
_albumfail3.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalEdition>(), It.IsAny<DownloadClientItem>()), Times.Once());
|
||||
_albumpass1.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalEdition>(), It.IsAny<DownloadClientItem>()), Times.Once());
|
||||
_albumpass2.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalEdition>(), It.IsAny<DownloadClientItem>()), Times.Once());
|
||||
_albumpass3.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalEdition>(), It.IsAny<DownloadClientItem>()), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -317,7 +322,7 @@ namespace NzbDrone.Core.Test.MediaFiles.BookImport
|
||||
.Setup(s => s.Identify(It.IsAny<List<LocalBook>>(), It.IsAny<IdentificationOverrides>(), It.IsAny<ImportDecisionMakerConfig>()))
|
||||
.Returns((List<LocalBook> tracks, IdentificationOverrides idOverrides, ImportDecisionMakerConfig config) =>
|
||||
{
|
||||
return new List<LocalAlbumRelease> { new LocalAlbumRelease(tracks) };
|
||||
return new List<LocalEdition> { new LocalEdition(tracks) };
|
||||
});
|
||||
|
||||
var decisions = Subject.GetImportDecisions(_fileInfos, _idOverrides, null, _idConfig);
|
||||
|
||||
Reference in New Issue
Block a user