Changeset 26

User picture

Author: dkeeney

(2009/04/12 06:14) About 3 years ago

test bugfixes

Affected files

Added notunittests/README.txt

Show contents

Updated unittests/dbapi20.py Download diff

2526
511
            self.assertEqual(cur.fetchone(),None,
511
            self.assertEqual(cur.fetchone(),None,
512
                'cursor.fetchone should return None if no more rows available'
512
                'cursor.fetchone should return None if no more rows available'
513
                )
513
                )
514
            self.failUnless(cur.rowcount in (-1,1))
514
            self.failUnless(cur.rowcount in (-1,1),cur.rowcount)
515
        finally:
515
        finally:
516
            con.close()
516
            con.close()
517
517
...
...
567
                'cursor.fetchmany should return an empty sequence after '
567
                'cursor.fetchmany should return an empty sequence after '
568
                'results are exhausted'
568
                'results are exhausted'
569
            )
569
            )
570
            self.failUnless(cur.rowcount in (-1,6))
570
            self.failUnless(cur.rowcount in (-1,6),cur.rowcount)
571
571
572
            # Same as above, using cursor.arraysize
572
            # Same as above, using cursor.arraysize
573
            cur.arraysize=4
573
            cur.arraysize=4
...
...
580
            self.assertEqual(len(r),2)
580
            self.assertEqual(len(r),2)
581
            r = cur.fetchmany() # Should be an empty sequence
581
            r = cur.fetchmany() # Should be an empty sequence
582
            self.assertEqual(len(r),0)
582
            self.assertEqual(len(r),0)
583
            self.failUnless(cur.rowcount in (-1,6))
583
            self.failUnless(cur.rowcount in (-1,6),cur.rowcount)
584
584
585
            cur.arraysize=6
585
            cur.arraysize=6
586
            cur.execute('select name from %sbooze' % self.table_prefix)
586
            cur.execute('select name from %sbooze' % self.table_prefix)
587
            rows = cur.fetchmany() # Should get all rows
587
            rows = cur.fetchmany() # Should get all rows
588
            self.failUnless(cur.rowcount in (-1,6))
588
            self.failUnless(cur.rowcount in (-1,6),cur.rowcount)
589
            self.assertEqual(len(rows),6)
589
            self.assertEqual(len(rows),6)
590
            self.assertEqual(len(rows),6)
590
            self.assertEqual(len(rows),6)
591
            rows = [r[0] for r in rows]
591
            rows = [r[0] for r in rows]
...
...
602
                'cursor.fetchmany should return an empty sequence if '
602
                'cursor.fetchmany should return an empty sequence if '
603
                'called after the whole result set has been fetched'
603
                'called after the whole result set has been fetched'
604
                )
604
                )
605
            self.failUnless(cur.rowcount in (-1,6))
605
            self.failUnless(cur.rowcount in (-1,6),cur.rowcount)
606
606
607
            self.executeDDL2(cur)
607
            self.executeDDL2(cur)
608
            cur.execute('select name from %sbarflys' % self.table_prefix)
608
            cur.execute('select name from %sbarflys' % self.table_prefix)
...
...
611
                'cursor.fetchmany should return an empty sequence if '
611
                'cursor.fetchmany should return an empty sequence if '
612
                'query retrieved no rows'
612
                'query retrieved no rows'
613
                )
613
                )
614
            self.failUnless(cur.rowcount in (-1,0))
614
            self.failUnless(cur.rowcount in (-1,0),cur.rowcount)
615
615
616
        finally:
616
        finally:
617
            con.close()
617
            con.close()
...
...
635
635
636
            cur.execute('select name from %sbooze' % self.table_prefix)
636
            cur.execute('select name from %sbooze' % self.table_prefix)
637
            rows = cur.fetchall()
637
            rows = cur.fetchall()
638
            self.failUnless(cur.rowcount in (-1,len(self.samples)))
638
            self.failUnless(cur.rowcount in (-1,len(self.samples)),cur.rowcount)
639
            self.assertEqual(len(rows),len(self.samples),
639
            self.assertEqual(len(rows),len(self.samples),
640
                'cursor.fetchall did not retrieve all rows'
640
                'cursor.fetchall did not retrieve all rows'
641
                )
641
                )
