Skip to content

Commit

Permalink
pass tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jbukhari committed Jul 1, 2024
1 parent b0bbfd5 commit 1d43ae3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dlx_dl/scripts/export/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def _561(bib):
latest = sorted(files, key=lambda x: x.timestamp, reverse=True)[0]
_fft = Datafield('FFT', record_type='bib')
_fft.set('a', 'https://' + latest.uri)
_fft.set('d', ', '.join([ISO_STR.get(x, '') for x in latest.langauges]))
_fft.set('d', ', '.join([ISO_STR.get(x, '') for x in latest.languages]))

old_fn = latest.filename if latest.filename else uri.split('/')[-1]
new_fn = clean_fn(old_fn)
Expand Down
6 changes: 4 additions & 2 deletions dlx_dl/scripts/sync/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ def param(name):

# if run as function convert args to sys.argv so they can be parsed by ArgumentParser
if kwargs:
sys.argv = [sys.argv[0]] # clear any existing command line args

for key, val in kwargs.items():
if val == True:
# boolean args
Expand All @@ -90,10 +92,10 @@ def param(name):
sys.argv.append(f'--{key}={val}')

return parser.parse_args()

def run(**kwargs):
args = get_args(**kwargs)

if isinstance(kwargs.get('connect'), MockClient):
# required for testing
DB.client = kwargs['connect']
Expand Down
4 changes: 2 additions & 2 deletions tests/test_dlx_dl.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os, pytest, responses
import sys, os, pytest, responses
from moto import mock_aws
from datetime import datetime
from dlx_dl.scripts import export, sync
Expand Down Expand Up @@ -217,7 +217,7 @@ def test_561(db, tmp_path):

bib = Bib().set('561', 'u', 'test uri identifier')
bib.commit()
control = '<collection><record><datafield tag="035" ind1=" " ind2=" "><subfield code="a">(DHL)3</subfield></datafield><datafield tag="561" ind1=" " ind2=" "><subfield code="u">test uri identifier</subfield></datafield><datafield tag="980" ind1=" " ind2=" "><subfield code="a">BIB</subfield></datafield><datafield tag="FFT" ind1=" " ind2=" "><subfield code="a">https://mock_bucket.s3.amazonaws.com/1e50210a0202497fb79bc38b6ade6c34</subfield><subfield code="n">.test_1</subfield></datafield></record></collection>'
control = '<collection><record><datafield tag="035" ind1=" " ind2=" "><subfield code="a">(DHL)3</subfield></datafield><datafield tag="561" ind1=" " ind2=" "><subfield code="u">test uri identifier</subfield></datafield><datafield tag="980" ind1=" " ind2=" "><subfield code="a">BIB</subfield></datafield><datafield tag="FFT" ind1=" " ind2=" "><subfield code="a">https://mock_bucket.s3.amazonaws.com/1e50210a0202497fb79bc38b6ade6c34</subfield><subfield code="d">English</subfield><subfield code="n">.test_1</subfield></datafield></record></collection>'
out = tmp_path / 'out.xml'
export.run(connect=db, source='test', type='bib', id=bib.id, xml=out)
assert diff_texts(out.read_text(), control) == []
Expand Down

0 comments on commit 1d43ae3

Please sign in to comment.