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

Handle records with no user value #128

Merged
merged 2 commits into from
Jul 3, 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
3 changes: 3 additions & 0 deletions dlx_dl/scripts/sync/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 16 additions & 1 deletion tests/test_dlx_dl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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
Loading