Changeset 801 for trunk/tests


Ignore:
Timestamp:
Jan 31, 2016, 2:51:16 PM (3 years ago)
Author:
cito
Message:

Add documentation and tests for two older methods

transaction() was there since 3.6 and parameter() since 4.0,
but they have never been documented or tested

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/test_classic_connection.py

    r798 r801  
    255255        self.assertIsInstance(r, int)
    256256        self.assertGreaterEqual(r, 0)
     257
     258    def testMethodTransaction(self):
     259        transaction = self.connection.transaction
     260        self.assertRaises(TypeError, transaction, None)
     261        self.assertEqual(transaction(), pg.TRANS_IDLE)
     262        self.connection.query('begin')
     263        self.assertEqual(transaction(), pg.TRANS_INTRANS)
     264        self.connection.query('rollback')
     265        self.assertEqual(transaction(), pg.TRANS_IDLE)
     266
     267    def testMethodParameter(self):
     268        parameter = self.connection.parameter
     269        query = self.connection.query
     270        self.assertRaises(TypeError, parameter)
     271        r = parameter('this server setting does not exist')
     272        self.assertIsNone(r)
     273        s = query('show server_version').getresult()[0][0].upper()
     274        self.assertIsNotNone(s)
     275        r = parameter('server_version')
     276        self.assertEqual(r, s)
     277        s = query('show server_encoding').getresult()[0][0].upper()
     278        self.assertIsNotNone(s)
     279        r = parameter('server_encoding')
     280        self.assertEqual(r, s)
     281        s = query('show client_encoding').getresult()[0][0].upper()
     282        self.assertIsNotNone(s)
     283        r = parameter('client_encoding')
     284        self.assertEqual(r, s)
     285        s = query('show server_encoding').getresult()[0][0].upper()
     286        self.assertIsNotNone(s)
     287        r = parameter('server_encoding')
     288        self.assertEqual(r, s)
    257289
    258290
Note: See TracChangeset for help on using the changeset viewer.