Skip to content

Commit

Permalink
Add test for copying a table using inserttable
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito committed Jan 29, 2022
1 parent c3b54d5 commit ac66e2e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/test_classic_dbwrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4227,6 +4227,20 @@ def testNotificationHandler(self):
self.db.reopen()
self.assertIsNone(handler.db)

def testInserttableFromQuery(self):
# use inserttable() to copy from one table to another
query = self.db.query
self.createTable('test_table_from', 'n integer, t timestamp')
self.createTable('test_table_to', 'n integer, t timestamp')
for i in range(1, 4):
query("insert into test_table_from values ($1, now())", i)
self.db.inserttable(
'test_table_to', query("select n, t::text from test_table_from"))
data_from = query("select * from test_table_from").getresult()
data_to = query("select * from test_table_to").getresult()
self.assertEqual([row[0] for row in data_from], [1, 2, 3])
self.assertEqual(data_from, data_to)


class TestDBClassNonStdOpts(TestDBClass):
"""Test the methods of the DB class with non-standard global options."""
Expand Down

0 comments on commit ac66e2e

Please sign in to comment.