comparison test/test_anydbm.py @ 6806:bdd28b244839

- issue2551223 - fix timestamp truncation in mysql and postgresql The data types used to represent timestamps in pg and mysql for ephemeral tables: sessions and otks don't have enough signifcant digits to work. As a result the timestamps are rounduped (up/down) rsuling in the stored timestamp being 2 minutes (pg) or 2-3 hours(mysql) off from what it should be. Modify db schema to use a numeric type that preserves more significant figures. Implement schema upgrade. Document need for upgrade in upgrading.txt. Write tests for schema upgrade. Implement test for updateTimestamp method on BasicDatabase that showed this issue in the first place. Write overrides for test for anydbm/memorydb which store timestamp properly or not at all.
author John Rouillard <rouilj@ieee.org>
date Mon, 25 Jul 2022 17:20:20 -0400
parents 044dcf3608a2
children 3f60a71b0812
comparison
equal deleted inserted replaced
6805:09d9c646ca89 6806:bdd28b244839
53 53
54 from .session_common import SessionTest 54 from .session_common import SessionTest
55 class anydbmSessionTest(anydbmOpener, SessionTest, unittest.TestCase): 55 class anydbmSessionTest(anydbmOpener, SessionTest, unittest.TestCase):
56 s2b = lambda x,y: strings.s2b(y) 56 s2b = lambda x,y: strings.s2b(y)
57 57
58 # this only works for dbm. other backends don't change the __timestamp
59 # value, they have a separate column for the timestamp so they can
60 # update it with SQL.
61 def testUpdateTimestamp(self):
62 # make sure timestamp is older than one minute so update will work
63 timestamp = time.time() - 62
64 self.sessions.set('random_session', text='hello, world!',
65 __timestamp=timestamp)
66 self.sessions.updateTimestamp('random_session')
67 self.assertNotEqual (self.sessions.get('random_session',
68 '__timestamp'),
69 timestamp)
70
58 class anydbmSpecialActionTestCase(anydbmOpener, SpecialActionTest, 71 class anydbmSpecialActionTestCase(anydbmOpener, SpecialActionTest,
59 unittest.TestCase): 72 unittest.TestCase):
60 backend = 'anydbm' 73 backend = 'anydbm'
61 74
62 class anydbmRestTest (RestTestCase, unittest.TestCase): 75 class anydbmRestTest (RestTestCase, unittest.TestCase):

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