Datasets:
Download src/test_europeana_contract.py from SlayerLab/polish-dynaword: direct link, hf CLI and curl.
- Browser
- Download file 1.34 kB
-
https://huggingface.co/datasets/SlayerLab/polish-dynaword/resolve/a9d134ac79a9fe586fc9c11cb39eb32d69dcd21f/src/test_europeana_contract.py
- Command line
-
hf download hf://datasets/SlayerLab/polish-dynaword@a9d134ac79a9fe586fc9c11cb39eb32d69dcd21f/src/test_europeana_contract.py
-
curl -L -o test_europeana_contract.py https://huggingface.co/datasets/SlayerLab/polish-dynaword/resolve/a9d134ac79a9fe586fc9c11cb39eb32d69dcd21f/src/test_europeana_contract.py
1.34 kB
| """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() | |