Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Continues marc records if a record is None #1400

Merged
merged 2 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions libsys_airflow/plugins/data_exports/marc/oclc.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ def divide(self, marc_file) -> None:
if not i % 100:
logger.info(f"{i:,} records processed")

if record is None:
logger.error(f"Record {i} is None in {marc_file}")
continue

record_ids = get_record_id(record)
campus_codes = self.determine_campus_code(record)

Expand Down
7 changes: 6 additions & 1 deletion tests/data_exports/test_oclc.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,9 @@ def test_determine_campus_code_http_error(mocker, mock_folio_client):
assert codes == []


def test_oclc_division(mocker, tmp_path, mock_folio_client, sample_marc_records):
def test_oclc_division(
mocker, tmp_path, mock_folio_client, sample_marc_records, caplog
):

mocker.patch(
'libsys_airflow.plugins.data_exports.marc.transformer.folio_client',
Expand All @@ -385,10 +387,13 @@ def test_oclc_division(mocker, tmp_path, mock_folio_client, sample_marc_records)
marc_writer = pymarc.MARCWriter(fo)
for record in sample_marc_records:
marc_writer.write(record)
fo.write(b"\n")

oclc_transformer = OCLCTransformer()
oclc_transformer.divide(marc_file=str(marc_file.absolute()))

assert "Record 3 is None" in caplog.text

assert len(oclc_transformer.libraries["STF"]["holdings"]) == 1
assert len(oclc_transformer.libraries["STF"]["marc"]) == 1

Expand Down
Loading