File: test_1000_module.py

package info (click to toggle)
python-cx-oracle 8.3.0-3
  • links: PTS, VCS
  • area: contrib
  • in suites: bookworm, sid
  • size: 3,276 kB
  • sloc: ansic: 10,406; python: 9,358; sql: 1,724; makefile: 31
file content (45 lines) | stat: -rw-r--r-- 1,625 bytes parent folder | download
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()