mirror of
https://github.com/Readarr/Readarr
synced 2026-02-12 09:42:04 +01:00
Fixed: Ensure AudioTag years have default values (#1272)
* Fixed: Ensure AudioTagService years have default values * Fix AudioTagServiceFixture.cs tests Co-authored-by: Sean Anderson <sean.anderson@gaiaresources.com.au>
This commit is contained in:
parent
d14a64caf9
commit
27259c1ebd
2 changed files with 24 additions and 9 deletions
|
|
@ -17,14 +17,13 @@
|
|||
namespace NzbDrone.Core.Test.MediaFiles.AudioTagServiceFixture
|
||||
{
|
||||
[TestFixture]
|
||||
[Ignore("Readarr doesn't currently support audio")]
|
||||
public class AudioTagServiceFixture : CoreTest<AudioTagService>
|
||||
{
|
||||
public static class TestCaseFactory
|
||||
{
|
||||
private static readonly string[] MediaFiles = new[] { "nin.mp2", "nin.mp3", "nin.flac", "nin.m4a", "nin.wma", "nin.ape", "nin.opus" };
|
||||
|
||||
private static readonly string[] SkipProperties = new[] { "IsValid", "Duration", "Quality", "MediaInfo", "ImageFile" };
|
||||
private static readonly string[] SkipProperties = new[] { "IsValid", "Duration", "Quality", "MediaInfo", "ImageFile", "BookAuthors" };
|
||||
private static readonly Dictionary<string, string[]> SkipPropertiesByFile = new Dictionary<string, string[]>
|
||||
{
|
||||
{ "nin.mp2", new[] { "OriginalReleaseDate" } }
|
||||
|
|
@ -194,6 +193,9 @@ public void should_read_write_tags(string filename, string[] skipProperties)
|
|||
var writtentags = Subject.ReadAudioTag(path);
|
||||
|
||||
VerifySame(writtentags, _testTags, skipProperties);
|
||||
writtentags.BookAuthors.Should().BeEquivalentTo(
|
||||
_testTags.BookAuthors.Concat(_testTags.Performers),
|
||||
options => options.WithStrictOrdering());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -337,12 +339,12 @@ public void get_metadata_should_not_fail_with_missing_country()
|
|||
[Test]
|
||||
public void should_not_fail_if_media_has_been_omitted()
|
||||
{
|
||||
// make sure that we aren't relying on index of items in
|
||||
// Media being the same as the medium number
|
||||
var file = GivenPopulatedTrackfile(100);
|
||||
var tag = Subject.GetTrackMetadata(file);
|
||||
GivenFileCopy("nin.mp3");
|
||||
|
||||
tag.Media.Should().NotBeNull();
|
||||
var file = GivenPopulatedTrackfile(100);
|
||||
file.Path = _copiedFile;
|
||||
|
||||
Assert.DoesNotThrow(() => Subject.GetTrackMetadata(file));
|
||||
}
|
||||
|
||||
[TestCase("nin.mp3")]
|
||||
|
|
@ -363,5 +365,18 @@ public void write_tags_should_update_trackfile_size_and_modified(string filename
|
|||
file.Modified.Should().Be(fileInfo.LastWriteTimeUtc);
|
||||
file.Size.Should().Be(fileInfo.Length);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_fail_reading_metadata_with_dates_omitted()
|
||||
{
|
||||
GivenFileCopy("nin.mp3");
|
||||
|
||||
var bookFile = GivenPopulatedTrackfile(0);
|
||||
bookFile.Path = _copiedFile;
|
||||
bookFile.Edition.Value.ReleaseDate = null;
|
||||
bookFile.Edition.Value.Book.Value.ReleaseDate = null;
|
||||
|
||||
Assert.DoesNotThrow(() => Subject.GetTrackMetadata(bookFile));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,9 +108,9 @@ public AudioTag GetTrackMetadata(BookFile trackfile)
|
|||
// We may have omitted media so index in the list isn't the same as medium number
|
||||
Media = fileTags.Media,
|
||||
Date = edition.ReleaseDate,
|
||||
Year = (uint)edition.ReleaseDate?.Year,
|
||||
Year = (uint)(edition.ReleaseDate?.Year ?? 0),
|
||||
OriginalReleaseDate = book.ReleaseDate,
|
||||
OriginalYear = (uint)book.ReleaseDate?.Year,
|
||||
OriginalYear = (uint)(book.ReleaseDate?.Year ?? 0),
|
||||
Publisher = edition.Publisher,
|
||||
Genres = new string[0],
|
||||
ImageFile = imageFile,
|
||||
|
|
|
|||
Loading…
Reference in a new issue