...
...
651
                'cursor.fetchall should return an empty list if called '
651
                'cursor.fetchall should return an empty list if called '
652
                'after the whole result set has been fetched'
652
                'after the whole result set has been fetched'
653
                )
653
                )
654
            self.failUnless(cur.rowcount in (-1,len(self.samples)))
654
            self.failUnless(cur.rowcount in (-1,len(self.samples)),cur.rowcount)
655
655
656
            self.executeDDL2(cur)
656
            self.executeDDL2(cur)
657
            cur.execute('select name from %sbarflys' % self.table_prefix)
657
            cur.execute('select name from %sbarflys' % self.table_prefix)

Updated unittests/dbexceptions.py Download diff

2526
159
    def test_grant_privilege(self):
159
    def test_grant_privilege(self):
160
        con = self._connect()
160
        con = self._connect()
161
        cur = con.cursor()
161
        cur = con.cursor()
162
        q = "GRANT ALL ON weather to s000015"
162
        q = "GRANT ALL ON %sweather to s000043" % self.table_prefix
163
        self.assertRaises(self.driver.ProgrammingError, cur.execute, q)
163
        self.assertRaises(self.driver.ProgrammingError, cur.execute, q)
164
164
165
    def test_closed_connection(self):
165
    def test_closed_connection(self):
166
        con = self._connect()
166
        con = self._connect()
167
        cur = con.cursor()
167
        cur = con.cursor()
168
        self.executeDDL1(cur)
168
        self.executeDDL1(cur)
169
        q = "SELECT * FROM  dbexctest_weather"
169
        q = "SELECT * FROM  %sweather" % self.table_prefix
170
        con.close()
170
        con.close()
171
        self.assertRaises(self.driver.ProgrammingError, cur.execute, q)
171
        self.assertRaises(self.driver.ProgrammingError, cur.execute, q)
172
172
...
...
174
        con = self._connect()
174
        con = self._connect()
175
        cur = con.cursor()
175
        cur = con.cursor()
176
        self.executeDDL1(cur)
176
        self.executeDDL1(cur)
177
        q = "SELECT * FROM  dbexctest_weather"
177
        q = "SELECT * FROM  %sweather" % self.table_prefix
178
        con.close()
178
        con.close()
179
        self.assertRaises(self.driver.ProgrammingError, con.commit)
179
        self.assertRaises(self.driver.ProgrammingError, con.commit)
180
180
...
...
187
        con = self._connect()
187
        con = self._connect()
188
        cur = con.cursor()
188
        cur = con.cursor()
189
        self.executeDDL1(cur)
189
        self.executeDDL1(cur)
190
        q="INSERT INTO weather VALUE ('San Francisco', 46, 50, 0.25, '1994-11-27');"
190
        q="INSERT INTO %sweather VALUE ('San Francisco', 46, 50, 0.25, '1994-11-27');"%\
191
                                                           self.table_prefix
191
        self.assertRaises(self.driver.ProgrammingError, cur.execute,q)
192
        self.assertRaises(self.driver.ProgrammingError, cur.execute,q)
192
193
193
    def test_fetchone_before_select_query(self):
194
    def test_fetchone_before_select_query(self):
...
...
209
        con = self._connect()
210
        con = self._connect()
210
        cur = con.cursor()
211
        cur = con.cursor()
211
        self.executeDDL1(cur)
212
        self.executeDDL1(cur)
212
        q="INSERT INTO weather VALUES ('San Francisco', 46, 50, 0.25, '1994-11-27');"
213
        q="INSERT INTO %sweather VALUES ('San Francisco', 46, 50, 0.25, '1994-11-27');"%\
214
                                                                  self.table_prefix
213
        cur.execute(q)
215
        cur.execute(q)
214
        self.assertRaises(self.driver.ProgrammingError,cur.fetchone)
216
        self.assertRaises(self.driver.ProgrammingError,cur.fetchone)
215
217
...
...
217
        con = self._connect()
219
        con = self._connect()
218
        cur = con.cursor()
