Skip to content

Commit

Permalink
Update Springshare OAI sources date handling
Browse files Browse the repository at this point in the history
Why these changes are being introduced:
* Setting date.kind=None was throwing errors in TIMDEX api

How this addresses that need:
* Determined Springshare dates were created, sets to "Created"
* Sets generic OAI transformer to "Unknown", though should not be used directly

Side effects of this change:
* All Springshare records will need to be rerun to get updated date.kind properties.

Relevant ticket(s):
* https://mitlibraries.atlassian.net/browse/TIMX-241
  • Loading branch information
ghukill committed Aug 25, 2023
1 parent 7ffed5e commit 9c28431
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tests/test_oai_dc.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,5 @@ def test_oaidc_generic_date():
transformer_instance = OaiDc("libguides", input_records)
xml = next(transformer_instance.input_records)
assert transformer_instance.get_dates("test_source_record_id", xml) == [
timdex.Date(kind=None, note=None, range=None, value="2008-06-19T17:55:27")
timdex.Date(kind="Unknown", note=None, range=None, value="2008-06-19T17:55:27")
]
8 changes: 5 additions & 3 deletions tests/test_springshare.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ def test_springshare_get_dates_valid():
for xml in transformer_instance.input_records:
date_field_value = transformer_instance.get_dates("test_get_dates", xml)
assert date_field_value == [
timdex.Date(kind=None, note=None, range=None, value="2000-01-01T00:00:00")
timdex.Date(
kind="Created", note=None, range=None, value="2000-01-01T00:00:00"
)
]


Expand Down Expand Up @@ -106,7 +108,7 @@ def test_libguide_transform_with_all_fields_transforms_correctly():
)
],
dates=[
timdex.Date(value="2008-06-19T17:55:27"),
timdex.Date(value="2008-06-19T17:55:27", kind="Created"),
],
format="electronic resource",
identifiers=[
Expand Down Expand Up @@ -160,7 +162,7 @@ def test_research_databases_transform_with_all_fields_transforms_correctly():
"researchdatabases. https://libguides.mit.edu/llba",
content_type=["researchdatabases"],
dates=[
timdex.Date(value="2022-01-28T22:15:37"),
timdex.Date(value="2022-01-28T22:15:37", kind="Created"),
],
format="electronic resource",
identifiers=[
Expand Down
2 changes: 1 addition & 1 deletion transmogrifier/sources/oaidc.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def get_dates(self, source_record_id: str, xml: Tag) -> Optional[List[timdex.Dat
date_str,
source_record_id,
):
dates.append(timdex.Date(value=date_str))
dates.append(timdex.Date(value=date_str, kind="Unknown"))
return dates or None

def get_links(self, source_record_id: str, xml: Tag) -> Optional[List[timdex.Link]]:
Expand Down
2 changes: 1 addition & 1 deletion transmogrifier/sources/springshare.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def get_dates(self, source_record_id: str, xml: Tag) -> Optional[List[timdex.Dat
date_iso_str,
source_record_id,
):
dates.append(timdex.Date(value=date_iso_str, kind=None))
dates.append(timdex.Date(value=date_iso_str, kind="Created"))
return dates or None

def get_links(self, source_record_id: str, xml: Tag) -> Optional[List[timdex.Link]]:
Expand Down

0 comments on commit 9c28431

Please sign in to comment.