Random Fixes (#3549)
Co-authored-by: Robbie Davis <robbie@therobbiedavis.com>
This commit is contained in:
parent
ea81a2f432
commit
39726f8c4d
33 changed files with 425 additions and 107 deletions
|
@ -398,4 +398,153 @@ public class ScannerServiceTests : AbstractDbTest
|
|||
Assert.Equal(3, series.Volumes.Count);
|
||||
Assert.Equal(2, series.Volumes.First(v => v.MinNumber.Is(Parser.LooseLeafVolumeNumber)).Chapters.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ScanLibrary_LocalizedSeries_MatchesFilename()
|
||||
{
|
||||
const string testcase = "Localized Name matches Filename - Manga.json";
|
||||
|
||||
// Get the first file and generate a ComicInfo
|
||||
var infos = new Dictionary<string, ComicInfo>();
|
||||
infos.Add("Futoku no Guild v01.cbz", new ComicInfo()
|
||||
{
|
||||
Series = "Immoral Guild",
|
||||
LocalizedSeries = "Futoku no Guild"
|
||||
});
|
||||
|
||||
var library = await _scannerHelper.GenerateScannerData(testcase, infos);
|
||||
|
||||
|
||||
var scanner = _scannerHelper.CreateServices();
|
||||
await scanner.ScanLibrary(library.Id);
|
||||
var postLib = await _unitOfWork.LibraryRepository.GetLibraryForIdAsync(library.Id, LibraryIncludes.Series);
|
||||
|
||||
Assert.NotNull(postLib);
|
||||
Assert.Single(postLib.Series);
|
||||
var s = postLib.Series.First();
|
||||
Assert.Equal("Immoral Guild", s.Name);
|
||||
Assert.Equal("Futoku no Guild", s.LocalizedName);
|
||||
Assert.Single(s.Volumes);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ScanLibrary_LocalizedSeries_MatchesFilename_SameNames()
|
||||
{
|
||||
const string testcase = "Localized Name matches Filename - Manga.json";
|
||||
|
||||
// Get the first file and generate a ComicInfo
|
||||
var infos = new Dictionary<string, ComicInfo>();
|
||||
infos.Add("Futoku no Guild v01.cbz", new ComicInfo()
|
||||
{
|
||||
Series = "Futoku no Guild",
|
||||
LocalizedSeries = "Futoku no Guild"
|
||||
});
|
||||
|
||||
var library = await _scannerHelper.GenerateScannerData(testcase, infos);
|
||||
|
||||
|
||||
var scanner = _scannerHelper.CreateServices();
|
||||
await scanner.ScanLibrary(library.Id);
|
||||
var postLib = await _unitOfWork.LibraryRepository.GetLibraryForIdAsync(library.Id, LibraryIncludes.Series);
|
||||
|
||||
Assert.NotNull(postLib);
|
||||
Assert.Single(postLib.Series);
|
||||
var s = postLib.Series.First();
|
||||
Assert.Equal("Futoku no Guild", s.Name);
|
||||
Assert.Equal("Futoku no Guild", s.LocalizedName);
|
||||
Assert.Single(s.Volumes);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ScanLibrary_ExcludePattern_Works()
|
||||
{
|
||||
const string testcase = "Exclude Pattern 1 - Manga.json";
|
||||
|
||||
// Get the first file and generate a ComicInfo
|
||||
var infos = new Dictionary<string, ComicInfo>();
|
||||
var library = await _scannerHelper.GenerateScannerData(testcase, infos);
|
||||
|
||||
library.LibraryExcludePatterns = [new LibraryExcludePattern() {Pattern = "**/Extra/*"}];
|
||||
_unitOfWork.LibraryRepository.Update(library);
|
||||
await _unitOfWork.CommitAsync();
|
||||
|
||||
|
||||
var scanner = _scannerHelper.CreateServices();
|
||||
await scanner.ScanLibrary(library.Id);
|
||||
var postLib = await _unitOfWork.LibraryRepository.GetLibraryForIdAsync(library.Id, LibraryIncludes.Series);
|
||||
|
||||
Assert.NotNull(postLib);
|
||||
Assert.Single(postLib.Series);
|
||||
var s = postLib.Series.First();
|
||||
Assert.Equal(2, s.Volumes.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ScanLibrary_ExcludePattern_FlippedSlashes_Works()
|
||||
{
|
||||
const string testcase = "Exclude Pattern 1 - Manga.json";
|
||||
|
||||
// Get the first file and generate a ComicInfo
|
||||
var infos = new Dictionary<string, ComicInfo>();
|
||||
var library = await _scannerHelper.GenerateScannerData(testcase, infos);
|
||||
|
||||
library.LibraryExcludePatterns = [new LibraryExcludePattern() {Pattern = "**\\Extra\\*"}];
|
||||
_unitOfWork.LibraryRepository.Update(library);
|
||||
await _unitOfWork.CommitAsync();
|
||||
|
||||
|
||||
var scanner = _scannerHelper.CreateServices();
|
||||
await scanner.ScanLibrary(library.Id);
|
||||
var postLib = await _unitOfWork.LibraryRepository.GetLibraryForIdAsync(library.Id, LibraryIncludes.Series);
|
||||
|
||||
Assert.NotNull(postLib);
|
||||
Assert.Single(postLib.Series);
|
||||
var s = postLib.Series.First();
|
||||
Assert.Equal(2, s.Volumes.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ScanLibrary_MultipleRoots_MultipleScans_DataPersists()
|
||||
{
|
||||
const string testcase = "Multiple Roots - Manga.json";
|
||||
|
||||
// Get the first file and generate a ComicInfo
|
||||
var infos = new Dictionary<string, ComicInfo>();
|
||||
var library = await _scannerHelper.GenerateScannerData(testcase, infos);
|
||||
|
||||
var testDirectoryPath =
|
||||
Path.Join(
|
||||
Path.Join(Directory.GetCurrentDirectory(), "../../../Services/Test Data/ScannerService/ScanTests"),
|
||||
testcase.Replace(".json", string.Empty));
|
||||
library.Folders =
|
||||
[
|
||||
new FolderPath() {Path = Path.Join(testDirectoryPath, "Root 1")},
|
||||
new FolderPath() {Path = Path.Join(testDirectoryPath, "Root 2")}
|
||||
];
|
||||
|
||||
_unitOfWork.LibraryRepository.Update(library);
|
||||
await _unitOfWork.CommitAsync();
|
||||
|
||||
|
||||
var scanner = _scannerHelper.CreateServices();
|
||||
await scanner.ScanLibrary(library.Id);
|
||||
var postLib = await _unitOfWork.LibraryRepository.GetLibraryForIdAsync(library.Id, LibraryIncludes.Series);
|
||||
|
||||
Assert.NotNull(postLib);
|
||||
Assert.Equal(2, postLib.Series.Count);
|
||||
var s = postLib.Series.First(s => s.Name == "Plush");
|
||||
Assert.Equal(2, s.Volumes.Count);
|
||||
var s2 = postLib.Series.First(s => s.Name == "Accel");
|
||||
Assert.Single(s2.Volumes);
|
||||
|
||||
// Rescan to ensure nothing changes yet again
|
||||
await scanner.ScanLibrary(library.Id, true);
|
||||
|
||||
postLib = await _unitOfWork.LibraryRepository.GetLibraryForIdAsync(library.Id, LibraryIncludes.Series);
|
||||
Assert.Equal(2, postLib.Series.Count);
|
||||
s = postLib.Series.First(s => s.Name == "Plush");
|
||||
Assert.Equal(2, s.Volumes.Count);
|
||||
s2 = postLib.Series.First(s => s.Name == "Accel");
|
||||
Assert.Single(s2.Volumes);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
[
|
||||
"Antarctic Press/Plush/Plush v01.cbz",
|
||||
"Antarctic Press/Plush/Plush v02.cbz",
|
||||
"Antarctic Press/Plush/Extra/Plush v03.cbz"
|
||||
]
|
|
@ -0,0 +1,3 @@
|
|||
[
|
||||
"Immoral Guild/Futoku no Guild v01.cbz"
|
||||
]
|
|
@ -0,0 +1,5 @@
|
|||
[
|
||||
"Root 1/Antarctic Press/Plush/Plush v01.cbz",
|
||||
"Root 1/Antarctic Press/Plush/Plush v02.cbz",
|
||||
"Root 2/Accel/Accel v01.cbz"
|
||||
]
|
Loading…
Add table
Add a link
Reference in a new issue