Skip to content

Commit f987c6d

Browse files
Test improvements.
1 parent b94d10b commit f987c6d

File tree

4 files changed

+80
-4
lines changed

4 files changed

+80
-4
lines changed

tests/test_1100_connection.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -----------------------------------------------------------------------------
2-
# Copyright (c) 2020, 2024, Oracle and/or its affiliates.
2+
# Copyright (c) 2020, 2025, Oracle and/or its affiliates.
33
#
44
# This software is dual-licensed to you under the Universal Permissive License
55
# (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
@@ -954,6 +954,30 @@ def hook(params):
954954
conn = test_env.get_connection()
955955
self.assertEqual(conn.stmtcachesize, orig_stmtcachesize)
956956

957+
def test_1157(self):
958+
"1157 - test connect() with multiple parameters hooks"
959+
960+
def hook1(params):
961+
order.append("first")
962+
963+
def hook2(params):
964+
order.append("second")
965+
966+
def hook3(params):
967+
order.append("third")
968+
969+
oracledb.register_params_hook(hook1)
970+
oracledb.register_params_hook(hook2)
971+
oracledb.register_params_hook(hook3)
972+
try:
973+
order = []
974+
test_env.get_connection()
975+
self.assertEqual(order, ["first", "second", "third"])
976+
finally:
977+
oracledb.unregister_params_hook(hook1)
978+
oracledb.unregister_params_hook(hook2)
979+
oracledb.unregister_params_hook(hook3)
980+
957981

958982
if __name__ == "__main__":
959983
test_env.run_test_cases()

tests/test_3400_soda_collection.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -----------------------------------------------------------------------------
2-
# Copyright (c) 2020, 2024, Oracle and/or its affiliates.
2+
# Copyright (c) 2020, 2025, Oracle and/or its affiliates.
33
#
44
# This software is dual-licensed to you under the Universal Permissive License
55
# (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
@@ -360,6 +360,10 @@ def test_3413(self):
360360
coll.truncate()
361361
self.assertEqual(coll.find().count(), 0)
362362

363+
@unittest.skipIf(
364+
test_env.get_client_version() < (19, 11),
365+
"client version not supported.. min required 19.11",
366+
)
363367
def test_3414(self):
364368
"3414 - verify hints are reflected in the executed SQL statement"
365369
soda_db = self.get_soda_database()
@@ -755,6 +759,10 @@ def test_3434(self):
755759
with self.assertRaisesFullCode("ORA-40734"):
756760
coll.find().keys(keys).replaceOneAndGet({"data": "new"})
757761

762+
@unittest.skipIf(
763+
test_env.get_client_version() < (19, 9),
764+
"client version not supported.. min required 19.9",
765+
)
758766
def test_3435(self):
759767
"3435 - test writting a read-only collection"
760768
soda_db = self.get_soda_database()

tests/test_6300_cursor_other_async.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ def type_handler(cursor, metadata):
575575

576576
@unittest.skipIf(test_env.get_is_drcp(), "not supported with DRCP")
577577
async def test_6335(self):
578-
"4535 - kill connection with open cursor"
578+
"6335 - kill connection with open cursor"
579579
admin_conn = await test_env.get_admin_connection_async()
580580
conn = await test_env.get_connection_async()
581581
self.assertEqual(conn.is_healthy(), True)
@@ -864,7 +864,7 @@ async def test_6350(self):
864864
self.assertEqual(fetched_value, value)
865865

866866
async def test_6351(self):
867-
"4360 - fetch JSON columns as Python objects"
867+
"6351 - fetch JSON columns as Python objects"
868868
expected_data = [
869869
(1, [1, 2, 3], [4, 5, 6], [7, 8, 9]),
870870
(2, None, None, None),

tests/test_8000_dataframe.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,50 @@ def test_8017(self):
476476
DATASET_2, batch_size=len(DATASET_2), num_batches=1
477477
)
478478

479+
def test_8018(self):
480+
"8018 - verify get_column() returns the correct value"
481+
self.__check_interop()
482+
self.__populate_table(DATASET_1)
483+
statement = "select * from TestDataFrame order by Id"
484+
ora_df = self.conn.fetch_df_all(statement)
485+
array = pyarrow.array(ora_df.get_column(1))
486+
self.assertEqual(array.to_pylist(), ["John", "Big"])
487+
488+
def test_8019(self):
489+
"8019 - verify OracleColumn and get_buffers"
490+
self.__populate_table(DATASET_1)
491+
statement = "select * from TestDataFrame order by Id"
492+
ora_df = self.conn.fetch_df_all(statement)
493+
ora_col = ora_df.get_column(1)
494+
self.assertEqual(ora_col.num_chunks(), 1)
495+
self.assertEqual(ora_col.size(), 2)
496+
497+
buffers = ora_col.get_buffers()
498+
self.assertEqual(len(buffers), 3)
499+
self.assertIsNotNone(buffers["data"])
500+
self.assertIsNotNone(buffers["offsets"])
501+
self.assertIsNone(buffers["validity"])
502+
503+
def test_8020(self):
504+
"8020 - verify OracleColumn Attributes"
505+
self.__populate_table(DATASET_2)
506+
statement = "select * from TestDataFrame order by Id"
507+
ora_df = self.conn.fetch_df_all(statement)
508+
509+
ora_col = ora_df.get_column(0)
510+
self.assertEqual(ora_col.describe_null[0], 0)
511+
self.assertEqual(ora_col.dtype[0], 0)
512+
metadata = {"name": "ID", "size": 2, "num_chunks": 1}
513+
self.assertEqual(metadata, ora_col.metadata)
514+
self.assertEqual(ora_col.null_count, 0)
515+
516+
ora_col = ora_df.get_column(4)
517+
self.assertEqual(ora_col.describe_null[0], 3)
518+
self.assertEqual(ora_col.dtype[0], 21)
519+
metadata = {"name": "COUNTRY", "size": 2, "num_chunks": 1}
520+
self.assertEqual(metadata, ora_col.metadata)
521+
self.assertEqual(ora_col.null_count, 1)
522+
479523

480524
if __name__ == "__main__":
481525
test_env.run_test_cases()

0 commit comments

Comments
 (0)