Datasets:
File size: 1,342 Bytes
264ccc9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | """TDD contract for the direct Europeana ingestion path."""
import sys
import unittest
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent))
from fetch_europeana import normalize_europeana_row
class EuropeanaContractTest(unittest.TestCase):
def test_open_record_keeps_rights_and_canonical_schema(self):
item = {
"id": "/123/item-1", "rights": ["https://creativecommons.org/licenses/by/4.0/"],
"dcDescription": ["Polski opis wystarczająco długi do testu." * 10],
"dcCreator": ["Autor Testowy"], "year": ["1912"], "title": ["Tytuł"],
}
row = normalize_europeana_row(item, item)
self.assertEqual(set(row), {"id", "text", "source_url", "title", "license", "rights_url", "author", "created", "provider", "raw_metadata"})
self.assertEqual(row["license"], "CC-BY-4.0")
self.assertEqual(row["author"], "Autor Testowy")
self.assertEqual(row["created"], "1912")
self.assertTrue(row["rights_url"].startswith("https://creativecommons.org/licenses/by/"))
def test_restricted_rights_are_not_normalized(self):
item = {"id": "/x", "rights": ["https://creativecommons.org/licenses/by-nc/4.0/"]}
self.assertIsNone(normalize_europeana_row(item, item))
if __name__ == "__main__":
unittest.main()
|