Skip to content

Commit

Permalink
Add get_source_link method to MITAardvark class
Browse files Browse the repository at this point in the history
  • Loading branch information
ehanson8 committed Jan 4, 2024
1 parent e6d1a1c commit f5c8331
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/sources/json/test_aardvark.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def test_aardvark_get_required_fields_returns_expected_values(aardvark_records):
transformer = MITAardvark("cool-repo", aardvark_records)
assert transformer.get_required_fields(next(aardvark_records)) == {
"source": "A Cool Repository",
"source_link": "https://example.com/123",
"source_link": "https://example.com/gismit:123",
"timdex_record_id": "cool-repo:123",
"title": "Test title 1",
}
Expand All @@ -18,10 +18,10 @@ def test_aardvark_transform_returns_timdex_record(aardvark_records):
transformer = MITAardvark("cool-repo", aardvark_records)
assert next(transformer) == timdex.TimdexRecord(
source="A Cool Repository",
source_link="https://example.com/123",
source_link="https://example.com/gismit:123",
timdex_record_id="cool-repo:123",
title="Test title 1",
citation="Test title 1. Geospatial data. https://example.com/123",
citation="Test title 1. Geospatial data. https://example.com/gismit:123",
content_type=["Geospatial data"],
rights=[timdex.Rights(description="Access rights", kind="Access")],
)
Expand Down
22 changes: 22 additions & 0 deletions transmogrifier/sources/json/aardvark.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,28 @@ def get_main_titles(cls, source_record: dict) -> list[str]:
"""
return [source_record["dct_title_s"]]

@classmethod
def get_source_link(
cls, source_base_url: str, source_record_id: str, source_record: dict[str, JSON]
) -> str:
"""
Class method to set the source link for the item.
May be overridden by source subclasses if needed.
Default behavior is to concatenate the source base URL + source record id.
Args:
source_base_url: Source base URL.
source_record_id: Record identifier for the source record.
source_record: A BeautifulSoup Tag representing a single XML record.
- not used by default implementation, but could be useful for subclass
overrides
"""
return source_base_url + cls.get_timdex_record_id(
"gismit", source_record_id, source_record
)

@classmethod
def get_timdex_record_id(
cls, source: str, source_record_id: str, source_record: dict[str, JSON]
Expand Down

0 comments on commit f5c8331

Please sign in to comment.