From a9abc9908dc8cda554d4987f073e22d31b241f91 Mon Sep 17 00:00:00 2001 From: Grzegorz Niewisiewicz Date: Mon, 27 Jan 2014 08:58:45 +0100 Subject: [PATCH] Add a test case for table cache updates This test case verifies whether get_table returns the most up-to-date table object containing all columns that has been added to the table since the last cache update. --- test/test_persistence.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/test_persistence.py b/test/test_persistence.py index 696f746..ca52c03 100644 --- a/test/test_persistence.py +++ b/test/test_persistence.py @@ -121,6 +121,13 @@ class DatabaseTestCase(unittest.TestCase): r = self.db.query('SELECT COUNT(*) AS num FROM weather').next() assert r['num'] == len(TEST_DATA), r + def test_table_cache_updates(self): + tbl1 = self.db.get_table('people') + tbl1.insert(dict(first_name='John', last_name='Smith')) + tbl2 = self.db.get_table('people') + + assert list(tbl2.all()) == [(1, 'John', 'Smith')] + class TableTestCase(unittest.TestCase):