def test_fetchmany(self):
"""It gets many rows"""
query = text("""
SELECT id, name FROM tblExample
ORDER BY id
""")
# Expect multiple records to be returned
result = self.dao.fetchmany(query)
self.assertEqual(len(result), 3)
self.assertDictEqual(result[0], {'id': 1, 'name': 'Foo'})
self.assertDictEqual(result[1], {'id': 2, 'name': 'Bar'})
self.assertDictEqual(result[2], {'id': 3, 'name': 'Baz'})
# Expect rows to be limited by MAX_RESULTS_SIZE
self.dao.MAX_RESULTS_SIZE = 2
result = self.dao.fetchmany(query)
self.assertEqual(len(result), 2)
评论列表
文章目录