Changeset 763 for branches/4.x


Ignore:
Timestamp:
Jan 17, 2016, 4:01:04 PM (4 years ago)
Author:
cito
Message:

Achieve 100% test coverage for pg module on the trunk

Note that some lines are only covered in certain Pg or Py versions,
so you need to run tests with different versions to be sure.

Also added another synonym for transaction methods,
you can now pick your favorite for all three of them.

Location:
branches/4.x
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/4.x/docs/contents/pg/db_wrapper.rst

    r762 r763  
    257257
    258258.. versionadded:: 4.1
     259
     260.. method:: DB.abort()
     261
     262    This is the same as the :meth:`DB.rollback` method.
     263
     264.. versionadded:: 4.2
    259265
    260266.. method:: DB.savepoint(name)
  • branches/4.x/pg.py

    r762 r763  
    520520        return self.query(qstr)
    521521
     522    abort = rollback
     523
    522524    def savepoint(self, name):
    523525        """Define a new savepoint within the current transaction."""
     
    899901            if isinstance(arg, dict):
    900902                if qoid not in arg:
    901                     raise _db_error('%s not in arg' % qoid)
     903                    raise _prg_error('%s not in arg' % qoid)
    902904            else:
    903905                arg = {qoid: arg}
  • branches/4.x/tests/test_classic_dbwrapper.py

    r762 r763  
    7272    def testAllDBAttributes(self):
    7373        attributes = [
     74            'abort',
    7475            'begin',
    7576            'cancel', 'clear', 'close', 'commit',
     
    223224        else:
    224225            self.fail('Reset should give an error for a closed connection')
     226        self.assertIsNone(self.db.db)
    225227        self.assertRaises(pg.InternalError, self.db.close)
    226228        self.assertRaises(pg.InternalError, self.db.query, 'select 1')
     229        self.assertRaises(pg.InternalError, getattr, self.db, 'status')
     230        self.assertRaises(pg.InternalError, getattr, self.db, 'error')
     231        self.assertRaises(pg.InternalError, getattr, self.db, 'absent')
    227232
    228233    def testMethodReset(self):
     
    437442        self.assertRaises(TypeError, f, None)
    438443        self.assertRaises(TypeError, f, 42)
     444        self.assertRaises(TypeError, f, '')
     445        self.assertRaises(TypeError, f, [])
     446        self.assertRaises(TypeError, f, [''])
    439447        self.assertRaises(pg.ProgrammingError, f, 'this_does_not_exist')
    440448        r = f('standard_conforming_strings')
     
    488496        self.assertRaises(TypeError, f, None)
    489497        self.assertRaises(TypeError, f, 42)
     498        self.assertRaises(TypeError, f, '')
     499        self.assertRaises(TypeError, f, [])
     500        self.assertRaises(TypeError, f, [''])
     501        self.assertRaises(ValueError, f, 'all', 'invalid')
     502        self.assertRaises(ValueError, f, {
     503            'invalid1': 'value1', 'invalid2': 'value2'}, 'value')
    490504        self.assertRaises(pg.ProgrammingError, f, 'this_does_not_exist')
    491505        f('standard_conforming_strings', 'off')
     
    771785        self.assertRaises(pg.ProgrammingError,
    772786            self.db.get_attnames, 'has.too.many.dots')
     787        attributes = self.db.get_attnames('test')
     788        self.assertIsInstance(attributes, dict)
     789        self.assertEqual(attributes, dict(
     790            i2='int', i4='int', i8='int', d='num',
     791            f4='float', f8='float', m='money',
     792            v4='text', c4='text', t='text'))
    773793        for table in ('attnames_test_table', 'test table for attnames'):
    774794            self.db.query('drop table if exists "%s"' % table)
Note: See TracChangeset for help on using the changeset viewer.