def test_delete(db, capsys): import json from http.server import HTTPServer from xmldiff.main import diff_texts from dlx.marc import Bib server = HTTPServer(('127.0.0.1', 9090), None) responses.add(responses.POST, 'http://127.0.0.1:9090', body='test OK') dlx_dl.API_URL = 'http://127.0.0.1:9090' bib = Bib().set('245', 'a', 'Will self destruct') bib.commit() bib.delete() dlx_dl.run(connect=db, source='test', type='bib', modified_within=100, use_api=True, api_key='x') data = list(filter(None, capsys.readouterr().out.split('\n'))) assert len(data) == 3 assert json.loads(data[2])['record_id'] == 3 ### end
def test_delete(db): from dlx import DB from dlx.marc import Bib from datetime import datetime bib = Bib().set('245', 'a', 'This record will self-destruct') bib.commit() bib.delete() assert Bib.match_id(bib.id) == None history = DB.handle['bib_history'].find_one({'_id': bib.id}) assert history['deleted']['user'] == 'admin' assert isinstance(history['deleted']['time'], datetime)