Skip to content

Commit 1ef74ff

Browse files
Ongoing improvement of test suite.
1 parent 7d364ea commit 1ef74ff

11 files changed

+261
-43
lines changed

tests/ext/test_ext_2100_bfile_type.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import tempfile
3232
import unittest
3333

34+
import oracledb
3435
import test_env
3536

3637

@@ -158,6 +159,34 @@ def test_ext_2104(self):
158159
with self.assertRaisesFullCode("ORA-22288"):
159160
bfile.read()
160161

162+
def test_ext_2105(self):
163+
"E2105 - test setting and getting BFILE var"
164+
with tempfile.TemporaryDirectory() as temp_dir:
165+
self._setup_directory(temp_dir)
166+
file_name1 = "test1.txt"
167+
contents1 = b"extended test 2105 - first file"
168+
with open(os.path.join(temp_dir, file_name1), "wb") as f:
169+
f.write(contents1)
170+
file_name2 = "test2.txt"
171+
contents2 = b"extended test 2105 - second file"
172+
with open(os.path.join(temp_dir, file_name2), "wb") as f:
173+
f.write(contents2)
174+
var1 = self.cursor.var(oracledb.DB_TYPE_BFILE)
175+
var2 = self.cursor.var(oracledb.DB_TYPE_BFILE)
176+
self.cursor.execute(
177+
f"""
178+
begin
179+
:1 := BFILENAME('{self.dir_name}', '{file_name1}');
180+
:2 := BFILENAME('{self.dir_name}', '{file_name2}');
181+
end;
182+
""",
183+
[var1, var2],
184+
)
185+
self.assertEqual(var1.getvalue().read(), contents1)
186+
self.assertEqual(var2.getvalue().read(), contents2)
187+
self.cursor.execute("begin :1 := :2; end;", [var1, var2])
188+
self.assertEqual(var1.getvalue().read(), contents2)
189+
161190

162191
if __name__ == "__main__":
163192
test_env.run_test_cases()

tests/ext/test_ext_2200_bfile_type_async.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import tempfile
3232
import unittest
3333

34+
import oracledb
3435
import test_env
3536

3637

@@ -161,6 +162,34 @@ async def test_ext_2204(self):
161162
with self.assertRaisesFullCode("ORA-22288"):
162163
await bfile.read()
163164

165+
async def test_ext_2205(self):
166+
"E2205 - test setting and getting BFILE var"
167+
with tempfile.TemporaryDirectory() as temp_dir:
168+
await self._setup_directory(temp_dir)
169+
file_name1 = "test1.txt"
170+
contents1 = b"extended test 2105 - first file"
171+
with open(os.path.join(temp_dir, file_name1), "wb") as f:
172+
f.write(contents1)
173+
file_name2 = "test2.txt"
174+
contents2 = b"extended test 2105 - second file"
175+
with open(os.path.join(temp_dir, file_name2), "wb") as f:
176+
f.write(contents2)
177+
var1 = self.cursor.var(oracledb.DB_TYPE_BFILE)
178+
var2 = self.cursor.var(oracledb.DB_TYPE_BFILE)
179+
await self.cursor.execute(
180+
f"""
181+
begin
182+
:1 := BFILENAME('{self.dir_name}', '{file_name1}');
183+
:2 := BFILENAME('{self.dir_name}', '{file_name2}');
184+
end;
185+
""",
186+
[var1, var2],
187+
)
188+
self.assertEqual(await var1.getvalue().read(), contents1)
189+
self.assertEqual(await var2.getvalue().read(), contents2)
190+
await self.cursor.execute("begin :1 := :2; end;", [var1, var2])
191+
self.assertEqual(await var1.getvalue().read(), contents2)
192+
164193

165194
if __name__ == "__main__":
166195
test_env.run_test_cases()

