Skip to content

Commit 2266892

Browse files
Further test improvements.
1 parent ca8e9c1 commit 2266892

9 files changed

+280
-212
lines changed

tests/test_1100_connection.py

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -201,16 +201,16 @@ def test_1109_parse_password(self):
201201
finally:
202202
conn.changepassword(new_password, test_env.get_main_password())
203203

204-
def test_1112_exception_on_close(self):
205-
"1112 - confirm an exception is raised after closing a connection"
204+
def test_1110_exception_on_close(self):
205+
"1110 - confirm an exception is raised after closing a connection"
206206
conn = test_env.get_connection()
207207
conn.close()
208208
self.assertRaisesRegex(oracledb.InterfaceError, "^DPY-1001:",
209209
conn.rollback)
210210

211211
@unittest.skipIf(test_env.get_is_thin(), "not relevant for thin mode")
212-
def test_1113_connect_with_handle(self):
213-
"1113 - test creating a connection using a handle"
212+
def test_1111_connect_with_handle(self):
213+
"1111 - test creating a connection using a handle"
214214
conn = test_env.get_connection()
215215
cursor = conn.cursor()
216216
cursor.execute("truncate table TestTempTable")
@@ -229,13 +229,13 @@ def test_1113_connect_with_handle(self):
229229
conn2.close)
230230
conn.close()
231231

232-
def test_1116_version(self):
233-
"1116 - connection version is a string"
232+
def test_1112_version(self):
233+
"1112 - connection version is a string"
234234
conn = test_env.get_connection()
235235
self.assertIsInstance(conn.version, str)
236236

237-
def test_1117_rollback_on_close(self):
238-
"1117 - connection rolls back before close"
237+
def test_1113_rollback_on_close(self):
238+
"1113 - connection rolls back before close"
239239
conn = test_env.get_connection()
240240
cursor = conn.cursor()
241241
cursor.execute("truncate table TestTempTable")
@@ -248,8 +248,8 @@ def test_1117_rollback_on_close(self):
248248
count, = cursor.fetchone()
249249
self.assertEqual(count, 0)
250250

251-
def test_1118_rollback_on_del(self):
252-
"1118 - connection rolls back before destruction"
251+
def test_1114_rollback_on_del(self):
252+
"1114 - connection rolls back before destruction"
253253
conn = test_env.get_connection()
254254
cursor = conn.cursor()
255255
cursor.execute("truncate table TestTempTable")
@@ -262,8 +262,8 @@ def test_1118_rollback_on_del(self):
262262
count, = cursor.fetchone()
263263
self.assertEqual(count, 0)
264264

265-
def test_1119_threading(self):
266-
"1119 - multiple connections to database with multiple threads"
265+
def test_1115_threading(self):
266+
"1115 - multiple connections to database with multiple threads"
267267
threads = []
268268
for i in range(20):
269269
thread = threading.Thread(None, self.__connect_and_drop)
@@ -273,15 +273,15 @@ def test_1119_threading(self):
273273
for thread in threads:
274274
thread.join()
275275

276-
def test_1120_string_format(self):
277-
"1120 - test string format of connection"
276+
def test_1116_string_format(self):
277+
"1116 - test string format of connection"
278278
conn = test_env.get_connection()
279279
expected_value = "<oracledb.Connection to %s@%s>" % \
280280
(test_env.get_main_user(), test_env.get_connect_string())
281281
self.assertEqual(str(conn), expected_value)
282282

283-
def test_1121_ctx_mgr_close(self):
284-
"1121 - test context manager - close"
283+
def test_1117_ctx_mgr_close(self):
284+
"1117 - test context manager - close"
285285
with test_env.get_connection() as conn:
286286
cursor = conn.cursor()
287287
cursor.execute("truncate table TestTempTable")
@@ -296,8 +296,8 @@ def test_1121_ctx_mgr_close(self):
296296
count, = cursor.fetchone()
297297
self.assertEqual(count, 1)
298298

