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