Skip to content

Commit c8b9a41

Browse files
Tweaks to tests.
1 parent ef3ba1f commit c8b9a41

File tree

2 files changed

+158
-2
lines changed

2 files changed

+158
-2
lines changed

tests/test_2700_aq.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,13 +556,15 @@ def test_2723(self):
556556
self.book_queue_name, self.book_type_name
557557
)
558558
book = queue.payload_type.newobject()
559-
self.cursor.execute("select sysdate from dual")
559+
self.cursor.execute("select current_timestamp from dual")
560560
(start_date,) = self.cursor.fetchone()
561+
start_date = start_date.replace(microsecond=0)
561562
props = self.conn.msgproperties(payload=book)
562563
queue.enqone(props)
563564
props = queue.deqone()
564-
self.cursor.execute("select sysdate from dual")
565+
self.cursor.execute("select current_timestamp from dual")
565566
(end_date,) = self.cursor.fetchone()
567+
end_date = end_date.replace(microsecond=0)
566568
self.assertTrue(start_date <= props.enqtime <= end_date)
567569

568570
def test_2724(self):
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
# -----------------------------------------------------------------------------
2+
# Copyright (c) 2024, Oracle and/or its affiliates.
3+
#
4+
# This software is dual-licensed to you under the Universal Permissive License
5+
# (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
6+
# 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose
7+
# either license.
8+
#
9+
# If you elect to accept the software under the Apache License, Version 2.0,
10+
# the following applies:
11+
#
12+
# Licensed under the Apache License, Version 2.0 (the "License");
13+
# you may not use this file except in compliance with the License.
14+
# You may obtain a copy of the License at
15+
#
16+
# https://www.apache.org/licenses/LICENSE-2.0
17+
#
18+
# Unless required by applicable law or agreed to in writing, software
19+
# distributed under the License is distributed on an "AS IS" BASIS,
20+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21+
# See the License for the specific language governing permissions and
22+
# limitations under the License.
23+
# -----------------------------------------------------------------------------
24+
25+
"""
26+
7000 - Module for testing async connections shortcut methods
27+
"""
28+
29+
import unittest
30+
31+
import test_env
32+
33+
34+
@unittest.skipUnless(
35+
test_env.get_is_thin(), "asyncio not supported in thick mode"
36+
)
37+
class TestCase(test_env.BaseAsyncTestCase):
38+
39+
async def test_7700(self):
40+
"7700 - test execute()"
41+
await self.conn.execute("truncate table TestTempTable")
42+
await self.conn.execute(
43+
"insert into TestTempTable (IntCol) values (:1)", [77]
44+
)
45+
await self.conn.execute(
46+
"insert into TestTempTable (IntCol) values (:val)", dict(val=15)
47+
)
48+
await self.conn.commit()
49+
50+
res = await self.conn.fetchall(
51+
"select IntCol from TestTempTable order by IntCol"
52+
)
53+
self.assertEqual(res, [(15,), (77,)])
54+
55+
async def test_7701(self):
56+
"7701 - test fetchall()"
57+
await self.conn.execute("truncate table TestTempTable")
58+
data = [(2,), (3,)]
59+
await self.conn.executemany(
60+
"insert into TestTempTable (IntCol) values (:1)", data
61+
)
62+
res = await self.conn.fetchall(
63+
"select IntCol from TestTempTable order by IntCol"
64+
)
65+
self.assertEqual(res, data)
66+
67+
async def test_7702(self):
68+
"7702 - test fetchall() with arraysize"
69+
await self.conn.execute("truncate table TestTempTable")
70+
await self.conn.executemany(
71+
"insert into TestTempTable (IntCol) values (:value)",
72+
[{"value": i} for i in range(3)],
73+
)
74+
await self.conn.commit()
75+
res = await self.conn.fetchall(
76+
"select IntCol from TestTempTable order by IntCol", arraysize=1
77+
)
78+
self.assertEqual(res, [(0,), (1,), (2,)])
79+
80+
async def test_7703(self):
81+
"7703 - test fetchall() with rowfactory"
82+
await self.conn.execute("truncate table TestTempTable")
83+
await self.conn.execute(
84+
"""
85+
insert into TestTempTable (IntCol, StringCol1)
86+
values (1, 'test_7703')
87+
"""
88+
)
89+
await self.conn.commit()
90+
91+
column_names = ["INTCOL", "STRINGCOL1"]
92+
93+
def rowfactory(*row):
94+
return dict(zip(column_names, row))
95+
96+
res = await self.conn.fetchall(
97+
"select IntCol, StringCol1 from TestTempTable",
98+
rowfactory=rowfactory,
99+
)
100+
expected_value = [{"INTCOL": 1, "STRINGCOL1": "test_7703"}]
101+
self.assertEqual(res, expected_value)
102+
103+
async def test_7704(self):
104+
"7704 - test executemany()"
105+
await self.conn.execute("truncate table TestTempTable")
106+
await self.conn.executemany(
107+
"insert into TestTempTable (IntCol) values (:1)", [(1,), (2,)]
108+
)
109+
await self.conn.executemany(
110+
"insert into TestTempTable (IntCol) values (:value)",
111+
[{"value": 3}, {"value": 4}],
112+
)
113+
await self.conn.commit()
114+
res = await self.conn.fetchall(
115+
"select IntCol from TestTempTable order by IntCol"
116+
)
117+
self.assertEqual(res, [(1,), (2,), (3,), (4,)])
118+
119+
async def test_7705(self):
120+
"7705 - test fetchone()"
121+
await self.conn.execute("truncate table TestTempTable")
122+
await self.conn.executemany(
123+
"insert into TestTempTable (IntCol) values (:1)", [(9,), (10,)]
124+
)
125+
await self.conn.commit()
126+
127+
res = await self.conn.fetchone(
128+
"select IntCol from TestTempTable order by IntCol"
129+
)
130+
self.assertEqual(res, (9,))
131+
132+
res = await self.conn.fetchone("select :1 from dual", [23])
133+
self.assertEqual(res, (23,))
134+
135+
res = await self.conn.fetchone("select :val from dual", {"val": 5})
136+
self.assertEqual(res, (5,))
137+
138+
async def test_7706(self):
139+
"7706 - test fetchmany()"
140+
data = [(i,) for i in range(10)]
141+
await self.conn.execute("truncate table TestTempTable")
142+
await self.conn.executemany(
143+
"insert into TestTempTable (IntCol) values (:1)", data
144+
)
145+
await self.conn.commit()
146+
res = await self.conn.fetchmany(
147+
"select IntCol from TestTempTable order by IntCol",
148+
num_rows=3,
149+
)
150+
self.assertEqual(res, data[:3])
151+
152+
153+
if __name__ == "__main__":
154+
test_env.run_test_cases()

0 commit comments

Comments
 (0)