Skip to content

Commit

Permalink
Replace test for 'get_dates'
Browse files Browse the repository at this point in the history
Why these changes are being introduced:
* The record stub now available for testing negates the need for an XML file solely for
checking invalid date formats.
  • Loading branch information
jonavellecuerdo committed May 21, 2024
1 parent e43e295 commit cd5569a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 39 deletions.
26 changes: 0 additions & 26 deletions tests/fixtures/oai_dc/oaidc_record_valid_generic_date.xml

This file was deleted.

22 changes: 9 additions & 13 deletions tests/sources/xml/test_oai_dc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import transmogrifier.models as timdex
from transmogrifier.sources.xml.oaidc import OaiDc

FIXTURES_PREFIX = "tests/fixtures/oai_dc"


def create_oai_dc_source_record_stub(xml_insert: str) -> BeautifulSoup:
xml_str = f"""
Expand Down Expand Up @@ -184,6 +182,15 @@ def test_get_dates_transforms_correctly_if_fields_missing(
)


def test_get_dates_transforms_correctly_if_date_invalid():
source_record = create_oai_dc_source_record_stub(
"""
<dc:date>INVALID</dc:date>
"""
)
assert OaiDc.get_dates(source_record_id="abc", source_record=source_record) == []


def test_get_identifiers_success(oai_dc_record_all_fields):
assert OaiDc.get_identifiers(oai_dc_record_all_fields) == [
timdex.Identifier(value="oai:libguides.com:guides/175846", kind="OAI-PMH")
Expand Down Expand Up @@ -272,14 +279,3 @@ def test_get_summary_transforms_properly_if_fields_missing(
oai_dc_record_optional_fields_missing,
):
assert OaiDc.get_summary(oai_dc_record_optional_fields_missing) == []


def test_oaidc_generic_date():
source_records = OaiDc.parse_source_file(
f"{FIXTURES_PREFIX}/oaidc_record_valid_generic_date.xml"
)
transformer_instance = OaiDc("libguides", source_records)
xml = next(transformer_instance.source_records)
assert transformer_instance.get_dates("test_source_record_id", xml) == [
timdex.Date(kind="Unknown", note=None, range=None, value="2008-06-19T17:55:27")
]

0 comments on commit cd5569a

Please sign in to comment.