Skip to content

Commit

Permalink
Check 035 for gls string, and fix subfield checks where subfields is …
Browse files Browse the repository at this point in the history
…a list of strings
  • Loading branch information
jgreben committed Mar 13, 2024
1 parent b7711a1 commit e796afa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
14 changes: 7 additions & 7 deletions libsys_airflow/plugins/data_exports/marc/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ class Exporter(object):
def __init__(self):
self.folio_client = folio_client()

def check_001(self, field001s: list) -> bool:
def check_035(self, field035s: list) -> bool:
reject = False
for field in field001s:
if field.value() == "gls":
for field in field035s:
if any("gls" in sf for sf in field.get_subfields("a")):
reject = True
return reject

Expand All @@ -31,16 +31,16 @@ def check_008(self, fields008: list) -> bool:
def check_590(self, field590s: list) -> bool:
reject = False
for field in field590s:
if "MARCit brief record" in field.get_subfields("a"):
if any("MARCit brief record" in sf for sf in field.get_subfields("a")):
reject = True
return reject

def check_915(self, fields915: list) -> bool:
reject = False
for field in fields915:
if "NO EXPORT" in field.get_subfields(
if any("NO EXPORT" in sf for sf in field.get_subfields(
"a"
) and "FOR SU ONLY" in field.get_subfields("b"):
)) and any("FOR SU ONLY" in sf for sf in field.get_subfields("b")):
reject = True
return reject

Expand All @@ -53,7 +53,7 @@ def exclude_marc_by_vendor(self, marc_record: pymarc.Record, vendor: str):
case "gobi":
exclude = any(
[
self.check_001(marc_record.get_fields("001")),
self.check_035(marc_record.get_fields("035")),
self.check_008(marc_record.get_fields("008")),
]
)
Expand Down
10 changes: 7 additions & 3 deletions tests/data_exports/test_marc_exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def mock_folio_get(*args, **kwargs):
},
]
if "fe2e581f-9767-442a-ae3c-a421ac655fe2" in args[0]:
# This record gets rejected because it is japanede language (not fre or eng) per _check_008 function
# This record gets rejected because it is japanese language (not fre or eng) per _check_008 function
fields = [
{'001': 'a4232294'},
{'008': '920218s1990 ja a 000 0 jpn '},
Expand Down Expand Up @@ -181,7 +181,11 @@ def test_marc_for_instances(mocker, tmp_path, mock_folio_client):
assert files[0].endswith('202402271159.csv')


field_001 = pymarc.Field(tag='001', data='gls')
field_035 = pymarc.Field(
tag='035',
indicators=[' ', '9'],
subfields=[pymarc.Subfield(code='a', value='gls19291491')],
)

field_008 = pymarc.Field(tag='008', data='920218s1990 ja a 000 0 jpn ')

Expand Down Expand Up @@ -211,7 +215,7 @@ def test_exclude_marc_by_vendor_gobi(mocker):
mocker.patch('libsys_airflow.plugins.data_exports.marc.exporter.folio_client')
exporter = Exporter()
marc_record = pymarc.Record()
marc_record.add_field(field_001, field_008)
marc_record.add_field(field_035)

assert exporter.exclude_marc_by_vendor(marc_record, 'gobi')

Expand Down

0 comments on commit e796afa

Please sign in to comment.