From 6b100a82b69a8b3a888a9b624b5fcc93686fc810 Mon Sep 17 00:00:00 2001 From: jbukhari Date: Wed, 3 Jul 2024 15:21:20 -0400 Subject: [PATCH 1/2] handle records with no user value --- dlx_dl/scripts/sync/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dlx_dl/scripts/sync/__init__.py b/dlx_dl/scripts/sync/__init__.py index 78ca0a3..3c63d79 100644 --- a/dlx_dl/scripts/sync/__init__.py +++ b/dlx_dl/scripts/sync/__init__.py @@ -204,6 +204,9 @@ def run(**kwargs): Auth.build_cache() for i, record in enumerate(records.records): + if record.user is None: + record.user = 'system' + if record.user[:10] == 'batch_edit': # skip syncing batch edited records for now so as not to overwhelm DL queue continue From be5e103dc2b8cf256bba1e0311762d7a258cf61a Mon Sep 17 00:00:00 2001 From: jbukhari Date: Wed, 3 Jul 2024 15:45:51 -0400 Subject: [PATCH 2/2] update tests --- tests/test_dlx_dl.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/test_dlx_dl.py b/tests/test_dlx_dl.py index 588f2e5..8ae67f3 100644 --- a/tests/test_dlx_dl.py +++ b/tests/test_dlx_dl.py @@ -225,6 +225,7 @@ def test_561(db, tmp_path): def test_sync(db, capsys, mock_get_post): # todo: expand this test from http.server import HTTPServer + from dlx import DB from dlx.marc import Bib bib = Bib().set('245', 'a', 'Will self destruct') @@ -234,5 +235,19 @@ def test_sync(db, capsys, mock_get_post): sync.run(connect=db, source='test', type='bib', modified_within=100, force=True) data = list(filter(None, capsys.readouterr().out.split('\n'))) assert data - + + # skip special user + bib = Bib().set('245', 'a', 'Moar testing') + bib.commit(user='batch_edit_x') + sync.run(connect=db, source='test', type='bib', id=bib.id, force=True) + data = list(filter(None, capsys.readouterr().out.split('\n'))) + assert 'Updated 0 records' in data + + # no user + bib = Bib().set('245', 'a', 'Moar testing') + bib.commit(user='') + sync.run(connect=db, source='test', type='bib', id=bib.id, force=True) + data = list(filter(None, capsys.readouterr().out.split('\n'))) + assert DB.handle['dlx_dl_log'].find_one({'record_id': bib.id}) + ### end \ No newline at end of file