mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 06:11:10 +00:00
Maps OpenLibrary MARC publish_country to ReleaseCountry
Adds publish_country to the Open Library edition response, translates MARC 21 country codes into the ReleaseCountry enumeration through a private table, and drops the city based publish_places mapping. Closes #222
This commit is contained in:
1 parent
3350f19c1d
commit
c6469e70cf
7 files changed
+365
-27
No files matched your search
+29
-3
@@ -160,7 +160,6 @@ public class OpenLibraryMapperTests
|
||||
authorNames: ["Search Author"],
|
||||
firstPublishYear: 2003,
|
||||
publishers: ["Search Publisher"],
|
||||
publishPlaces: ["London"],
|
||||
subjects: ["Science fiction", "Space"],
|
||||
isbns: ["978-0-306-40615-7"],
|
||||
numberOfPagesMedian: 250,
|
||||
@@ -205,7 +204,7 @@ public class OpenLibraryMapperTests
|
||||
title: "Edition Title",
|
||||
publishDate: "2010-05-01",
|
||||
publishers: ["Publisher Co"],
|
||||
publishPlaces: ["New York"],
|
||||
publishCountry: "nyu",
|
||||
numberOfPages: 320,
|
||||
physicalFormat: "Hardcover",
|
||||
editionName: "First Edition",
|
||||
@@ -243,7 +242,7 @@ public class OpenLibraryMapperTests
|
||||
Assert.Equal(1987, result.ReleaseInfo.OriginalReleaseYear);
|
||||
Assert.Equal(new DateOnly(2010, 5, 1), result.ReleaseInfo.ReReleaseDate);
|
||||
Assert.Equal(2010, result.ReleaseInfo.ReReleaseYear);
|
||||
Assert.Null(result.ReleaseInfo.ReleaseCountry);
|
||||
Assert.Equal(ReleaseCountry.US, result.ReleaseInfo.ReleaseCountry);
|
||||
Assert.Equal("First Edition", result.ReleaseInfo.ReleaseVersion);
|
||||
GenreDto genre = Assert.Single(result.Genres!);
|
||||
Assert.Equal("Fantasy", genre.Name);
|
||||
@@ -282,6 +281,33 @@ public class OpenLibraryMapperTests
|
||||
Assert.Equal(100, mappedRating.VoteCount);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("nyu", ReleaseCountry.US)] // A MARC 21 state code that stands for the United States.
|
||||
[InlineData("xxu", ReleaseCountry.US)] // The MARC 21 country code of the United States.
|
||||
[InlineData("enk", ReleaseCountry.GB)] // The MARC 21 country code of England.
|
||||
[InlineData("ENK", ReleaseCountry.GB)] // The code differs only in casing.
|
||||
[InlineData("gw ", ReleaseCountry.DE)] // A two letter MARC 21 code, padded with a trailing space.
|
||||
[InlineData("fr", ReleaseCountry.FR)] // A two letter MARC 21 code without padding.
|
||||
[InlineData("abc", ReleaseCountry.CA)] // A MARC 21 province code that stands for Canada.
|
||||
[InlineData("aca", ReleaseCountry.AU)] // A MARC 21 territory code that stands for Australia.
|
||||
[InlineData("uk", ReleaseCountry.GB)] // A discontinued MARC 21 code that still appears in catalogued records.
|
||||
[InlineData("cs", ReleaseCountry.CZ)] // A discontinued MARC 21 code, mapped to the country that succeeded it.
|
||||
[InlineData("vp", null)] // A MARC 21 code that stands for various places, with no equivalent release country.
|
||||
[InlineData("zzz", null)] // An unknown MARC 21 code.
|
||||
[InlineData("", null)] // An empty MARC 21 code.
|
||||
public void MapDetailed_WhenEditionHasPublishCountry_ShouldMapTheMarcCountryCode(string? publishCountry, ReleaseCountry? expected)
|
||||
{
|
||||
// Arrange
|
||||
BookMetadataLookupDto lookup = _bookMetadataLookupDtoFixture.Create();
|
||||
OpenLibraryEditionResponse edition = _openLibraryEditionResponseFixture.Create(publishCountry: publishCountry);
|
||||
|
||||
// Act
|
||||
BookMetadataDto result = OpenLibraryMapper.MapDetailed(lookup, edition, null, [], null);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(expected, result.ReleaseInfo!.ReleaseCountry);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MapDetailed_WhenWorkHasNoExplicitGenres_ShouldDeriveGenresFromTheGenreLikeSubjects()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user