@@ -53,6 +53,15 @@ def testPool(self):
5353 self .assertEqual (pool .busy , 2 , "busy not 2 after release" )
5454 del connection_2
5555 self .assertEqual (pool .busy , 1 , "busy not 1 after del" )
56+ pool .getmode = cx_Oracle .SPOOL_ATTRVAL_NOWAIT
57+ self .assertEqual (pool .getmode , cx_Oracle .SPOOL_ATTRVAL_NOWAIT )
58+ pool .stmtcachesize = 50
59+ self .assertEqual (pool .stmtcachesize , 50 )
60+ pool .timeout = 10
61+ self .assertEqual (pool .timeout , 10 )
62+ if CLIENT_VERSION >= (12 , 1 ):
63+ pool .max_lifetime_session = 10
64+ self .assertEqual (pool .max_lifetime_session , 10 )
5665
5766 def testProxyAuth (self ):
5867 """test that proxy authentication is possible"""
@@ -135,3 +144,40 @@ def testThreadingWithErrors(self):
135144 for thread in threads :
136145 thread .join ()
137146
147+ def testPurity (self ):
148+ """test session pool with various types of purity"""
149+ action = "TEST_ACTION"
150+ pool = cx_Oracle .SessionPool (USERNAME , PASSWORD , TNSENTRY , min = 1 ,
151+ max = 8 , increment = 1 , encoding = ENCODING ,
152+ nencoding = NENCODING )
153+
154+ # get connection and set the action
155+ connection = pool .acquire ()
156+ connection .action = action
157+ cursor = connection .cursor ()
158+ cursor .execute ("select 1 from dual" )
159+ cursor .close ()
160+ pool .release (connection )
161+ self .assertEqual (pool .opened , 1 , "opened (1)" )
162+
163+ # verify that the connection still has the action set on it
164+ connection = pool .acquire ()
165+ cursor = connection .cursor ()
166+ cursor .execute ("select sys_context('userenv', 'action') from dual" )
167+ result , = cursor .fetchone ()
168+ self .assertEqual (result , action )
169+ cursor .close ()
170+ pool .release (connection )
171+ self .assertEqual (pool .opened , 1 , "opened (2)" )
172+
173+ # get a new connection with new purity (should not have state)
174+ connection = pool .acquire (purity = cx_Oracle .ATTR_PURITY_NEW )
175+ cursor = connection .cursor ()
176+ cursor .execute ("select sys_context('userenv', 'action') from dual" )
177+ result , = cursor .fetchone ()
178+ self .assertEqual (result , None )
179+ cursor .close ()
180+ self .assertEqual (pool .opened , 2 , "opened (3)" )
181+ pool .drop (connection )
182+ self .assertEqual (pool .opened , 1 , "opened (4)" )
183+
0 commit comments