Mercurial > p > roundup > code
comparison test/db_test_base.py @ 6968:4169f27f15f6
force time offset when loading journal
Had a failure in python2.7 under sqlite where journal
was in wrong location because two journal entries had
identical timestamps.
jonural entry 2 and 3 were swapped. Add a second offset to
all new journal entries added to see if we can prevent this..
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Tue, 13 Sep 2022 18:40:43 -0400 |
| parents | 9ff091537f43 |
| children | 2acea75cd7e5 |
comparison
equal
deleted
inserted
replaced
| 6967:8473039648da | 6968:4169f27f15f6 |
|---|---|
| 1430 self.db.issue.set(id, title='green eggs') | 1430 self.db.issue.set(id, title='green eggs') |
| 1431 time.sleep(2) | 1431 time.sleep(2) |
| 1432 self.db.commit() | 1432 self.db.commit() |
| 1433 journal = self.db.getjournal('issue', id) | 1433 journal = self.db.getjournal('issue', id) |
| 1434 now = date.Date('.') | 1434 now = date.Date('.') |
| 1435 sec = date.Interval('0:00:01') | 1435 sec1 = date.Interval('0:00:01') |
| 1436 sec2 = date.Interval('0:00:02') | 1436 sec2 = date.Interval('0:00:02') |
| 1437 sec3 = date.Interval('0:00:03') | |
| 1437 jp0 = dict(title = 'spam') | 1438 jp0 = dict(title = 'spam') |
| 1438 # Non-existing property changed | 1439 # Non-existing property changed |
| 1439 jp1 = dict(nonexisting = None) | 1440 jp1 = dict(nonexisting = None) |
| 1440 journal.append ((id, now, '1', 'set', jp1)) | 1441 journal.append ((id, now+sec1, '1', 'set', jp1)) |
| 1441 # Link from user-class to non-existing property | 1442 # Link from user-class to non-existing property |
| 1442 jp2 = ('user', '1', 'xyzzy') | 1443 jp2 = ('user', '1', 'xyzzy') |
| 1443 journal.append ((id, now+sec, '1', 'link', jp2)) | 1444 journal.append ((id, now+sec2, '1', 'link', jp2)) |
| 1444 # Link from non-existing class | 1445 # Link from non-existing class |
| 1445 jp3 = ('frobozz', '1', 'xyzzy') | 1446 jp3 = ('frobozz', '1', 'xyzzy') |
| 1446 journal.append ((id, now+sec2, '1', 'link', jp3)) | 1447 journal.append ((id, now+sec3, '1', 'link', jp3)) |
| 1447 self.db.setjournal('issue', id, journal) | 1448 self.db.setjournal('issue', id, journal) |
| 1448 self.db.commit() | 1449 self.db.commit() |
| 1449 result=self.db.issue.history(id) | 1450 result=self.db.issue.history(id) |
| 1450 result.sort() | 1451 result.sort() |
| 1451 # anydbm drops unknown properties during serialisation | 1452 # anydbm drops unknown properties during serialisation |
| 1458 self.assertEqual(len(result), 5) | 1459 self.assertEqual(len(result), 5) |
| 1459 self.assertEqual(result [1][4], jp0) | 1460 self.assertEqual(result [1][4], jp0) |
| 1460 print(result) # following test fails sometimes under sqlite | 1461 print(result) # following test fails sometimes under sqlite |
| 1461 # in travis. Looks like an ordering issue | 1462 # in travis. Looks like an ordering issue |
| 1462 # in python 3.5. Print result to debug. | 1463 # in python 3.5. Print result to debug. |
| 1464 # is system runs fast enough, timestamp can | |
| 1465 # be the same on two journal items. Ordering | |
| 1466 # in that case is random. | |
| 1463 self.assertEqual(result [2][4], jp1) | 1467 self.assertEqual(result [2][4], jp1) |
| 1464 self.assertEqual(result [3][4], jp2) | 1468 self.assertEqual(result [3][4], jp2) |
| 1465 self.assertEqual(result [4][4], jp3) | 1469 self.assertEqual(result [4][4], jp3) |
| 1466 self.db.close() | 1470 self.db.close() |
| 1467 # Verify that normal user doesn't see obsolete props/classes | 1471 # Verify that normal user doesn't see obsolete props/classes |
