From 1d43ae3306eb6ae264299290574fab424d9f46c8 Mon Sep 17 00:00:00 2001 From: jbukhari Date: Mon, 1 Jul 2024 11:34:00 -0400 Subject: [PATCH] pass tests --- dlx_dl/scripts/export/__init__.py | 2 +- dlx_dl/scripts/sync/__init__.py | 6 ++++-- tests/test_dlx_dl.py | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/dlx_dl/scripts/export/__init__.py b/dlx_dl/scripts/export/__init__.py index b482a4a..bd80fbe 100644 --- a/dlx_dl/scripts/export/__init__.py +++ b/dlx_dl/scripts/export/__init__.py @@ -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) diff --git a/dlx_dl/scripts/sync/__init__.py b/dlx_dl/scripts/sync/__init__.py index 22c612e..75f415c 100644 --- a/dlx_dl/scripts/sync/__init__.py +++ b/dlx_dl/scripts/sync/__init__.py @@ -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 @@ -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'] diff --git a/tests/test_dlx_dl.py b/tests/test_dlx_dl.py index a5f5e70..588f2e5 100644 --- a/tests/test_dlx_dl.py +++ b/tests/test_dlx_dl.py @@ -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 @@ -217,7 +217,7 @@ def test_561(db, tmp_path): bib = Bib().set('561', 'u', 'test uri identifier') bib.commit() - control = '(DHL)3test uri identifierBIBhttps://mock_bucket.s3.amazonaws.com/1e50210a0202497fb79bc38b6ade6c34.test_1' + control = '(DHL)3test uri identifierBIBhttps://mock_bucket.s3.amazonaws.com/1e50210a0202497fb79bc38b6ade6c34English.test_1' 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) == []