tests/sql/create_schema.sql

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -268,35 +268,41 @@ create table &main_user..TestObjects (
268268
create table &main_user..TestTimestamps (
269269
IntCol number(9) not null,
270270
TimestampCol timestamp not null,
271-
NullableCol timestamp
271+
NullableCol timestamp,
272+
TimestampPrecisionCol timestamp(4)
272273
)
273274
/
274275

275276
create table &main_user..TestTimestampLTZs (
276277
IntCol number(9) not null,
277278
TimestampLTZCol timestamp with local time zone not null,
278-
NullableCol timestamp with local time zone
279+
NullableCol timestamp with local time zone,
280+
TimestampLTZPrecisionCol timestamp(5) with local time zone
279281
)
280282
/
281283

282284
create table &main_user..TestTimestampTZs (
283285
IntCol number(9) not null,
284286
TimestampTZCol timestamp with time zone not null,
285-
NullableCol timestamp with time zone
287+
NullableCol timestamp with time zone,
288+
TimestampTZPrecisionCol timestamp(7) with time zone
286289
)
287290
/
288291

289292
create table &main_user..TestIntervals (
290293
IntCol number(9) not null,
291294
IntervalCol interval day to second not null,
292-
NullableCol interval day to second
295+
NullableCol interval day to second,
296+
IntervalPrecisionCol interval day(7) to second,
297+
IntervalPrecisionScaleCol interval day(8) to second(9)
293298
)
294299
/
295300

296301
create table &main_user..TestIntervalYMs (
297302
IntCol number(9) not null,
298303
IntervalCol interval year to month not null,
299-
NullableCol interval year to month
304+
NullableCol interval year to month,
305+
IntervalPrecisionCol interval year(3) to month
300306
)
301307
/
302308

@@ -488,7 +494,8 @@ begin
488494
decode(mod(i, 2), 0, to_timestamp(null, 'YYYYMMDD'),
489495
to_timestamp('20021209', 'YYYYMMDD') +
490496
to_dsinterval(to_char(i + 1) || ' 00:00:' ||
491-
to_char(i * 3) || '.' || to_char(i * 125))));
497+
to_char(i * 3) || '.' || to_char(i * 125))),
498+
to_timestamp('20091214', 'YYYYMMDD'));
492499
end loop;
493500
end;
494501
/
@@ -505,7 +512,8 @@ begin
505512
decode(mod(i, 2), 0, to_timestamp(null, 'YYYYMMDD'),
506513
to_timestamp_tz('20220602 00:00', 'YYYYMMDD TZH:TZM') +
507514
to_dsinterval(to_char(i + 1) || ' 00:00:' ||
508-
to_char(i * 3) || '.' || to_char(i * 125))));
515+
to_char(i * 3) || '.' || to_char(i * 125))),
516+
to_timestamp_tz('20091214 00:00', 'YYYYMMDD TZH:TZM'));
509517
end loop;
510518
end;
511519
/
@@ -522,7 +530,8 @@ begin
522530
decode(mod(i, 2), 0, to_timestamp(null, 'YYYYMMDD'),
523531
to_timestamp_tz('20220603 00:00', 'YYYYMMDD TZH:TZM') +
524532
to_dsinterval(to_char(i + 1) || ' 00:00:' ||
525-
to_char(i * 3) || '.' || to_char(i * 125))));
533+
to_char(i * 3) || '.' || to_char(i * 125))),
534+
to_timestamp_tz('20091214 00:00', 'YYYYMMDD TZH:TZM'));
526535
end loop;
527536
end;
528537
/
@@ -534,7 +543,9 @@ begin
534543
to_char(i * 2) || ':' || to_char(i * 3)),
535544
decode(mod(i, 2), 0, to_dsinterval(null),
536545
to_dsinterval(to_char(i + 5) || ' ' || to_char(i + 2) || ':' ||
537-
to_char(i * 2 + 5) || ':' || to_char(i * 3 + 5))));
546+
to_char(i * 2 + 5) || ':' || to_char(i * 3 + 5))),
547+
to_dsinterval('8 05:15:00'),
548+
to_dsinterval('10 12:15:15'));
538549
end loop;
539550
end;
540551
/
@@ -544,7 +555,8 @@ begin
544555
insert into &main_user..TestIntervalYMs
545556
values (i, to_yminterval(to_char(i - 5) || '-' || to_char(i)),
546557
decode(mod(i, 2), 0, to_yminterval(null),
547-
to_yminterval(to_char(i + 5) || '-' || to_char(i + 2))));
558+
to_yminterval(to_char(i + 5) || '-' || to_char(i + 2))),
559+
to_yminterval('3-8'));
548560
end loop;
549561
end;
550562
/

tests/sql/create_schema_23.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ create table &main_user..TestVectors (
5858
VectorFlex8Col vector(*, int8),
5959
VectorFlex32Col vector(*, float32),
6060
VectorFlex64Col vector(*, float64),
61-
Vector32Col vector(10, float32),
62-
Vector64Col vector(10, float64),
63-
Vector8Col vector(10, int8)
61+
Vector8Col vector(16, int8),
62+
Vector32Col vector(16, float32),
63+
Vector64Col vector(16, float64)
6464
)
6565
/
6666

