Skip to content

Commit 2f6a89d

Browse files
committed
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..
1 parent 723ae70 commit 2f6a89d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

test/db_test_base.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,18 +1432,19 @@ def testJournalNonexistingProperty(self):
14321432
self.db.commit()
14331433
journal = self.db.getjournal('issue', id)
14341434
now = date.Date('.')
1435-
sec = date.Interval('0:00:01')
1435+
sec1 = date.Interval('0:00:01')
14361436
sec2 = date.Interval('0:00:02')
1437+
sec3 = date.Interval('0:00:03')
14371438
jp0 = dict(title = 'spam')
14381439
# Non-existing property changed
14391440
jp1 = dict(nonexisting = None)
1440-
journal.append ((id, now, '1', 'set', jp1))
1441+
journal.append ((id, now+sec1, '1', 'set', jp1))
14411442
# Link from user-class to non-existing property
14421443
jp2 = ('user', '1', 'xyzzy')
1443-
journal.append ((id, now+sec, '1', 'link', jp2))
1444+
journal.append ((id, now+sec2, '1', 'link', jp2))
14441445
# Link from non-existing class
14451446
jp3 = ('frobozz', '1', 'xyzzy')
1446-
journal.append ((id, now+sec2, '1', 'link', jp3))
1447+
journal.append ((id, now+sec3, '1', 'link', jp3))
14471448
self.db.setjournal('issue', id, journal)
14481449
self.db.commit()
14491450
result=self.db.issue.history(id)
@@ -1460,6 +1461,9 @@ def testJournalNonexistingProperty(self):
14601461
print(result) # following test fails sometimes under sqlite
14611462
# in travis. Looks like an ordering issue
14621463
# 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.
14631467
self.assertEqual(result [2][4], jp1)
14641468
self.assertEqual(result [3][4], jp2)
14651469
self.assertEqual(result [4][4], jp3)

0 commit comments

Comments
 (0)