Test suite improvements.
This commit is contained in:
parent
9db9d6907a
commit
2d33fec37a
@ -172,15 +172,21 @@ create table &main_user..TestXML (
|
||||
)
|
||||
/
|
||||
|
||||
create table &main_user..TestTempXML (
|
||||
IntCol number(9) not null,
|
||||
XMLCol xmltype not null
|
||||
)
|
||||
/
|
||||
|
||||
create table &main_user..TestLongs (
|
||||
IntCol number(9) not null,
|
||||
LongCol long not null
|
||||
LongCol long
|
||||
) nocompress
|
||||
/
|
||||
|
||||
create table &main_user..TestLongRaws (
|
||||
IntCol number(9) not null,
|
||||
LongRawCol long raw not null
|
||||
LongRawCol long raw
|
||||
) nocompress
|
||||
/
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ class TestCase(test_env.BaseTestCase):
|
||||
def __get_temp_lobs(self, sid):
|
||||
cursor = self.connection.cursor()
|
||||
cursor.execute("""
|
||||
select abstract_lobs
|
||||
select cache_lobs + nocache_lobs + abstract_lobs
|
||||
from v$temporary_lobs
|
||||
where sid = :sid""", sid = sid)
|
||||
row = cursor.fetchone()
|
||||
|
||||
@ -19,24 +19,27 @@ class TestCase(test_env.BaseTestCase):
|
||||
def __perform_test(self, typ):
|
||||
name_part = "Long" if typ is oracledb.DB_TYPE_LONG else "LongRaw"
|
||||
|
||||
self.cursor.execute("truncate table Test%ss" % name_part)
|
||||
self.cursor.execute(f"truncate table Test{name_part}s")
|
||||
self.cursor.setinputsizes(long_string=typ)
|
||||
long_string = ""
|
||||
for i in range(1, 11):
|
||||
char = chr(ord('A') + i - 1)
|
||||
long_string += char * 25000
|
||||
self.cursor.setinputsizes(long_string=typ)
|
||||
if typ is oracledb.DB_TYPE_LONG_RAW:
|
||||
bind_value = long_string.encode()
|
||||
if i % 3 == 1:
|
||||
bind_value = None
|
||||
else:
|
||||
bind_value = long_string
|
||||
self.cursor.execute("""
|
||||
insert into Test%ss (
|
||||
if typ is oracledb.DB_TYPE_LONG_RAW:
|
||||
bind_value = long_string.encode()
|
||||
else:
|
||||
bind_value = long_string
|
||||
self.cursor.execute(f"""
|
||||
insert into Test{name_part}s (
|
||||
IntCol,
|
||||
%sCol
|
||||
{name_part}Col
|
||||
) values (
|
||||
:integer_value,
|
||||
:long_string
|
||||
)""" % (name_part, name_part),
|
||||
)""",
|
||||
integer_value=i,
|
||||
long_string=bind_value)
|
||||
self.connection.commit()
|
||||
@ -48,12 +51,16 @@ class TestCase(test_env.BaseTestCase):
|
||||
for integer_value, fetched_value in self.cursor:
|
||||
char = chr(ord('A') + integer_value - 1)
|
||||
long_string += char * 25000
|
||||
if typ is oracledb.DB_TYPE_LONG_RAW:
|
||||
actual_value = long_string.encode()
|
||||
if integer_value % 3 == 1:
|
||||
expected_value = None
|
||||
else:
|
||||
actual_value = long_string
|
||||
self.assertEqual(len(fetched_value), integer_value * 25000)
|
||||
self.assertEqual(fetched_value, actual_value)
|
||||
if typ is oracledb.DB_TYPE_LONG_RAW:
|
||||
expected_value = long_string.encode()
|
||||
else:
|
||||
expected_value = long_string
|
||||
if fetched_value is not None:
|
||||
self.assertEqual(len(fetched_value), integer_value * 25000)
|
||||
self.assertEqual(fetched_value, expected_value)
|
||||
|
||||
def test_2000_longs(self):
|
||||
"2000 - test binding and fetching long data"
|
||||
@ -82,7 +89,7 @@ class TestCase(test_env.BaseTestCase):
|
||||
self.cursor.execute("select * from TestLongs")
|
||||
expected_value = [
|
||||
('INTCOL', oracledb.DB_TYPE_NUMBER, 10, None, 9, 0, False),
|
||||
('LONGCOL', oracledb.DB_TYPE_LONG, None, None, None, None, False)
|
||||
('LONGCOL', oracledb.DB_TYPE_LONG, None, None, None, None, True)
|
||||
]
|
||||
self.assertEqual(self.cursor.description, expected_value)
|
||||
|
||||
@ -92,7 +99,7 @@ class TestCase(test_env.BaseTestCase):
|
||||
expected_value = [
|
||||
('INTCOL', oracledb.DB_TYPE_NUMBER, 10, None, 9, 0, False),
|
||||
('LONGRAWCOL', oracledb.DB_TYPE_LONG_RAW, None, None, None, None,
|
||||
False)
|
||||
True)
|
||||
]
|
||||
self.assertEqual(self.cursor.description, expected_value)
|
||||
|
||||
|
||||
@ -427,11 +427,11 @@ class TestCase(test_env.BaseTestCase):
|
||||
random_string = ''.join(random.choice(chars) for _ in range(1024))
|
||||
int_val = 200
|
||||
xml_string = '<data>' + random_string + '</data>'
|
||||
self.cursor.execute("truncate table TestXML")
|
||||
self.cursor.execute("truncate table TestTempXML")
|
||||
self.cursor.execute("""
|
||||
insert into TestXML (IntCol, XMLCol)
|
||||
insert into TestTempXML (IntCol, XMLCol)
|
||||
values (:1, :2)""", (int_val, xml_string))
|
||||
self.cursor.execute("select XMLCol from TestXML where intCol = :1",
|
||||
self.cursor.execute("select XMLCol from TestTempXML where intCol = :1",
|
||||
(int_val,))
|
||||
actual_value, = self.cursor.fetchone()
|
||||
self.assertEqual(actual_value.strip(), xml_string)
|
||||
|
||||
@ -301,6 +301,8 @@ class TestCase(test_env.BaseTestCase):
|
||||
self.assertEqual(coll.find().count(), 0)
|
||||
coll.drop()
|
||||
|
||||
@unittest.skipIf(test_env.skip_client_version_old_multi((19, 11), (21, 3)),
|
||||
"unsupported client")
|
||||
def test_3414_soda_hint(self):
|
||||
"3414 - verify hints are reflected in the executed SQL statement"
|
||||
soda_db = self.connection.getSodaDatabase()
|
||||
|
||||
@ -197,6 +197,12 @@ def run_test_cases():
|
||||
print()
|
||||
unittest.main(testRunner=unittest.TextTestRunner(verbosity=2))
|
||||
|
||||
def skip_client_version_old_multi(min_version1, min_version2):
|
||||
ver = get_client_version()
|
||||
return ver < min_version1 or \
|
||||
(ver[0] > min_version1[0] and ver[0] < min_version2[0]) or \
|
||||
(ver[0] == min_version2[0] and ver[1] < min_version2[1])
|
||||
|
||||
def skip_soda_tests():
|
||||
client = get_client_version()
|
||||
if client < (18, 3):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user