Skip to content

Commit

Permalink
fix the timestamp tests (#38)
Browse files Browse the repository at this point in the history
* fix the timestamp tests

* remove extraneous comment

---------

Co-authored-by: Greg Landrum <[email protected]>
  • Loading branch information
greglandrum and Greg Landrum authored Dec 11, 2023
1 parent 607116a commit f34f168
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions lwreg/test_lwreg.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,20 +359,20 @@ def testStandardizationLibCheckers(self):
config=lconfig), 2)

def testTimestamp(self):
cn = sqlite3.connect(':memory:')
self._config = utils.defaultConfig()
self._config['connection'] = cn
utils._initdb(config=self._config, confirm=True)
utils.register(smiles='CCC', config=self._config)
time.sleep(2)
utils.register(smiles='CCCC', config=self._config)
cn = utils._connect(config=self._config)
curs = cn.cursor()
d = curs.execute("select molregno, timestamp from orig_data order by molregno asc")
curs.execute("select molregno,timestamp from orig_data order by molregno asc")
d = curs.fetchall()
curs = None

timestamps = []
for row in d:
timestamps.append(datetime.strptime(row[1], "%Y-%m-%d %H:%M:%S"))
timestamps.append(datetime.strptime(row[1], "%Y-%m-%d %H:%M:%S"))
self.assertEqual(timestamps[1]-timestamps[0] > timedelta(0),True)

class TestLWRegTautomerv2(unittest.TestCase):
integrityError = sqlite3.IntegrityError

Expand Down Expand Up @@ -410,6 +410,20 @@ def setUp(self):
self._config['dbname'] = 'lwreg_tests'
self._config['dbtype'] = 'postgresql'

def testTimestamp(self):
utils._initdb(config=self._config, confirm=True)
utils.register(smiles='CCC', config=self._config)
time.sleep(2)
utils.register(smiles='CCCC', config=self._config)
cn = utils._connect(config=self._config)
curs = cn.cursor()
curs.execute("select molregno,timestamp from orig_data order by molregno asc")
d = curs.fetchall()
curs = None
timestamps = []
for row in d:
timestamps.append(row[1])
self.assertEqual(timestamps[1]-timestamps[0] > timedelta(0),True)

class TestStandardizationLabels(unittest.TestCase):

Expand Down

0 comments on commit f34f168

Please sign in to comment.