forked from oracle/python-cx_Oracle
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_1000_module.py
More file actions
45 lines (36 loc) · 1.59 KB
/
test_1000_module.py
File metadata and controls
45 lines (36 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#------------------------------------------------------------------------------
# Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
#------------------------------------------------------------------------------
"""
1000 - Module for testing top-level module methods
"""
import datetime
import time
import cx_Oracle as oracledb
import test_env
class TestCase(test_env.BaseTestCase):
requires_connection = False
def test_1000_date_from_ticks(self):
"1000 - test DateFromTicks()"
today = datetime.datetime.today()
timestamp = time.mktime(today.timetuple())
date = oracledb.DateFromTicks(timestamp)
self.assertEqual(date, today.date())
def test_1001_future_obj(self):
"1001 - test management of __future__ object"
self.assertEqual(oracledb.__future__.dummy, None)
oracledb.__future__.dummy = "Unimportant"
self.assertEqual(oracledb.__future__.dummy, None)
def test_1002_timestamp_from_ticks(self):
"1002 - test TimestampFromTicks()"
timestamp = time.mktime(datetime.datetime.today().timetuple())
today = datetime.datetime.fromtimestamp(timestamp)
date = oracledb.TimestampFromTicks(timestamp)
self.assertEqual(date, today)
def test_1003_unsupported_functions(self):
"1003 - test unsupported time functions"
self.assertRaises(oracledb.NotSupportedError, oracledb.Time, 12, 0, 0)
self.assertRaises(oracledb.NotSupportedError, oracledb.TimeFromTicks,
100)
if __name__ == "__main__":
test_env.run_test_cases()