220
        cur = con.cursor()
219
        self.executeDDL1(cur)
221
        self.executeDDL1(cur)
220
        q="INSERT INTO weather VALUES ('San Francisco', 46, 50, 0.25, '1994-11-27');"
222
        q="INSERT INTO %sweather VALUES ('San Francisco', 46, 50, 0.25, '1994-11-27');"%\
223
                                                                 self.table_prefix
221
        cur.execute(q)
224
        cur.execute(q)
222
        self.assertRaises(self.driver.ProgrammingError,cur.fetchmany, 10)
225
        self.assertRaises(self.driver.ProgrammingError,cur.fetchmany, 10)
223
226
...
...
225
        con = self._connect()
228
        con = self._connect()
226
        cur = con.cursor()
229
        cur = con.cursor()
227
        self.executeDDL1(cur)
230
        self.executeDDL1(cur)
228
        q="INSERT INTO weather VALUES ('San Francisco', 46, 50, 0.25, '1994-11-27');"
231
        q="INSERT INTO %sweather VALUES ('San Francisco', 46, 50, 0.25, '1994-11-27');"%\
232
                                                                     self.table_prefix
229
        cur.execute(q)
233
        cur.execute(q)
230
        self.assertRaises(self.driver.ProgrammingError,cur.fetchall)
234
        self.assertRaises(self.driver.ProgrammingError,cur.fetchall)
231
235
...
...
265
        con = self._connect()
269
        con = self._connect()
266
        cur = con.cursor()
270
        cur = con.cursor()
267
        self.executeDDL1(cur)
271
        self.executeDDL1(cur)
268
        q="CREATE TABLE dbexctest_weather (city varchar(80);"
272
        q="CREATE TABLE %sweather (city varchar(80);"%self.table_prefix
269
        self.assertRaises(self.driver.ProgrammingError,cur.execute,q)
273
        self.assertRaises(self.driver.ProgrammingError,cur.execute,q)
270
274
271
    def test_copy_table_to_file(self):
275
    def test_copy_table_to_file(self):
272
        con = self._connect()
276
        con = self._connect()
273
        cur = con.cursor()
277
        cur = con.cursor()
274
        self.executeDDL1(cur)
278
        self.executeDDL1(cur)
275
        q="COPY weather TO 'xxx';"
279
        q="COPY %sweather TO 'xxx';"%self.table_prefix
276
        self.assertRaises(self.driver.ProgrammingError,cur.execute,q)
280
        self.assertRaises(self.driver.ProgrammingError,cur.execute,q)
277
281
278
    def test_copy_table_from_file(self):
282
    def test_copy_table_from_file(self):
279
        con = self._connect()
283
        con = self._connect()
280
        cur = con.cursor()
284
        cur = con.cursor()
281
        self.executeDDL1(cur)
285
        self.executeDDL1(cur)
282
        q="COPY weather FROM 'xxx';"
286
        q="COPY %sweather FROM 'xxx';"%self.table_prefix
283
        self.assertRaises(self.driver.ProgrammingError,cur.execute,q)
287
        self.assertRaises(self.driver.ProgrammingError,cur.execute,q)

Updated unittests/test_rdbhdb_autorefill.py Download diff

2526
14
14
15
    connect_args = ()
15
    connect_args = ()
16
    connect_kw_args = {
16
    connect_kw_args = {
17
        'role' : 's000015',
17
        'role' : 's000043',
18
        'authcode' : "KF7IUQPlwfSth4sBvjdqqanHkojAZzEjMshrkfEV0O53yz6w6v" }
18
        'authcode' : "AAGDKHnL4VEAPoeFhtNLDXtdOjRxfo0dAePFgPReSpED0aCOhL" }
19
19
20
    lower_func = 'lower' # For stored procedure test
20
    lower_func = 'lower' # For stored procedure test
21
21

Updated unittests/test_rdbhdb_dbapi20.py Download diff

2526
10
    driver = rdbhdb
10
    driver = rdbhdb
11
    connect_args = ()
11
    connect_args = ()
