Skip to content

Commit 69f58be

Browse files
videos: use creation date for missing date digitized records
1 parent cb043f2 commit 69f58be

2 files changed

Lines changed: 18 additions & 9 deletions

File tree

cds_migrator_kit/videos/weblecture_migration/transform/transform.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,14 +342,14 @@ def reformat_date(json_data):
342342
json_data["_curation"]["legacy_dates"] = legacy_dates
343343
dates_set = [sorted(dates_set)[0]]
344344

345-
# TODO: update after migrator fix
345+
# TODO: remove this part after digitized lecturemedia migration
346346
if not dates_set:
347-
dates_set = [json_data.get("lecture_created")]
347+
dates_set = [json_data["creation_date"]]
348348
self.migration_logger.add_information(
349349
json_data.get("recid"),
350350
state={
351351
"message": "Lecture created date used!",
352-
"value": json_data.get("lecture_created"),
352+
"value": json_data["creation_date"],
353353
},
354354
)
355355

@@ -749,6 +749,8 @@ def transform(self, entry):
749749

750750
# Generate media files before metadata, it'll set if record has multiple masters
751751
media_files = self._media_files(json_data)
752+
creation_date = self._created(record_dump)
753+
json_data["creation_date"] = creation_date.date().isoformat()
752754
record_json_output = {
753755
"metadata": self._metadata(json_data),
754756
"created": self._created(record_dump),

tests/cds-videos/test_videos_transform_rules.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from os.path import dirname, join
1313
from pathlib import Path
1414

15+
import arrow
1516
import pytest
1617
import yaml
1718

@@ -142,6 +143,7 @@ def test_transform_date(dumpdir, base_app):
142143
record_marcxml, "518", {"d": "2025-02-06"}
143144
)
144145
res = load_and_dump_revision(modified_data)
146+
dump = CDSRecordDump(data=modified_data, dojson_model=videos_migrator_marc21)
145147

146148
# Transform record
147149
record_entry = CDSToVideosRecordEntry()
@@ -159,8 +161,9 @@ def test_transform_date(dumpdir, base_app):
159161
res = load_and_dump_revision(modified_data)
160162

161163
# Transform record
162-
with pytest.raises(MissingRequiredField):
163-
record_entry._metadata(res)
164+
# TODO: revert this change after digitized lecturemedia migration
165+
# with pytest.raises(MissingRequiredField):
166+
# record_entry._metadata(res)
164167

165168

166169
def test_transform_contributor(dumpdir, base_app):
@@ -212,6 +215,7 @@ def test_transform_digitized(dumpdir, base_app):
212215
# Get digitized record and apply rules
213216
entry_data = data[1]
214217
res = load_and_dump_revision(entry_data)
218+
dump = CDSRecordDump(data=entry_data, dojson_model=videos_migrator_marc21)
215219

216220
digitized = [
217221
item["digitized"] for item in res["url_files"] if "digitized" in item
@@ -228,8 +232,9 @@ def test_transform_digitized(dumpdir, base_app):
228232

229233
# Transform record it should fail (no valid date, it has date range)
230234
record_entry = CDSToVideosRecordEntry()
231-
with pytest.raises(MissingRequiredField):
232-
record_entry._metadata(res)
235+
# TODO: revert this change after digitized lecturemedia migration
236+
# with pytest.raises(MissingRequiredField):
237+
# record_entry._metadata(res)
233238

234239

235240
def test_transform_files(dumpdir, base_app):
@@ -286,6 +291,7 @@ def test_transform_note(dumpdir, base_app):
286291
# Get record and apply rules
287292
entry_data = data[1]
288293
res = load_and_dump_revision(entry_data)
294+
dump = CDSRecordDump(data=entry_data, dojson_model=videos_migrator_marc21)
289295

290296
# Record has one internal note
291297
assert "notes" in res
@@ -295,8 +301,9 @@ def test_transform_note(dumpdir, base_app):
295301

296302
# Transform record it should fail (no valid date, it has date range)
297303
record_entry = CDSToVideosRecordEntry()
298-
with pytest.raises(MissingRequiredField):
299-
record_entry._metadata(res)
304+
# TODO: revert this change after digitized lecturemedia migration
305+
# with pytest.raises(MissingRequiredField):
306+
# record_entry._metadata(res)
300307

301308
# Test case: Add internal note which has a valid date to record
302309
modified_data = data[1]

0 commit comments

Comments
 (0)