125 lines
6.4 KiB
Python
125 lines
6.4 KiB
Python
"""Checks for published ECCV metadata and preserved submission histories."""
|
|
from hashlib import sha256
|
|
import json
|
|
from pathlib import Path
|
|
import sqlite3
|
|
import tempfile
|
|
import unittest
|
|
|
|
from paper_atlas.collectors.eccv2026_publications import BOOK_TITLE, SOURCE, collect
|
|
from paper_atlas.db.store import Store
|
|
from paper_atlas.ingestion.records import ingest_file
|
|
|
|
|
|
FIRST_BOOK = '10.1007/978-3-032-10000-0'
|
|
FIRST_DOI = FIRST_BOOK + '_1'
|
|
|
|
|
|
def snapshots(root):
|
|
toc, chapters = root / 'toc', root / 'chapters'
|
|
toc.mkdir()
|
|
chapters.mkdir()
|
|
receipts, volumes = [], {}
|
|
for offset in range(78):
|
|
volume = 17001 + offset
|
|
book = f'10.1007/978-3-032-{10000 + offset}-0'
|
|
book_url = 'https://link.springer.com/book/' + book
|
|
count = 37 if offset < 27 else 36
|
|
files, chapter_dois = {}, []
|
|
for page, indices in ((1, range(1, 20)), (2, range(20, count + 1))):
|
|
filename = f'{volume}-{page}.html'
|
|
html = f'<h1>{BOOK_TITLE}</h1><p>Malmö (LNCS, volume {volume})</p>'
|
|
html += '<li data-test="chapter"><h3>Front Matter</h3></li>'
|
|
for i in indices:
|
|
doi = f'{book}_{i}'
|
|
html += f'<li data-test="chapter"><h3><a href="/chapter/{doi}">Title {volume}-{i}</a></h3></li>'
|
|
chapter_dois.append(doi)
|
|
raw = html.encode()
|
|
(toc / filename).write_bytes(raw)
|
|
files[str(page)] = filename
|
|
receipts.append({'file': filename, 'status': 200, 'bytes': len(raw), 'sha256': sha256(raw).hexdigest(),
|
|
'url': book_url + ('?page=2' if page == 2 else '')})
|
|
volumes[str(volume)] = {'book': book_url, 'files': files, 'chapter_dois': chapter_dois}
|
|
data = ''.join(json.dumps(row) + '\n' for row in receipts).encode()
|
|
(toc / 'receipts.jsonl').write_bytes(data)
|
|
checkpoint = json.dumps(volumes).encode()
|
|
(toc / 'volume-checkpoint.json').write_bytes(checkpoint)
|
|
(toc / 'summary.json').write_text(json.dumps({
|
|
'raw_receipts_sha256': sha256(data).hexdigest(),
|
|
'volume_checkpoint_sha256': sha256(checkpoint).hexdigest(),
|
|
'chapter_link_count': 2835,
|
|
}))
|
|
url = 'https://link.springer.com/chapter/' + FIRST_DOI
|
|
citation = {
|
|
'citation_doi': FIRST_DOI, 'citation_title': 'Title 17001-1',
|
|
'citation_inbook_title': BOOK_TITLE, 'citation_publication_date': '2026',
|
|
'citation_firstpage': '1', 'citation_lastpage': '10',
|
|
'citation_author': 'Chen, Lei',
|
|
}
|
|
body = ''.join(f'<meta name="{k}" content="{v}">' for k, v in citation.items())
|
|
body += '<div id="Abs1-content"><p>Published abstract.</p></div>'
|
|
raw = body.encode()
|
|
(chapters / 'first.html').write_bytes(raw)
|
|
(chapters / 'receipts.json').write_text(json.dumps({'responses': [{
|
|
'url': url, 'final_url': url, 'file': 'first.html', 'at': '2026-11-18T00:00:00Z',
|
|
'http_status': 200, 'bytes': len(raw), 'sha256': sha256(raw).hexdigest(),
|
|
'headers': {'Content-Type': 'text/html'},
|
|
}]}))
|
|
return {'toc_snapshots': toc, 'chapter_snapshots': chapters}
|
|
|
|
|
|
class ECCV2026PublicationsTests(unittest.TestCase):
|
|
def test_frozen_snapshot_and_existing_history(self):
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
root = Path(tmp)
|
|
source = snapshots(root)
|
|
report = collect(root / 'out', **source)
|
|
self.assertEqual((report['toc_chapters'], report['chapter_details_missing']), (2835, 2834))
|
|
manifest, = report['files']
|
|
self.assertEqual((manifest['track'], manifest['status']), ('main', 'partial'))
|
|
row = json.loads(Path(manifest['file']).read_text())
|
|
self.assertEqual(row['identifiers'], {'doi': FIRST_DOI})
|
|
self.assertEqual(row['submission_identifiers'], [{'scheme': 'publication_doi', 'value': FIRST_DOI}])
|
|
self.assertEqual(row['authors'], [{'family': 'Chen', 'given': 'Lei'}])
|
|
self.assertEqual(row['abstract'], 'Published abstract.')
|
|
self.assertEqual(row['metadata']['lncs_volume'], 17001)
|
|
self.assertFalse(row['metadata']['original_decision_signature_verified'])
|
|
detail = row['metadata']['publisher_chapter_evidence']
|
|
self.assertEqual(sha256((root / 'out' / detail['file']).read_bytes()).hexdigest(), detail['sha256'])
|
|
db = root / 'example.sqlite'
|
|
store = Store(db)
|
|
pid, rid = store.record('prior', 'work', 'https://example.org/work',
|
|
row['title'], 'Original preprint abstract.', row['authors'],
|
|
{'arxiv': '2601.00001'})
|
|
store.decision(pid, rid, 'ICLR', 2026, 'main', 'work', 'https://example.org/decision',
|
|
'rejected', 'Original ICLR result.')
|
|
store.conn.commit()
|
|
store.conn.close()
|
|
row['identifiers']['arxiv'] = '2601.00001'
|
|
path = Path(manifest['file'])
|
|
raw = (json.dumps(row) + '\n').encode()
|
|
path.write_bytes(raw)
|
|
manifest['file_sha256'] = sha256(raw).hexdigest()
|
|
path.with_suffix('.manifest.json').write_text(json.dumps(manifest))
|
|
ingest_file(db, path)
|
|
ingest_file(db, path)
|
|
with sqlite3.connect(db) as conn:
|
|
self.assertEqual(conn.execute('SELECT id,abstract FROM papers').fetchall(),
|
|
[(pid, 'Original preprint abstract.')])
|
|
self.assertEqual(conn.execute('SELECT status FROM decisions ORDER BY id').fetchall(),
|
|
[('rejected',), ('accepted',)])
|
|
self.assertEqual(conn.execute('SELECT scheme,value FROM submission_identifiers').fetchall(),
|
|
[('publication_doi', FIRST_DOI)])
|
|
self.assertEqual(conn.execute('SELECT name FROM sources ORDER BY id').fetchall(), [('prior',), (SOURCE,)])
|
|
with self.assertRaises(FileExistsError):
|
|
collect(root / 'out', **source)
|
|
|
|
def test_changed_contents_receipt_stops_before_output(self):
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
root = Path(tmp)
|
|
source = snapshots(root)
|
|
(source['toc_snapshots'] / '17001-1.html').write_text('unverified bytes')
|
|
with self.assertRaisesRegex(ValueError, 'contents bytes disagree'):
|
|
collect(root / 'out', **source)
|
|
self.assertFalse((root / 'out').exists())
|