12
    connect_kw_args = {
12
    connect_kw_args = {
13
        'role' : 's000015',
13
        'role' : 's000043',
14
        'authcode' : "KF7IUQPlwfSth4sBvjdqqanHkojAZzEjMshrkfEV0O53yz6w6v" }
14
        'authcode' : "AAGDKHnL4VEAPoeFhtNLDXtdOjRxfo0dAePFgPReSpED0aCOhL" }
15
15
16
    lower_func = 'lower' # For stored procedure test
16
    lower_func = 'lower' # For stored procedure test
17
17

Updated unittests/test_rdbhdb_dbapi20_ar.py Download diff

2526
10
    driver = rdbhdb
10
    driver = rdbhdb
11
    connect_args = ()
11
    connect_args = ()
12
    connect_kw_args = {
12
    connect_kw_args = {
13
        'role' : 's000015',
13
        'role' : 's000043',
14
        'authcode' : "KF7IUQPlwfSth4sBvjdqqanHkojAZzEjMshrkfEV0O53yz6w6v" }
14
        'authcode' : "AAGDKHnL4VEAPoeFhtNLDXtdOjRxfo0dAePFgPReSpED0aCOhL" }
15
15
16
    lower_func = 'lower' # For stored procedure test
16
    lower_func = 'lower' # For stored procedure test
17
17

Updated unittests/test_rdbhdb_exceptions.py Download diff

2526
10
    driver = rdbhdb
10
    driver = rdbhdb
11
    connect_args = ()
11
    connect_args = ()
12
    connect_kw_args = {
12
    connect_kw_args = {
13
        'role' : 's000015',
13
        'role' : 's000043',
14
        'authcode' : "KF7IUQPlwfSth4sBvjdqqanHkojAZzEjMshrkfEV0O53yz6w6v" }
14
        'authcode' : "AAGDKHnL4VEAPoeFhtNLDXtdOjRxfo0dAePFgPReSpED0aCOhL" }
15
15
16
    lower_func = 'lower' # For stored procedure test
16
    lower_func = 'lower' # For stored procedure test
17
17

Updated unittests/test_rdbhdb_extensions.py Download diff

2526
14
14
15
    connect_args = ()
15
    connect_args = ()
16
    connect_kw_args = {
16
    connect_kw_args = {
17
        'role' : 's000015',
17
        'role' : 's000043',
18
        'authcode' : "KF7IUQPlwfSth4sBvjdqqanHkojAZzEjMshrkfEV0O53yz6w6v" }
18
        'authcode' : "AAGDKHnL4VEAPoeFhtNLDXtdOjRxfo0dAePFgPReSpED0aCOhL" }
19
19
20
    lower_func = 'lower' # For stored procedure test
20
    lower_func = 'lower' # For stored procedure test
21
21

Updated unittests/test_rdbhdb_extras.py Download diff

2526
13
13
14
    connect_args = ()
14
    connect_args = ()
15
    connect_kw_args = {
15
    connect_kw_args = {
16
        'role' : 's000015',
16
        'role' : 's000043',
17
        'authcode' : "KF7IUQPlwfSth4sBvjdqqanHkojAZzEjMshrkfEV0O53yz6w6v" }
17
        'authcode' : "AAGDKHnL4VEAPoeFhtNLDXtdOjRxfo0dAePFgPReSpED0aCOhL" }
18
18
19
    lower_func = 'lower' # For stored procedure test
19
    lower_func = 'lower' # For stored procedure test
20
20

Updated unittests/test_rdbhdb_sql.py Download diff

2526
14
14
15
    connect_args = ()
15
    connect_args = ()
16
    connect_kw_args = {
16
    connect_kw_args = {
17
        'role' : 's000015',
17
        'role' : 's000043',
18
        'authcode' : "KF7IUQPlwfSth4sBvjdqqanHkojAZzEjMshrkfEV0O53yz6w6v" }
18
        'authcode' : "AAGDKHnL4VEAPoeFhtNLDXtdOjRxfo0dAePFgPReSpED0aCOhL" }
19
19
20
    table_prefix = 'extras_' # If you need to specify a prefix for tables
20
    table_prefix = 'extras_' # If you need to specify a prefix for tables
21
21