Changeset 857 for trunk/tests


Ignore:
Timestamp:
Mar 18, 2016, 8:22:21 AM (3 years ago)
Author:
cito
Message:

Add system parameter to get_relations()

Also fix a regression in the 4.x branch when using temporary tables,
related to filtering system tables (as discussed on the mailing list).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/test_classic_dbwrapper.py

    r849 r857  
    990990        self.assertEqual(after_tables, before_tables)
    991991
     992    def testGetSystemTables(self):
     993        get_tables = self.db.get_tables
     994        result = get_tables()
     995        self.assertNotIn('pg_catalog.pg_class', result)
     996        self.assertNotIn('information_schema.tables', result)
     997        result = get_tables(system=False)
     998        self.assertNotIn('pg_catalog.pg_class', result)
     999        self.assertNotIn('information_schema.tables', result)
     1000        result = get_tables(system=True)
     1001        self.assertIn('pg_catalog.pg_class', result)
     1002        self.assertNotIn('information_schema.tables', result)
     1003
    9921004    def testGetRelations(self):
    9931005        get_relations = self.db.get_relations
     
    10071019        self.assertNotIn('public.test', result)
    10081020        self.assertNotIn('public.test_view', result)
     1021
     1022    def testGetSystemRelations(self):
     1023        get_relations = self.db.get_relations
     1024        result = get_relations()
     1025        self.assertNotIn('pg_catalog.pg_class', result)
     1026        self.assertNotIn('information_schema.tables', result)
     1027        result = get_relations(system=False)
     1028        self.assertNotIn('pg_catalog.pg_class', result)
     1029        self.assertNotIn('information_schema.tables', result)
     1030        result = get_relations(system=True)
     1031        self.assertIn('pg_catalog.pg_class', result)
     1032        self.assertIn('information_schema.tables', result)
    10091033
    10101034    def testGetAttnames(self):
     
    23082332        q = "select n from test_parent natural join test_child limit 2"
    23092333        self.assertEqual(query(q).getresult(), [(1,)])
     2334
     2335    def testTempCrud(self):
     2336        table = 'test_temp_table'
     2337        self.createTable(table, "n int primary key, t varchar", temporary=True)
     2338        self.db.insert(table, dict(n=1, t='one'))
     2339        self.db.insert(table, dict(n=2, t='too'))
     2340        self.db.insert(table, dict(n=3, t='three'))
     2341        r = self.db.get(table, 2)
     2342        self.assertEqual(r['t'], 'too')
     2343        self.db.update(table, dict(n=2, t='two'))
     2344        r = self.db.get(table, 2)
     2345        self.assertEqual(r['t'], 'two')
     2346        self.db.delete(table, r)
     2347        r = self.db.query('select n, t from %s order by 1' % table).getresult()
     2348        self.assertEqual(r, [(1, 'one'), (3, 'three')])
    23102349
    23112350    def testTruncate(self):
Note: See TracChangeset for help on using the changeset viewer.