tests/test_1800_interval_var.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,25 @@ def setUp(self):
5050
minutes=i * 2 + 5,
5151
seconds=i * 3 + 5,
5252
)
53-
data_tuple = (i, delta, nullable_delta)
53+
precision_col = datetime.timedelta(
54+
days=8,
55+
hours=5,
56+
minutes=15,
57+
seconds=0,
58+
)
59+
precision_scale_col = datetime.timedelta(
60+
days=10,
61+
hours=12,
62+
minutes=15,
63+
seconds=15,
64+
)
65+
data_tuple = (
66+
i,
67+
delta,
68+
nullable_delta,
69+
precision_col,
70+
precision_scale_col,
71+
)
5472
self.raw_data.append(data_tuple)
5573
self.data_by_key[i] = data_tuple
5674

@@ -178,6 +196,24 @@ def test_1807(self):
178196
6,
179197
True,
180198
),
199+
(
200+
"INTERVALPRECISIONCOL",
201+
oracledb.DB_TYPE_INTERVAL_DS,
202+
None,
203+
None,
204+
7,
205+
6,
206+
True,
207+
),
208+
(
209+
"INTERVALPRECISIONSCALECOL",
210+
oracledb.DB_TYPE_INTERVAL_DS,
211+
None,
212+
None,
213+
8,
214+
9,
215+
True,
216+
),
181217
]
182218
self.assertEqual(self.cursor.description, expected_value)
183219

tests/test_2600_timestamp_var.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ def setUp(self):
6868
)
6969
else:
7070
nullable_col = None
71-
data_tuple = (i, date_col, nullable_col)
71+
precision_col = datetime.datetime(2009, 12, 14)
72+
data_tuple = (i, date_col, nullable_col, precision_col)
7273
self.raw_data.append(data_tuple)
7374
self.data_by_key[i] = data_tuple
7475

@@ -167,6 +168,15 @@ def test_2606(self):
167168
False,
168169
),
169170
("NULLABLECOL", oracledb.DB_TYPE_TIMESTAMP, 23, None, 0, 6, True),
171+
(
172+
"TIMESTAMPPRECISIONCOL",
173+
oracledb.DB_TYPE_TIMESTAMP,
174+
23,
175+
None,
176+
0,
177+
4,
178+
True,
179+
),
170180
]
171181
self.assertEqual(self.cursor.description, expected_value)
172182

tests/test_3400_soda_collection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ def test_3444(self):
967967

968968
@unittest.skipIf(
969969
test_env.get_client_version() < (23, 4)
970-
and test_env.get_server_version() < (23, 4),
970+
or test_env.get_server_version() < (23, 4),
971971
"unsupported data types",
972972
)
973973
def test_3445(self):
@@ -990,7 +990,7 @@ def test_3445(self):
990990

991991
@unittest.skipIf(
992992
test_env.get_client_version() < (23, 4)
993-
and test_env.get_server_version() < (23, 4),
993+
or test_env.get_server_version() < (23, 4),
994994
"unsupported data types",
995995
)
996996
def test_3446(self):

tests/test_4800_timestamp_ltz_var.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ def setUp(self):
6060
nullable_col = base_date + offset
6161
else:
6262
nullable_col = None
63-
data_tuple = (i, col, nullable_col)
63+
precision_col = datetime.datetime(2009, 12, 14)
64+
data_tuple = (i, col, nullable_col, precision_col)
6465
self.raw_data.append(data_tuple)
6566
self.data_by_key[i] = data_tuple
6667

@@ -171,6 +172,15 @@ def test_4806(self):
171172
6,
172173
True,
173174
),
175+
(
176+
"TIMESTAMPLTZPRECISIONCOL",
177+
oracledb.DB_TYPE_TIMESTAMP_LTZ,
178+
23,
179+
None,
180+
0,
181+
5,
182+
True,
183+
),
174184
]
175185
self.assertEqual(self.cursor.description, expected_value)
176186

tests/test_4900_timestamp_tz_var.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ def setUp(self):
5252
nullable_col = base_date + offset
5353
else:
5454
nullable_col = None
55-
data_tuple = (i, col, nullable_col)
55+
precision_col = datetime.datetime(2009, 12, 14)
56+
data_tuple = (i, col, nullable_col, precision_col)
5657
self.raw_data.append(data_tuple)
5758
self.data_by_key[i] = data_tuple
5859

@@ -163,6 +164,15 @@ def test_4906(self):
163164
6,
164165
True,
165166
),
167+
(
168+
"TIMESTAMPTZPRECISIONCOL",
169+
oracledb.DB_TYPE_TIMESTAMP_TZ,
170+
23,
171+
None,
172+
0,
173+
7,
174+
True,
175+
),
166176
]
167177
self.assertEqual(self.cursor.description, expected_value)
168178

0 commit comments

Comments
 (0)