import gzip import json from pathlib import Path import tempfile import unittest from paper_atlas.collectors import corl2026 as c class CoRL2026Test(unittest.TestCase): @classmethod def setUpClass(cls): cls.bundle = json.loads(gzip.decompress((Path(__file__).parent/'fixtures/corl2026-source.json.gz').read_bytes())) def test_official_census_and_presentation_dedup(self): program = c.parse_program(self.bundle['official_html']) self.assertEqual(len(program), 687) self.assertEqual(sum(len(p['presentations']) for p in program.values()), 780) self.assertEqual(sum(len(p['presentations']) == 2 for p in program.values()), 93) def test_conflicting_official_title_is_not_silently_folded(self): html = self.bundle['official_html'] title = 'Diagnosing Compositional Generalization in Sequential Robot Tasks' self.assertIn(title, html) with self.assertRaises(ValueError): c.parse_program(html.replace(title, 'Different paper', 1)) def test_foreign_forum_source_is_rejected(self): program = c.parse_program(self.bundle['official_html']); archive = json.loads(self.bundle['filtered']) archive['papers'][0]['author_source'] = 'https://openreview.net/forum?id=WrongPaper' with self.assertRaisesRegex(ValueError, 'another submission'): c.join_metadata(program, archive) def test_unknown_profile_fields_are_rejected(self): program = c.parse_program(self.bundle['official_html']); archive = json.loads(self.bundle['filtered']) archive['papers'][0]['authorids'] = ['profile'] with self.assertRaisesRegex(ValueError, 'profile'): c.join_metadata(program, archive) def test_source_sets_must_agree(self): program = c.parse_program(self.bundle['official_html']); archive = json.loads(self.bundle['filtered']) archive['papers'].pop() with self.assertRaisesRegex(ValueError, 'forum sets'): c.join_metadata(program, archive) def test_complete_snapshot_and_explicit_version_provenance(self): with tempfile.TemporaryDirectory() as tmp: root = Path(tmp); official = root/'official'; archive = root/'archive' official.mkdir(); archive.mkdir() (official/'accepted.html').write_text(self.bundle['official_html']) (official/'research.json').write_text(json.dumps(self.bundle['research'])) (archive/'explorer-paper-metadata-filtered-v1.json').write_text(self.bundle['filtered']) out = root/'out'; report = c.collect(out, official_snapshots=official, archive_snapshots=archive) self.assertEqual(report['records'], 687); self.assertEqual(len(report['title_variants']), 34) self.assertEqual(report['public_rejected_availability'], 'unknown') rows = [json.loads(l) for l in (out/'corl-program-archive-2026-main.jsonl').read_text().splitlines()] self.assertEqual(len({r['external_id'] for r in rows}), 687) self.assertTrue(all(set(r['identifiers']) == {'openreview'} for r in rows)) self.assertTrue(all(r['submission_identifiers'] == [{'scheme': 'openreview', 'value': r['identifiers']['openreview']}] for r in rows)) self.assertTrue(all(not r['tags'] and not r['metadata']['original_decision_signature_verified'] for r in rows)) self.assertTrue(all(r['title'] == r['metadata']['archive_fields']['title'] for r in rows)) self.assertTrue(all(r['authors'] and r['abstract'] for r in rows)) self.assertFalse(report['database_written']); self.assertFalse(report['pdfs_downloaded']) with self.assertRaisesRegex(ValueError, 'Output exists'): c.collect(out, official_snapshots=official, archive_snapshots=archive) (official/'accepted.html').write_text('tampered') with self.assertRaisesRegex(ValueError, 'hash changed'): c.collect(root/'failed', official_snapshots=official, archive_snapshots=archive) self.assertTrue((root/'failed/failed.json').exists()) self.assertFalse((root/'failed/collection-report.json').exists()) def test_forum_identity_validation(self): for bad in ['https://openreview.net/challenge?redirect=forum', 'https://evil.test/forum?id=abcdefgh', 'https://openreview.net/forum?id=abcdefgh&other=1']: with self.assertRaises(ValueError): c.forum_id(bad)