Skip to content

Commit 2d33fec

Browse files
Test suite improvements.
1 parent 9db9d69 commit 2d33fec

6 files changed

+43
-22
lines changed

test/sql/setup_test_exec.sql

+8-2
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,21 @@ create table &main_user..TestXML (
172172
)
173173
/
174174

175+
create table &main_user..TestTempXML (
176+
IntCol number(9) not null,
177+
XMLCol xmltype not null
178+
)
179+
/
180+
175181
create table &main_user..TestLongs (
176182
IntCol number(9) not null,
177-
LongCol long not null
183+
LongCol long
178184
) nocompress
179185
/
180186

181187
create table &main_user..TestLongRaws (
182188
IntCol number(9) not null,
183-
LongRawCol long raw not null
189+
LongRawCol long raw
184190
) nocompress
185191
/
186192

test/test_1900_lob_var.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class TestCase(test_env.BaseTestCase):
1919
def __get_temp_lobs(self, sid):
2020
cursor = self.connection.cursor()
2121
cursor.execute("""
22-
select abstract_lobs
22+
select cache_lobs + nocache_lobs + abstract_lobs
2323
from v$temporary_lobs
2424
where sid = :sid""", sid = sid)
2525
row = cursor.fetchone()

test/test_2000_long_var.py

+23-16
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,27 @@ class TestCase(test_env.BaseTestCase):
1919
def __perform_test(self, typ):
2020
name_part = "Long" if typ is oracledb.DB_TYPE_LONG else "LongRaw"
2121

22-
self.cursor.execute("truncate table Test%ss" % name_part)
22+
self.cursor.execute(f"truncate table Test{name_part}s")
23+
self.cursor.setinputsizes(long_string=typ)
2324
long_string = ""
2425
for i in range(1, 11):
2526
char = chr(ord('A') + i - 1)
2627
long_string += char * 25000
27-
self.cursor.setinputsizes(long_string=typ)
28-
if typ is oracledb.DB_TYPE_LONG_RAW:
29-
bind_value = long_string.encode()
28+
if i % 3 == 1:
29+
bind_value = None
3030
else:
31-
bind_value = long_string
32-
self.cursor.execute("""
33-
insert into Test%ss (
31+
if typ is oracledb.DB_TYPE_LONG_RAW:
32+
bind_value = long_string.encode()
33+
else:
34+
bind_value = long_string
35+
self.cursor.execute(f"""
36+
insert into Test{name_part}s (
3437
IntCol,
35-
%sCol
38+
{name_part}Col
3639
) values (
3740
:integer_value,
3841
:long_string
39-
)""" % (name_part, name_part),
42+
)""",
4043
integer_value=i,
4144
long_string=bind_value)
4245
self.connection.commit()
@@ -48,12 +51,16 @@ def __perform_test(self, typ):
4851
for integer_value, fetched_value in self.cursor:
4952
char = chr(ord('A') + integer_value - 1)
5053
long_string += char * 25000
51-
if typ is oracledb.DB_TYPE_LONG_RAW:
52-
actual_value = long_string.encode()
54+
if integer_value % 3 == 1:
55+
expected_value = None
5356
else:
54-
actual_value = long_string
55-
self.assertEqual(len(fetched_value), integer_value * 25000)
56-
self.assertEqual(fetched_value, actual_value)
57+
if typ is oracledb.DB_TYPE_LONG_RAW:
58+
expected_value = long_string.encode()
59+
else:
60+
expected_value = long_string
61+
if fetched_value is not None:
62+
self.assertEqual(len(fetched_value), integer_value * 25000)
63+
self.assertEqual(fetched_value, expected_value)
5764

5865
def test_2000_longs(self):
5966
"2000 - test binding and fetching long data"
@@ -82,7 +89,7 @@ def test_2003_long_cursor_description(self):
8289
self.cursor.execute("select * from TestLongs")
8390
expected_value = [
8491
('INTCOL', oracledb.DB_TYPE_NUMBER, 10, None, 9, 0, False),
85-
('LONGCOL', oracledb.DB_TYPE_LONG, None, None, None, None, False)
92+
('LONGCOL', oracledb.DB_TYPE_LONG, None, None, None, None, True)
8693
]
8794
self.assertEqual(self.cursor.description, expected_value)
8895

@@ -92,7 +99,7 @@ def test_2004_long_raw_cursor_description(self):
9299
expected_value = [
93100
('INTCOL', oracledb.DB_TYPE_NUMBER, 10, None, 9, 0, False),
94101
('LONGRAWCOL', oracledb.DB_TYPE_LONG_RAW, None, None, None, None,
95-
False)
102+
True)
96103
]
97104
self.assertEqual(self.cursor.description, expected_value)
98105

test/test_2500_string_var.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -427,11 +427,11 @@ def test_2531_long_xml_as_string(self):
427427
random_string = ''.join(random.choice(chars) for _ in range(1024))
428428
int_val = 200
429429
xml_string = '<data>' + random_string + '</data>'
430-
self.cursor.execute("truncate table TestXML")
430+
self.cursor.execute("truncate table TestTempXML")
431431
self.cursor.execute("""
432-
insert into TestXML (IntCol, XMLCol)
432+
insert into TestTempXML (IntCol, XMLCol)
433433
values (:1, :2)""", (int_val, xml_string))
434-
self.cursor.execute("select XMLCol from TestXML where intCol = :1",
434+
self.cursor.execute("select XMLCol from TestTempXML where intCol = :1",
435435
(int_val,))
436436
actual_value, = self.cursor.fetchone()
437437
self.assertEqual(actual_value.strip(), xml_string)

test/test_3400_soda_collection.py

+2
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,8 @@ def test_3413_soda_truncate(self):
301301
self.assertEqual(coll.find().count(), 0)
302302
coll.drop()
303303

304+
@unittest.skipIf(test_env.skip_client_version_old_multi((19, 11), (21, 3)),
305+
"unsupported client")
304306
def test_3414_soda_hint(self):
305307
"3414 - verify hints are reflected in the executed SQL statement"
306308
soda_db = self.connection.getSodaDatabase()

test/test_env.py

+6
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,12 @@ def run_test_cases():
197197
print()
198198
unittest.main(testRunner=unittest.TextTestRunner(verbosity=2))
199199

200+
def skip_client_version_old_multi(min_version1, min_version2):
201+
ver = get_client_version()
202+
return ver < min_version1 or \
203+
(ver[0] > min_version1[0] and ver[0] < min_version2[0]) or \
204+
(ver[0] == min_version2[0] and ver[1] < min_version2[1])
205+
200206
def skip_soda_tests():
201207
client = get_client_version()
202208
if client < (18, 3):

0 commit comments

Comments
 (0)