From c954ec119a7160c6d9926f9a74c1bf3993061586 Mon Sep 17 00:00:00 2001 From: SpacemanSteve Date: Tue, 27 Oct 2020 14:28:51 -0400 Subject: [PATCH] force message retry on update db error --- adsmp/app.py | 2 +- adsmp/tests/test_app.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/adsmp/app.py b/adsmp/app.py index 9e491d0..cd72a70 100644 --- a/adsmp/app.py +++ b/adsmp/app.py @@ -164,7 +164,7 @@ def update_storage(self, bibcode, type, payload): except exc.IntegrityError: self.logger.exception('error in app.update_storage while updating database for bibcode {}, type {}'.format(bibcode, type)) session.rollback() - return None + raise def delete_by_bibcode(self, bibcode): with self.session_scope() as session: diff --git a/adsmp/tests/test_app.py b/adsmp/tests/test_app.py index 295e06f..423817e 100644 --- a/adsmp/tests/test_app.py +++ b/adsmp/tests/test_app.py @@ -288,8 +288,7 @@ def test_update_records(self): def test_update_records_db_error(self): """test database exception IntegrityError is caught""" with mock.patch('sqlalchemy.orm.session.Session.commit', side_effect=[IntegrityError('a', 'b', 'c', 'd'), None]): - r = self.app.update_storage('abc', 'nonbib_data', '{}') - self.assertIsNone(r) + self.assertRaises(IntegrityError, self.app.update_storage, 'abc', 'nonbib_data', '{}') def test_rename_bibcode(self): self.app.update_storage('abc', 'metadata', {'foo': 'bar', 'hey': 1})