33import pytest
44import asyncio
55from cx_Oracle_async import *
6+ import time
67
78@pytest .mark .asyncio
89async def test_different_connect_ways ():
@@ -35,4 +36,51 @@ async def test_different_connect_ways():
3536
3637 ret = await oracle_pool .close ()
3738 assert ret == None
38-
39+
40+ @pytest .mark .asyncio
41+ async def test_properties ():
42+ INAQ = 0.5
43+ dsn = makedsn (
44+ host = 'localhost' ,
45+ port = '1521' ,
46+ sid = 'xe'
47+ )
48+ oracle_pool = await create_pool (
49+ user = 'system' ,
50+ password = 'oracle' ,
51+ dsn = dsn
52+ )
53+
54+ async with oracle_pool .acquire () as conn :
55+ st_time = time .time ()
56+ conn .module = 'hello world'
57+ conn .action = 'test_action'
58+ conn .client_identifier = 'test_identifier'
59+ conn .clientinfo = 'test_info'
60+ ed_time = time .time ()
61+ assert (ed_time - st_time ) <= INAQ
62+
63+ async with conn .cursor () as cursor :
64+ await cursor .execute ("SELECT SID, MODULE ,ACTION ,CLIENT_IDENTIFIER , CLIENT_INFO FROM V$SESSION WHERE MODULE='hello world'" )
65+ r = await cursor .fetchall ()
66+ assert len (r ) == 1
67+ _ , _module , _action , _ciden , _cinfo = r [0 ]
68+ assert _module == 'hello world'
69+ assert _action == 'test_action'
70+ assert _ciden == 'test_identifier'
71+ assert _cinfo == 'test_info'
72+
73+ # test no update
74+ st_time = time .time ()
75+ conn .module = 'hello world2'
76+ conn .action = 'test_action2'
77+ conn .client_identifier = 'test_identifier2'
78+ conn .clientinfo = 'test_info2'
79+ ed_time = time .time ()
80+ assert (ed_time - st_time ) <= INAQ
81+
82+ conn2 = await oracle_pool .acquire ()
83+ async with conn2 .cursor () as cursor :
84+ await cursor .execute ("SELECT SID, MODULE ,ACTION ,CLIENT_IDENTIFIER , CLIENT_INFO FROM V$SESSION WHERE MODULE='hello world2'" )
85+ r = await cursor .fetchall ()
86+ assert len (r ) == 0
0 commit comments