299-
def test_1122_connection_attributes(self):
300-
"1122 - test connection attribute values"
299+
def test_1118_connection_attributes(self):
300+
"1118 - test connection attribute values"
301301
conn = test_env.get_connection()
302302
if test_env.get_client_version() >= (12, 1):
303303
self.assertEqual(conn.ltxid, b'')
@@ -314,8 +314,8 @@ def test_1122_connection_attributes(self):
314314
self.assertRaises(TypeError, conn.stmtcachesize, 20.5)
315315
self.assertRaises(TypeError, conn.stmtcachesize, "value")
316316

317-
def test_1123_closed_connection_attributes(self):
318-
"1123 - test closed connection attribute values"
317+
def test_1119_closed_connection_attributes(self):
318+
"1119 - test closed connection attribute values"
319319
conn = test_env.get_connection()
320320
conn.close()
321321
attr_names = ["current_schema", "edition", "external_name",
@@ -326,17 +326,17 @@ def test_1123_closed_connection_attributes(self):
326326
self.assertRaisesRegex(oracledb.InterfaceError, "^DPY-1001:",
327327
getattr, conn, name)
328328

329-
def test_1124_ping(self):
330-
"1124 - test connection ping makes a round trip"
329+
def test_1120_ping(self):
330+
"1120 - test connection ping makes a round trip"
331331
self.conn = test_env.get_connection()
332332
self.setup_round_trip_checker()
333333
self.conn.ping()
334334
self.assertRoundTrips(1)
335335

336336
@unittest.skipIf(test_env.get_is_thin(),
337337
"thin mode doesn't support two-phase commit yet")
338-
def test_1125_transaction_begin(self):
339-
"1125 - test begin, prepare, cancel transaction"
338+
def test_1121_transaction_begin(self):
339+
"1121 - test begin, prepare, cancel transaction"
340340
conn = test_env.get_connection()
341341
cursor = conn.cursor()
342342
cursor.execute("truncate table TestTempTable")
@@ -355,8 +355,8 @@ def test_1125_transaction_begin(self):
355355

356356
@unittest.skipIf(test_env.get_is_thin(),
357357
"thin mode doesn't support two-phase commit yet")
358-
def test_1126_multiple_transactions(self):
359-
"1126 - test multiple transactions on the same connection"
358+
def test_1122_multiple_transactions(self):
359+
"1122 - test multiple transactions on the same connection"
360360
conn = test_env.get_connection()
361361
with conn.cursor() as cursor:
362362
cursor.execute("truncate table TestTempTable")
@@ -389,8 +389,8 @@ def test_1126_multiple_transactions(self):
389389

390390
@unittest.skipIf(test_env.get_is_thin(),
391391
"thin mode doesn't support two-phase commit yet")
392-
def test_1127_multiple_global_transactions(self):
393-
"1127 - test multiple global transactions on the same connection"
392+
def test_1123_multiple_global_transactions(self):
393+
"1123 - test multiple global transactions on the same connection"
394394
conn = test_env.get_connection()
395395
with conn.cursor() as cursor:
396396
cursor.execute("truncate table TestTempTable")
@@ -434,8 +434,8 @@ def test_1127_multiple_global_transactions(self):
434434

435435
@unittest.skipIf(test_env.get_is_thin(),
436436
"thin mode doesn't support two-phase commit yet")
437-
def test_1128_exception_creating_global_txn_after_local_txn(self):
438-
"1128 - test creating global txn after a local txn"
437+
def test_1124_exception_creating_global_txn_after_local_txn(self):
438+
"1124 - test creating global txn after a local txn"
439439
conn = test_env.get_connection()
440440
with conn.cursor() as cursor:
441441
cursor.execute("truncate table TestTempTable")
@@ -450,8 +450,8 @@ def test_1128_exception_creating_global_txn_after_local_txn(self):
450450
self.assertRaisesRegex(oracledb.DatabaseError, "^ORA-24776:",
451451
conn.begin, *xid)
452452

453-
def test_1129_threading_single_connection(self):
454-
"1129 - single connection to database with multiple threads"
453+
def test_1125_threading_single_connection(self):
454+
"1125 - single connection to database with multiple threads"
455455
with test_env.get_connection() as conn:
456456
threads = [threading.Thread(target=self.__verify_fetched_data,
457457
args=(conn,)) for i in range(3)]
@@ -460,8 +460,8 @@ def test_1129_threading_single_connection(self):
460460
for t in threads:
461461
t.join()
462462

463-
def test_1130_cancel(self):
464-
"1130 - test connection cancel"
463+
def test_1126_cancel(self):
464+
"1126 - test connection cancel"
465465
conn = test_env.get_connection()
466466
sleep_proc_name = test_env.get_sleep_proc_name()
467467
def perform_cancel():
@@ -480,8 +480,8 @@ def perform_cancel():
480480
user, = cursor.fetchone()
481481
self.assertEqual(user, test_env.get_main_user().upper())
482482

483-
def test_1131_change_password_during_connect(self):
484-
"1131 - test changing password during connect"
483+
def test_1127_change_password_during_connect(self):
484+
"1127 - test changing password during connect"
485485
conn = test_env.get_connection()
486486
if self.is_on_oracle_cloud(conn):
487487
self.skipTest("passwords on Oracle Cloud are strictly controlled")
@@ -492,8 +492,8 @@ def test_1131_change_password_during_connect(self):
492492
conn = test_env.get_connection(password=new_password)
493493
conn.changepassword(new_password, test_env.get_main_password())
494494

495-
def test_1132_autocommit_during_reexecute(self):
496-
"1132 - test use of autocommit during reexecute"
495+
def test_1128_autocommit_during_reexecute(self):
496+
"1128 - test use of autocommit during reexecute"
497497
sql = "insert into TestTempTable (IntCol, StringCol1) values (:1, :2)"
498498
data_to_insert = [
499499
(1, "Test String #1"),
@@ -512,8 +512,8 @@ def test_1132_autocommit_during_reexecute(self):
512512
other_cursor.execute("select IntCol, StringCol1 from TestTempTable")
513513
self.assertEqual(other_cursor.fetchall(), data_to_insert)
514514

515-
def test_1133_current_schema(self):
516-
"1133 - test current_schema is set properly"
515+
def test_1129_current_schema(self):
516+
"1129 - test current_schema is set properly"
517517
conn = test_env.get_connection()
518518
self.assertIsNone(conn.current_schema)
519519

@@ -532,8 +532,8 @@ def test_1133_current_schema(self):
532532
result, = cursor.fetchone()
533533
self.assertEqual(result, user)
534534

535-
def test_1134_dbms_output(self):
536-
"1134 - test dbms_output package"
535+
def test_1130_dbms_output(self):
536+
"1130 - test dbms_output package"
537537
conn = test_env.get_connection()
538538
cursor = conn.cursor()
539539
test_string = "Testing DBMS_OUTPUT package"
@@ -550,32 +550,32 @@ def test_1134_dbms_output(self):
550550
@unittest.skipIf(not test_env.get_is_thin() and \
551551
test_env.get_client_version() < (18, 1),
552552
"unsupported client")
553-
def test_1135_calltimeout(self):
554-
"1135 - test connection call_timeout"
553+
def test_1131_calltimeout(self):
554+
"1131 - test connection call_timeout"
555555
conn = test_env.get_connection()
556556
conn.call_timeout = 500 # milliseconds
557557
self.assertEqual(conn.call_timeout, 500)
558558
self.assertRaisesRegex(oracledb.DatabaseError, "^DPY-4011:|^DPY-4024:",
559559
conn.cursor().callproc,
560560
test_env.get_sleep_proc_name(), [2])
561561

562-
def test_1137_connection_repr(self):
563-
"1137 - test Connection repr()"
562+
def test_1132_connection_repr(self):
563+
"1132 - test Connection repr()"
564564
class MyConnection(oracledb.Connection):
565565
pass
566566
conn = test_env.get_connection(conn_class=MyConnection)
567-
expected_regex = f"^<{__name__}.TestCase.test_1137_connection_repr." \
567+
expected_value = f"<{__name__}.TestCase.test_1132_connection_repr." \
568568
f"<locals>.MyConnection to {conn.username}@" \
569-
f"{conn.dsn}>$"
570-
self.assertRegex(repr(conn), expected_regex)
569+
f"{conn.dsn}>"
570+
self.assertEqual(repr(conn), expected_value)
571571

572-
expected_regex = f"^<{__name__}.TestCase.test_1137_connection_repr." \
573-
"<locals>.MyConnection disconnected>$"
574572
conn.close()
575-
self.assertRegex(repr(conn), expected_regex)
573+
expected_value = f"<{__name__}.TestCase.test_1132_connection_repr." \
574+
"<locals>.MyConnection disconnected>"
575+
self.assertEqual(repr(conn), expected_value)
576576

577-
def test_1138_get_write_only_attributes(self):
578-
"1138 - test getting write-only attributes"
577+
def test_1133_get_write_only_attributes(self):
578+
"1133 - test getting write-only attributes"
579579
conn = test_env.get_connection()
580580
with self.assertRaises(AttributeError):
581581
conn.action
@@ -590,8 +590,8 @@ def test_1138_get_write_only_attributes(self):
590590
with self.assertRaises(AttributeError):
591591
conn.client_identifier
592592

593-
def test_1139_invalid_params(self):
594-
"1139 - test error for invalid type for params and pool"
593+
def test_1134_invalid_params(self):
594+
"1134 - test error for invalid type for params and pool"
595595
pool = test_env.get_pool()
596596
pool.close()
597597
self.assertRaisesRegex(oracledb.InterfaceError, "^DPY-1002:",
@@ -601,8 +601,8 @@ def test_1139_invalid_params(self):
601601
self.assertRaisesRegex(oracledb.ProgrammingError, "^DPY-2025:",
602602
oracledb.connect, params={"number": 7})
603603

604-
def test_1140_instance_name(self):
605-
"1140 - test connection instance name"
604+
def test_1135_instance_name(self):
605+
"1135 - test connection instance name"
606606
conn = test_env.get_connection()
607607
cursor = conn.cursor()
608608
cursor.execute("""
@@ -611,8 +611,8 @@ def test_1140_instance_name(self):
611611
instance_name, = cursor.fetchone()
612612
self.assertEqual(conn.instance_name.upper(), instance_name)
613613

614-
def test_1141_deprecations(self):
615-
"1141 - test deprecated attributes"
614+
def test_1136_deprecations(self):
615+
"1136 - test deprecated attributes"
616616
conn = test_env.get_connection()
617617
conn.callTimeout = 500
618618
self.assertEqual(conn.callTimeout, 500)
@@ -624,8 +624,8 @@ def test_1141_deprecations(self):
624624
@unittest.skipIf(test_env.get_server_version() < (23, 0) or \
625625
test_env.get_client_version() < (23, 0),
626626
"unsupported client/server")
627-
def test_1142_max_length_password(self):
628-
"1142 - test maximum allowed length for password"
627+
def test_1137_max_length_password(self):
628+
"1137 - test maximum allowed length for password"
629629
conn = test_env.get_connection()
630630
if self.is_on_oracle_cloud(conn):
631631
self.skipTest("passwords on Oracle Cloud are strictly controlled")

tests/test_2400_pool.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -432,45 +432,6 @@ def test_2414_create_new_pure_connection(self):
432432
self.assertEqual(pool.opened, 2, "opened (2)")
433433
pool.release(conn3)
434434

435-
@unittest.skipIf(test_env.get_is_thin(),
436-
"thin mode doesn't support pool reconfigure yet")
437-
def test_2415_reconfigure_pool(self):
438-
"2415 - test to ensure reconfigure() updates pool properties"
439-
pool = test_env.get_pool(min=1, max=2, increment=1,
440-
getmode=oracledb.POOL_GETMODE_WAIT)
441-
self.assertEqual(pool.min, 1, "min (1)")
442-
self.assertEqual(pool.max, 2, "max (2)")
443-
self.assertEqual(pool.increment, 1, "increment (1)")
444-
self.assertEqual(pool.getmode, oracledb.POOL_GETMODE_WAIT,
445-
"getmode differs")
446-
self.assertEqual(pool.timeout, 0, "timeout (0)")
447-
self.assertEqual(pool.wait_timeout, 5000, "wait_timeout (5000)")
448-
self.assertEqual(pool.max_lifetime_session, 0,
449-
"max_lifetime_sessionmeout (0)")
450-
self.assertEqual(pool.max_sessions_per_shard, 0,
451-
"max_sessions_per_shard (0)")
452-
self.assertEqual(pool.stmtcachesize, 20, "stmtcachesize (20)")
453-
self.assertEqual(pool.ping_interval, 60, "ping_interval (60)")
454-
455-
pool.reconfigure(min=2, max=5, increment=2, timeout=30,
456-
getmode=oracledb.POOL_GETMODE_TIMEDWAIT,
457-
wait_timeout=3000, max_lifetime_session=20,
458-
max_sessions_per_shard=2, stmtcachesize=30,
459-
ping_interval=30)
460-
self.assertEqual(pool.min, 2, "min (2)")
461-
self.assertEqual(pool.max, 5, "max (5)")
462-
self.assertEqual(pool.increment, 2, "increment (2)")
463-
self.assertEqual(pool.getmode, oracledb.POOL_GETMODE_TIMEDWAIT,
464-
"getmode differs")
465-
self.assertEqual(pool.timeout, 30, "timeout (30)")
466-
self.assertEqual(pool.wait_timeout, 3000, "wait_timeout (3000)")
467-
self.assertEqual(pool.max_lifetime_session, 20,
468-
"max_lifetime_sessionmeout (20)")
469-
self.assertEqual(pool.max_sessions_per_shard, 2,
470-
"max_sessions_per_shard (2)")
471-
self.assertEqual(pool.stmtcachesize, 30, "stmtcachesize (30)")
472-
self.assertEqual(pool.ping_interval, 30, "ping_interval (30)")
473-
474435
@unittest.skipIf(test_env.get_is_thin(),
475436
"thin mode doesn't support all the pool params yet")
476437
def test_2416_test_reconfigure_pool_with_missing_values(self):

tests/test_3100_boolean_var.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333

3434
@unittest.skipUnless(test_env.get_client_version() >= (12, 1),
3535
"unsupported client")
36+
@unittest.skipUnless(test_env.get_server_version() >= (12, 1),
37+
"unsupported server")
3638
class TestCase(test_env.BaseTestCase):
3739

3840
def __test_bind_value_as_boolean(self, value):

tests/test_3300_soda_database.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,11 @@ def test_3303_open_collection(self):
110110
coll.drop()
111111

112112
def test_3304_repr(self):
113-
"3304 - test SodaDatabase representation"
114-
conn1 = self.conn
115-
conn2 = test_env.get_connection()
116-
soda_db1 = self.conn.getSodaDatabase()
117-
soda_db2 = conn1.getSodaDatabase()
118-
soda_db3 = conn2.getSodaDatabase()
119-
self.assertEqual(str(soda_db1), str(soda_db2))
120-
self.assertEqual(str(soda_db2), str(soda_db3))
113+
"3304 - test SodaDatabase repr() and str()"
114+
conn = test_env.get_connection()
115+
soda_db = conn.getSodaDatabase()
116+
self.assertEqual(repr(soda_db), f"<oracledb.SodaDatabase on {conn}>")
117+
self.assertEqual(str(soda_db), f"<oracledb.SodaDatabase on {conn}>")
121118

122119
def test_3305_negative(self):
123120
"3305 - test negative cases for SODA database methods"

0 commit comments

Comments
 (0)