comparison test/db_test_base.py @ 6434:269f39e28d5c

issue2551142 - Import of retired node ... unique constraint failure. Title: Import of retired node with username after active node fails with unique constraint failure. Use different way of checking log output. Remove commit and rollback messages. For some reason python 3.4 in CI has different location for our interesting messages. 3.5+ all passed fine. Update upgrading.txt and CHANGES.txt.
author John Rouillard <rouilj@ieee.org>
date Thu, 10 Jun 2021 16:16:40 -0400
parents c1d3fbcdbfbd
children 91ab3e0ffcd0
comparison
equal deleted inserted replaced
6433:c1d3fbcdbfbd 6434:269f39e28d5c
2955 if self.db.dbtype not in ['anydbm', 'memorydb']: 2955 if self.db.dbtype not in ['anydbm', 'memorydb']:
2956 # no logs or fixup needed under anydbm 2956 # no logs or fixup needed under anydbm
2957 # postgres requires commits and rollbacks 2957 # postgres requires commits and rollbacks
2958 # as part of error recovery, so we get commit 2958 # as part of error recovery, so we get commit
2959 # logging that we need to account for 2959 # logging that we need to account for
2960 log = []
2960 if self.db.dbtype == 'postgres': 2961 if self.db.dbtype == 'postgres':
2961 log_count=24 2962 # remove commit and rollback log messages
2962 handle_msg_location=16 2963 # so the indexes below work correctly.
2963 # add two since rollback is logged 2964 for i in range(0,len(self._caplog.record_tuples)):
2964 success_msg_location = handle_msg_location+2 2965 if self._caplog.record_tuples[i][2] not in \
2966 ["commit", "rollback"]:
2967 log.append(self._caplog.record_tuples[i])
2965 else: 2968 else:
2966 log_count=2 2969 log = self._caplog.record_tuples[:]
2967 handle_msg_location=0 2970
2968 success_msg_location = handle_msg_location+1 2971 log_count=2
2969 self.assertEqual(log_count, len(self._caplog.record_tuples)) 2972 handle_msg_location=0
2973 success_msg_location = handle_msg_location+1
2974
2975 self.assertEqual(log_count, len(log))
2970 self.assertIn('Attempting to handle import exception for id 7:', 2976 self.assertIn('Attempting to handle import exception for id 7:',
2971 self._caplog.record_tuples[handle_msg_location][2]) 2977 log[handle_msg_location][2])
2972 self.assertIn('Successfully handled import exception for id 7 ' 2978 self.assertIn('Successfully handled import exception for id 7 '
2973 'which conflicted with 6', 2979 'which conflicted with 6',
2974 self._caplog.record_tuples[success_msg_location][2]) 2980 log[success_msg_location][2])
2975 2981
2976 # This is needed, otherwise journals won't be there for anydbm 2982 # This is needed, otherwise journals won't be there for anydbm
2977 self.db.commit() 2983 self.db.commit()
2978 finally: 2984 finally:
2979 shutil.rmtree('_test_export') 2985 shutil.rmtree('_test_export')

Roundup Issue Tracker: http://roundup-tracker.org/