Preserve confirmed single-name Springer authors
Metadata integrity checks / metadata (push) Successful in 8m28s

This commit is contained in:
2026-11-18 20:30:11 +08:00
parent 48f8304517
commit 4d97822d9e
3 changed files with 55 additions and 2 deletions
+23 -1
View File
@@ -9,7 +9,7 @@ import tempfile
import unittest
from paper_atlas.collectors.springer_selected import (
BOOK, SOURCE, collect, parse_chapter, parse_toc, read_page, snapshot_index,
BOOK, SCOPE, SOURCE, collect, parse_chapter, parse_toc, read_page, snapshot_index,
)
from paper_atlas.db.store import Store
from paper_atlas.ingestion.records import ingest_file
@@ -153,6 +153,28 @@ class SpringerSelectedTests(unittest.TestCase):
html = self.fixture['chapters']['chapter-01.html'].replace('id="Abs1-content"','id="not-an-abstract"')
self.assertIsNone(parse_chapter(html, BOOK+'_1')['abstract'])
def test_single_name_preserves_literal_and_requires_ordered_display_confirmation(self):
html = f"""
<meta name="citation_doi" content="{BOOK}_1">
<meta name="citation_inbook_title" content="{SCOPE['book_title']}">
<meta name="citation_publication_date" content="{SCOPE['publication_year']}">
<meta name="citation_title" content="Example">
<meta name="citation_author" content="Rajkumar">
<meta name="citation_author" content="Doe, Jane">
<meta name="citation_firstpage" content="1">
<meta name="citation_lastpage" content="5">
"""
article = {'@type':'ScholarlyArticle', 'author':[{'name':'Rajkumar'}, {'name':'Jane Doe'}]}
script = '<script type="application/ld+json">{}</script>'
chapter = parse_chapter(html+script.format(json.dumps(article)), BOOK+'_1')
self.assertEqual(chapter['authors'], ['Rajkumar', {'family':'Doe', 'given':'Jane'}])
self.assertEqual(chapter['authors_citation_raw'], ['Rajkumar','Doe, Jane'])
with self.assertRaisesRegex(ValueError, 'matching Springer display author list'):
parse_chapter(html, BOOK+'_1')
article['author'].reverse()
with self.assertRaisesRegex(ValueError, 'matching Springer display author list'):
parse_chapter(html+script.format(json.dumps(article)), BOOK+'_1')
def test_toc_ignores_frontmatter_but_rejects_duplicate_publications(self):
html = self.fixture['toc']['springer-toc1.html']
self.assertEqual(len(parse_toc(html)), 17)