Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
sqlite3.test.userfunctions.AggregateTests Class Reference

List of all members.

Public Member Functions

def setUp
def tearDown
def CheckAggrErrorOnCreate
def CheckAggrNoStep
def CheckAggrNoFinalize
def CheckAggrExceptionInInit
def CheckAggrExceptionInStep
def CheckAggrExceptionInFinalize
def CheckAggrCheckParamStr
def CheckAggrCheckParamInt
def CheckAggrCheckParamFloat
def CheckAggrCheckParamNone
def CheckAggrCheckParamBlob
def CheckAggrCheckAggrSum

Public Attributes

 con

Detailed Description

Definition at line 242 of file userfunctions.py.


Member Function Documentation

Definition at line 352 of file userfunctions.py.

00352 
00353     def CheckAggrCheckAggrSum(self):
00354         cur = self.con.cursor()
00355         cur.execute("delete from test")
00356         cur.executemany("insert into test(i) values (?)", [(10,), (20,), (30,)])
00357         cur.execute("select mysum(i) from test")
00358         val = cur.fetchone()[0]
00359         self.assertEqual(val, 60)

Here is the call graph for this function:

Definition at line 346 of file userfunctions.py.

00346 
00347     def CheckAggrCheckParamBlob(self):
00348         cur = self.con.cursor()
00349         cur.execute("select checkType('blob', ?)", (memoryview(b"blob"),))
00350         val = cur.fetchone()[0]
00351         self.assertEqual(val, 1)

Here is the call graph for this function:

Definition at line 334 of file userfunctions.py.

00334 
00335     def CheckAggrCheckParamFloat(self):
00336         cur = self.con.cursor()
00337         cur.execute("select checkType('float', ?)", (3.14,))
00338         val = cur.fetchone()[0]
00339         self.assertEqual(val, 1)

Here is the call graph for this function:

Definition at line 328 of file userfunctions.py.

00328 
00329     def CheckAggrCheckParamInt(self):
00330         cur = self.con.cursor()
00331         cur.execute("select checkType('int', ?)", (42,))
00332         val = cur.fetchone()[0]
00333         self.assertEqual(val, 1)

Here is the call graph for this function:

Definition at line 340 of file userfunctions.py.

00340 
00341     def CheckAggrCheckParamNone(self):
00342         cur = self.con.cursor()
00343         cur.execute("select checkType('None', ?)", (None,))
00344         val = cur.fetchone()[0]
00345         self.assertEqual(val, 1)

Here is the call graph for this function:

Definition at line 322 of file userfunctions.py.

00322 
00323     def CheckAggrCheckParamStr(self):
00324         cur = self.con.cursor()
00325         cur.execute("select checkType('str', ?)", ("foo",))
00326         val = cur.fetchone()[0]
00327         self.assertEqual(val, 1)

Here is the call graph for this function:

Definition at line 271 of file userfunctions.py.

00271 
00272     def CheckAggrErrorOnCreate(self):
00273         try:
00274             self.con.create_function("bla", -100, AggrSum)
00275             self.fail("should have raised an OperationalError")
00276         except sqlite.OperationalError:
00277             pass

Here is the call graph for this function:

Definition at line 313 of file userfunctions.py.

00313 
00314     def CheckAggrExceptionInFinalize(self):
00315         cur = self.con.cursor()
00316         try:
00317             cur.execute("select excFinalize(t) from test")
00318             val = cur.fetchone()[0]
00319             self.fail("should have raised an OperationalError")
00320         except sqlite.OperationalError as e:
00321             self.assertEqual(e.args[0], "user-defined aggregate's 'finalize' method raised error")

Here is the call graph for this function:

Definition at line 295 of file userfunctions.py.

00295 
00296     def CheckAggrExceptionInInit(self):
00297         cur = self.con.cursor()
00298         try:
00299             cur.execute("select excInit(t) from test")
00300             val = cur.fetchone()[0]
00301             self.fail("should have raised an OperationalError")
00302         except sqlite.OperationalError as e:
00303             self.assertEqual(e.args[0], "user-defined aggregate's '__init__' method raised error")

Here is the call graph for this function:

Definition at line 304 of file userfunctions.py.

00304 
00305     def CheckAggrExceptionInStep(self):
00306         cur = self.con.cursor()
00307         try:
00308             cur.execute("select excStep(t) from test")
00309             val = cur.fetchone()[0]
00310             self.fail("should have raised an OperationalError")
00311         except sqlite.OperationalError as e:
00312             self.assertEqual(e.args[0], "user-defined aggregate's 'step' method raised error")

Here is the call graph for this function:

Definition at line 286 of file userfunctions.py.

00286 
00287     def CheckAggrNoFinalize(self):
00288         cur = self.con.cursor()
00289         try:
00290             cur.execute("select nofinalize(t) from test")
00291             val = cur.fetchone()[0]
00292             self.fail("should have raised an OperationalError")
00293         except sqlite.OperationalError as e:
00294             self.assertEqual(e.args[0], "user-defined aggregate's 'finalize' method raised error")

Here is the call graph for this function:

Definition at line 278 of file userfunctions.py.

00278 
00279     def CheckAggrNoStep(self):
00280         cur = self.con.cursor()
00281         try:
00282             cur.execute("select nostep(t) from test")
00283             self.fail("should have raised an AttributeError")
00284         except AttributeError as e:
00285             self.assertEqual(e.args[0], "'AggrNoStep' object has no attribute 'step'")

Here is the call graph for this function:

Definition at line 243 of file userfunctions.py.

00243 
00244     def setUp(self):
00245         self.con = sqlite.connect(":memory:")
00246         cur = self.con.cursor()
00247         cur.execute("""
00248             create table test(
00249                 t text,
00250                 i integer,
00251                 f float,
00252                 n,
00253                 b blob
00254                 )
00255             """)
00256         cur.execute("insert into test(t, i, f, n, b) values (?, ?, ?, ?, ?)",
00257             ("foo", 5, 3.14, None, memoryview(b"blob"),))
00258 
00259         self.con.create_aggregate("nostep", 1, AggrNoStep)
00260         self.con.create_aggregate("nofinalize", 1, AggrNoFinalize)
00261         self.con.create_aggregate("excInit", 1, AggrExceptionInInit)
00262         self.con.create_aggregate("excStep", 1, AggrExceptionInStep)
00263         self.con.create_aggregate("excFinalize", 1, AggrExceptionInFinalize)
00264         self.con.create_aggregate("checkType", 2, AggrCheckType)
00265         self.con.create_aggregate("mysum", 1, AggrSum)

Here is the caller graph for this function:

Definition at line 266 of file userfunctions.py.

00266 
00267     def tearDown(self):
00268         #self.cur.close()
00269         #self.con.close()
00270         pass

Here is the caller graph for this function:


Member Data Documentation

Definition at line 244 of file userfunctions.py.


The documentation for this class was generated from the following file: