comparison test/db_test_base.py @ 8541:7a7f6ee0a09e

bug: import/importables fail to set newid correctly. Looks like I broke import when I was fixing a scandir issue. Overindented a couple of lines. This prevented the next used id from being set properly. It also resulted in wierd output when importing (bunches of newlines). Also fixed the two export/import tests to verify the new nextid for all the classes is equal or higher than the old one. Ideally they should be equal, but there is a bug somewhere where we get a double increment in the export/import cycle dropping a number or two.
author John Rouillard <rouilj@ieee.org>
date Mon, 23 Mar 2026 22:22:24 -0400
parents 05d8806b25ad
children 9c3ec0a5c7fc
comparison
equal deleted inserted replaced
8540:e8d1da6e3571 8541:7a7f6ee0a09e
3229 it = cl[id] = {} 3229 it = cl[id] = {}
3230 jn[id] = self.db.getjournal(cn, id) 3230 jn[id] = self.db.getjournal(cn, id)
3231 for name in klass.getprops().keys(): 3231 for name in klass.getprops().keys():
3232 it[name] = klass.get(id, name) 3232 it[name] = klass.get(id, name)
3233 3233
3234 # record the newid from the original database
3235 orig_newid = {cn: self.db.newid(cn) for cn in self.db.classes.keys()}
3236
3234 os.mkdir('_test_export') 3237 os.mkdir('_test_export')
3235 try: 3238 try:
3236 # grab the export 3239 # grab the export
3237 export = {} 3240 export = {}
3238 journals = {} 3241 journals = {}
3354 j[1].second = float(int(j[1].second)) 3357 j[1].second = float(int(j[1].second))
3355 oj.sort(key = NoneAndDictComparable) 3358 oj.sort(key = NoneAndDictComparable)
3356 rj.sort(key = NoneAndDictComparable) 3359 rj.sort(key = NoneAndDictComparable)
3357 ae(oj, rj) 3360 ae(oj, rj)
3358 3361
3362 # compare the newid's. The new database must always have
3363 # newid that is greater or equal to the old newid. Ideally
3364 # they should be equal but there is a latent bug where the restored
3365 # newid is 1 or 2 higher than the old one.
3366 for classname, newid in orig_newid.items():
3367 self.assertGreaterEqual(
3368 self.db.newid(classname), newid,
3369 msg="When comparing newid values for classname:old_val:"
3370 " %s:%s" % (classname, newid))
3371
3359 # make sure the retired items are actually imported 3372 # make sure the retired items are actually imported
3360 ae(self.db.user.get('4', 'username'), 'blop') 3373 ae(self.db.user.get('4', 'username'), 'blop')
3361 ae(self.db.issue.get('2', 'title'), 'issue two') 3374 ae(self.db.issue.get('2', 'title'), 'issue two')
3362 3375
3363 # make sure id counters are set correctly 3376 # make sure id counters are set correctly
3374 # create large field 3387 # create large field
3375 self.db.priority.create(name = 'X' * 500) 3388 self.db.priority.create(name = 'X' * 500)
3376 self.db.config.CSV_FIELD_SIZE = 400 3389 self.db.config.CSV_FIELD_SIZE = 400
3377 self.db.commit() 3390 self.db.commit()
3378 output = [] 3391 output = []
3392
3393 # record the newid from the original database
3394 orig_newid = {cn: self.db.newid(cn) for cn in self.db.classes.keys()}
3395
3379 # ugly hack to get stderr output and disable stdout output 3396 # ugly hack to get stderr output and disable stdout output
3380 # during regression test. Depends on roundup.admin not using 3397 # during regression test. Depends on roundup.admin not using
3381 # anything but stdout/stderr from sys (which is currently the 3398 # anything but stdout/stderr from sys (which is currently the
3382 # case) 3399 # case)
3383 def stderrwrite(s): 3400 def stderrwrite(s):
3424 tool.verbose = False 3441 tool.verbose = False
3425 tool.do_import(['_test_export']) 3442 tool.do_import(['_test_export'])
3426 3443
3427 # verify the data is loaded. 3444 # verify the data is loaded.
3428 self.db.user.getnode("5").values() 3445 self.db.user.getnode("5").values()
3446
3447 # compare the newid's. The new database must always have
3448 # newid that is greater or equal to the old newid. Ideally
3449 # they should be equal but there is a latent bug where the restored
3450 # newid is 1 or 2 higher than the old one.
3451 for classname, newid in orig_newid.items():
3452 self.assertGreaterEqual(
3453 self.db.newid(classname), newid,
3454 msg="When comparing newid values for "
3455 "classname:old_val: %s:%s" % (classname, newid))
3429 finally: 3456 finally:
3430 roundup.admin.sys = sys 3457 roundup.admin.sys = sys
3431 shutil.rmtree('_test_export') 3458 shutil.rmtree('_test_export')
3432 3459
3433 # test props from args parsing 3460 # test props from args parsing

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