diff --git a/.gitignore b/.gitignore index e0bff45..27511e4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.pyc +.tox/ build/ dist/ doc/build diff --git a/README.md b/README.md index 3dab9c9..c74a67d 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ of exclusions. See the [homepage](https://oracle.github.io/python-cx_Oracle/index.html) for a feature list. -cx_Oracle 8 has been tested with Python versions 3.5 through 3.8. You can use +cx_Oracle 8 has been tested with Python versions 3.6 through 3.9. You can use cx_Oracle with Oracle 11.2, 12c, 18c and 19c client libraries. Oracle's standard client-server version interoperability allows connection to both older and newer databases. For example Oracle 19c client libraries can connect to diff --git a/doc/src/release_notes.rst b/doc/src/release_notes.rst index b7e7698..c720241 100644 --- a/doc/src/release_notes.rst +++ b/doc/src/release_notes.rst @@ -11,12 +11,18 @@ Version 8.1 (TBD) #) Updated embedded ODPI-C to `version 4.1.0 `__. +#) Dropped support for Python 3.5. Added support for Python 3.9. #) Added internal methods for getting/setting OCI attributes that are otherwise not supported by cx_Oracle. These methods should only be used as directed by Oracle. #) Minor code improvement supplied by Alex Henrie (`PR 472 `__). -#) Improved documentation. +#) Builds are now done with setuptools and most metadata has moved from + `setup.py` to `setup.cfg` in order to take advantage of Python packaging + improvements. +#) Tests can now be run with tox in order to automate testing of the different + environments that are supported. +#) Improved documentation and test suite. Version 8.0.1 (August 2020) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..121a39f --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools >= 40.6.0", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..5ec4590 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,27 @@ +[metadata] +name = cx_Oracle +description = Python interface to Oracle +long_description = file: README.md +long_description_content_type = text/markdown +keywords = Oracle, database +author = "Anthony Tuininga", +author_email = "anthony.tuininga@gmail.com", +license = BSD License +url = https://oracle.github.io/python-cx_Oracle +project_urls = + Installation = https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html + Samples = https://github.com/oracle/python-cx_Oracle/tree/master/samples + Documentation = http://cx-oracle.readthedocs.io + Release Notes = https://cx-oracle.readthedocs.io/en/latest/release_notes.html#releasenotes + Issues = https://github.com/oracle/python-cx_Oracle/issues + Source = https://github.com/oracle/python-cx_Oracle +python_requires = >=3.6 +classifiers = + Development Status :: 6 - Mature + Intended Audience :: Developers + License :: OSI Approved :: BSD License + Natural Language :: English + Operating System :: OS Independent + Programming Language :: C + Programming Language :: Python :: 3 :: Only + Topic :: Database diff --git a/setup.py b/setup.py index bc1f510..20417aa 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -"""Distutils script for cx_Oracle. +"""Setup script for cx_Oracle. Windows platforms: python setup.py build --compiler=mingw32 install @@ -8,21 +8,18 @@ Unix platforms """ -import distutils.core import os +import pkg_resources +import setuptools import sys # check minimum supported Python version -if sys.version_info[:2] < (3, 5): - raise Exception("Python 3.5 or higher is required. " + +if sys.version_info[:2] < (3, 6): + raise Exception("Python 3.6 or higher is required. " + "For python 2, use 'pip install cx_Oracle==7.3'") -# if setuptools is detected, use it to add support for eggs -try: - from setuptools import setup, Extension -except: - from distutils.core import setup - from distutils.extension import Extension +# check minimum supported version of setuptools +pkg_resources.require("setuptools>=40.6.0") # define build constants BUILD_VERSION = "8.1.0-dev" @@ -39,43 +36,12 @@ elif sys.platform == "cygwin": elif sys.platform == "darwin": extraLinkArgs.append("-shared-libgcc") -class test(distutils.core.Command): - description = "run the test suite for the extension" - user_options = [] - - def finalize_options(self): - pass - - def initialize_options(self): - pass - - def run(self): - self.run_command("build") - buildCommand = self.distribution.get_command_obj("build") - sys.path.insert(0, os.path.abspath("test")) - sys.path.insert(0, os.path.abspath(buildCommand.build_lib)) - fileName = os.path.join("test", "test.py") - exec(open(fileName).read()) - -# define classifiers for the package index -classifiers = [ - "Development Status :: 6 - Mature", - "Intended Audience :: Developers", - "License :: OSI Approved :: BSD License", - "Natural Language :: English", - "Operating System :: OS Independent", - "Programming Language :: C", - "Programming Language :: Python :: 3 :: Only", - "Topic :: Database" -] - # define cx_Oracle sources sourceDir = "src" sources = [os.path.join(sourceDir, n) \ for n in sorted(os.listdir(sourceDir)) if n.endswith(".c")] depends = ["src/cxoModule.h"] - # define ODPI-C sources, libraries and include directories; if the environment # variables ODPIC_INC_DIR and ODPIC_LIB_DIR are both set, assume these # locations contain a compiled installation of ODPI-C; otherwise, use the @@ -98,7 +64,7 @@ else: libraryDirs = [] # setup the extension -extension = Extension( +extension = setuptools.Extension( name = "cx_Oracle", include_dirs = includeDirs, extra_compile_args = extraCompileArgs, @@ -110,22 +76,7 @@ extension = Extension( library_dirs = libraryDirs) # perform the setup -setup( - name = "cx_Oracle", +setuptools.setup( version = BUILD_VERSION, - description = "Python interface to Oracle", - cmdclass = dict(test = test), data_files = [ ("cx_Oracle-doc", ["LICENSE.txt", "README.txt"]) ], - long_description = \ - "Python interface to Oracle Database conforming to the Python DB " - "API 2.0 specification.\n" - "See http://www.python.org/topics/database/DatabaseAPI-2.0.html.", - author = "Anthony Tuininga", - author_email = "anthony.tuininga@gmail.com", - url = "https://oracle.github.io/python-cx_Oracle", - python_requires = ">=3.5", - ext_modules = [extension], - keywords = "Oracle", - license = "BSD License", - classifiers = classifiers) - + ext_modules = [extension]) diff --git a/test/README.md b/test/README.md index f3eda4e..f958c0b 100644 --- a/test/README.md +++ b/test/README.md @@ -2,10 +2,10 @@ This directory contains the test suite for cx_Oracle. 1. The schemas and SQL objects that are referenced in the test suite can be created by running the Python script [SetupTest.py][1]. The script requires - SYSDBA privileges and will prompt for these credentials as well as the - names of the schemas that will be created, unless a number of environment - variables are set as documented in the Python script [TestEnv.py][2]. Run - the script using the following command: + administrative privileges and will prompt for these credentials as well as + the names of the schemas that will be created, unless a number of + environment variables are set as documented in the Python script + [TestEnv.py][2]. Run the script using the following command: python SetupTest.py @@ -13,23 +13,23 @@ This directory contains the test suite for cx_Oracle. will always prompt for the names of the schemas that will be created. Run the script using the following command: - sqlplus sys/syspassword@hostname/servicename @sql/SetupTest.sql + sqlplus system/systempassword@hostname/servicename @sql/SetupTest.sql 2. Run the test suite by issuing the following command in the top-level directory of your cx_Oracle installation: - python setup.py test + tox Alternatively, you can run the test suite directly within this directory: - python test.py + python TestEnv.py 3. After running the test suite, the schemas can be dropped by running the - Python script [DropTest.py][4]. The script requires SYSDBA privileges and - will prompt for these credentials as well as the names of the schemas - that will be dropped, unless a number of environment variables are set as - documented in the Python script [TestEnv.py][2]. Run the script using the - following command: + Python script [DropTest.py][4]. The script requires administrative + privileges and will prompt for these credentials as well as the names of the + schemas that will be dropped, unless a number of environment variables are + set as documented in the Python script [TestEnv.py][2]. Run the script using + the following command: python DropTest.py @@ -37,11 +37,10 @@ This directory contains the test suite for cx_Oracle. will always prompt for the names of the schemas that will be dropped. Run the script using the following command: - sqlplus sys/syspassword@hostname/servicename @sql/DropTest.sql + sqlplus system/systempassword@hostname/servicename @sql/DropTest.sql [1]: https://github.com/oracle/python-cx_Oracle/blob/master/test/SetupTest.py [2]: https://github.com/oracle/python-cx_Oracle/blob/master/test/TestEnv.py [3]: https://github.com/oracle/python-cx_Oracle/blob/master/test/sql/SetupTest.sql [4]: https://github.com/oracle/python-cx_Oracle/blob/master/test/DropTest.py [5]: https://github.com/oracle/python-cx_Oracle/blob/master/test/sql/DropTest.sql - diff --git a/test/TestEnv.py b/test/TestEnv.py index 8ba4560..426b528 100644 --- a/test/TestEnv.py +++ b/test/TestEnv.py @@ -1,5 +1,5 @@ #------------------------------------------------------------------------------ -# Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. # # Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved. # @@ -146,6 +146,14 @@ def RunSqlScript(conn, scriptName, **kwargs): print(" %s/%s %s" % (lineNum, position, text)) def RunTestCases(): + print("Running tests for cx_Oracle version", cx_Oracle.version, + "built at", cx_Oracle.buildtime) + print("File:", cx_Oracle.__file__) + print("Client Version:", + ".".join(str(i) for i in cx_Oracle.clientversion())) + with GetConnection() as connection: + print("Server Version:", connection.version) + print() unittest.main(testRunner=unittest.TextTestRunner(verbosity=2)) def GetConnection(**kwargs): @@ -161,7 +169,32 @@ def GetPool(user=None, password=None, **kwargs): encoding="UTF-8", nencoding="UTF-8", **kwargs) def GetClientVersion(): - return cx_Oracle.clientversion() + name = "CLIENT_VERSION" + value = PARAMETERS.get(name) + if value is None: + value = cx_Oracle.clientversion()[:2] + PARAMETERS[name] = value + return value + +def GetServerVersion(): + name = "SERVER_VERSION" + value = PARAMETERS.get(name) + if value is None: + conn = GetConnection() + value = tuple(int(s) for s in conn.version.split("."))[:2] + PARAMETERS[name] = value + return value + +def SkipSodaTests(): + client = GetClientVersion() + if client < (18, 3): + return True + server = GetServerVersion() + if server < (18, 0): + return True + if server > (20, 1) and client < (20, 1): + return True + return False class RoundTripInfo: @@ -225,3 +258,9 @@ class BaseTestCase(unittest.TestCase): del self.cursor del self.connection + +def load_tests(loader, standard_tests, pattern): + return loader.discover(os.path.dirname(__file__)) + +if __name__ == "__main__": + RunTestCases() diff --git a/test/test.py b/test/test.py deleted file mode 100644 index 074abc1..0000000 --- a/test/test.py +++ /dev/null @@ -1,77 +0,0 @@ -#------------------------------------------------------------------------------ -# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. -# -# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved. -# -# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta, -# Canada. All rights reserved. -#------------------------------------------------------------------------------ - -"""Runs all defined unit tests.""" - -import cx_Oracle -import os -import sys -import TestEnv -import unittest - -# display version of cx_Oracle and Oracle client for which tests are being run -print("Running tests for cx_Oracle version", cx_Oracle.version, - "built at", cx_Oracle.buildtime) -print("File:", cx_Oracle.__file__) -print("Client Version:", ".".join(str(i) for i in cx_Oracle.clientversion())) -sys.stdout.flush() - -# verify that we can connect to the database and display database version -connection = TestEnv.GetConnection() -print("Server Version:", connection.version) -sys.stdout.flush() - -# define test cases to run -moduleNames = [ - "Module", - "Connection", - "Cursor", - "CursorVar", - "DateTimeVar", - "DbTypes", - "DMLReturning", - "Error", - "IntervalVar", - "LobVar", - "LongVar", - "NCharVar", - "NumberVar", - "ObjectVar", - "SessionPool", - "StringVar", - "TimestampVar", - "AQ", - "BulkAQ", - "Rowid", - "Subscription" -] -clientVersion = cx_Oracle.clientversion() -if clientVersion[:2] >= (12, 1): - moduleNames.append("BooleanVar") - moduleNames.append("Features12_1") -if clientVersion[:2] >= (18, 3): - moduleNames.append("SodaDatabase") - moduleNames.append("SodaCollection") - -# run all test cases -failures = [] -loader = unittest.TestLoader() -runner = unittest.TextTestRunner(verbosity = 2) -for name in moduleNames: - print() - print("Running tests in", name) - tests = loader.loadTestsFromName(name + ".TestCase") - result = runner.run(tests) - if not result.wasSuccessful(): - failures.append(name) -if failures: - print("***** Some tests in the following modules failed. *****") - for name in failures: - print(" %s" % name) - sys.exit(1) diff --git a/test/Module.py b/test/test_1000_module.py similarity index 70% rename from test/Module.py rename to test/test_1000_module.py index 190e0d1..4f1e644 100644 --- a/test/Module.py +++ b/test/test_1000_module.py @@ -1,8 +1,10 @@ #------------------------------------------------------------------------------ -# Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. #------------------------------------------------------------------------------ -"""Module for testing module methods.""" +""" +1000 - Module for testing top-level module methods +""" import TestEnv @@ -12,28 +14,28 @@ import time class TestCase(TestEnv.BaseTestCase): - def testDateFromTicks(self): - "test DateFromTicks()" + def test_1000_DateFromTicks(self): + "1000 - test DateFromTicks()" today = datetime.datetime.today() timestamp = time.mktime(today.timetuple()) date = cx_Oracle.DateFromTicks(timestamp) self.assertEqual(date, today.date()) - def testFutureObj(self): - "test management of __future__ object" + def test_1001_FutureObj(self): + "1001 - test management of __future__ object" self.assertEqual(cx_Oracle.__future__.dummy, None) cx_Oracle.__future__.dummy = "Unimportant" self.assertEqual(cx_Oracle.__future__.dummy, None) - def testTimestampFromTicks(self): - "test TimestampFromTicks()" + def test_1002_TimestampFromTicks(self): + "1002 - test TimestampFromTicks()" timestamp = time.mktime(datetime.datetime.today().timetuple()) today = datetime.datetime.fromtimestamp(timestamp) date = cx_Oracle.TimestampFromTicks(timestamp) self.assertEqual(date, today) - def testUnsupportedFunctions(self): - "test unsupported time functions" + def test_1003_UnsupportedFunctions(self): + "1003 - test unsupported time functions" self.assertRaises(cx_Oracle.NotSupportedError, cx_Oracle.Time, 12, 0, 0) self.assertRaises(cx_Oracle.NotSupportedError, cx_Oracle.TimeFromTicks, @@ -41,4 +43,3 @@ class TestCase(TestEnv.BaseTestCase): if __name__ == "__main__": TestEnv.RunTestCases() - diff --git a/test/Connection.py b/test/test_1100_connection.py similarity index 82% rename from test/Connection.py rename to test/test_1100_connection.py index 1d51ad0..e7ed298 100644 --- a/test/Connection.py +++ b/test/test_1100_connection.py @@ -1,5 +1,5 @@ #------------------------------------------------------------------------------ -# Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. # # Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved. # @@ -7,7 +7,9 @@ # Canada. All rights reserved. #------------------------------------------------------------------------------ -"""Module for testing connections.""" +""" +1100 - Module for testing connections +""" import TestEnv @@ -22,7 +24,7 @@ class TestCase(TestEnv.BaseTestCase): """Connect to the database, perform a query and drop the connection.""" connection = TestEnv.GetConnection(threaded=True) cursor = connection.cursor() - cursor.execute(u"select count(*) from TestNumbers") + cursor.execute("select count(*) from TestNumbers") count, = cursor.fetchone() self.assertEqual(count, 10) @@ -47,13 +49,13 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(connection.dsn, TestEnv.GetConnectString(), "dsn differs") - def testAllArgs(self): - "connection to database with user, password, TNS separate" + def test_1100_AllArgs(self): + "1100 - connection to database with user, password, TNS separate" connection = TestEnv.GetConnection() self.verifyArgs(connection) - def testAppContext(self): - "test use of application context" + def test_1101_AppContext(self): + "1101 - test use of application context" namespace = "CLIENTCONTEXT" appContextEntries = [ ( namespace, "ATTR1", "VALUE1" ), @@ -68,14 +70,14 @@ class TestCase(TestEnv.BaseTestCase): actualValue, = cursor.fetchone() self.assertEqual(actualValue, value) - def testAppContextNegative(self): - "test invalid use of application context" + def test_1102_AppContextNegative(self): + "1102 - test invalid use of application context" self.assertRaises(TypeError, cx_Oracle.connect, TestEnv.GetMainUser(), TestEnv.GetMainPassword(), TestEnv.GetConnectString(), appcontext=[('userenv', 'action')]) - def testAttributes(self): - "test connection end-to-end tracing attributes" + def test_1103_Attributes(self): + "1103 - test connection end-to-end tracing attributes" connection = TestEnv.GetConnection() if TestEnv.GetClientVersion() >= (12, 1) \ and not self.isOnOracleCloud(connection): @@ -94,8 +96,8 @@ class TestCase(TestEnv.BaseTestCase): "cx_OracleTest_CID", "select sys_context('userenv', 'client_identifier') from dual") - def testAutoCommit(self): - "test use of autocommit" + def test_1104_AutoCommit(self): + "1104 - test use of autocommit" connection = TestEnv.GetConnection() cursor = connection.cursor() otherConnection = TestEnv.GetConnection() @@ -111,24 +113,24 @@ class TestCase(TestEnv.BaseTestCase): rows = otherCursor.fetchall() self.assertEqual(rows, [(1,), (2,)]) - def testBadConnectString(self): - "connection to database with bad connect string" + def test_1105_BadConnectString(self): + "1105 - connection to database with bad connect string" self.assertRaises(cx_Oracle.DatabaseError, cx_Oracle.connect, TestEnv.GetMainUser()) self.assertRaises(cx_Oracle.DatabaseError, cx_Oracle.connect, - TestEnv.GetMainUser() + u"@" + TestEnv.GetConnectString()) + TestEnv.GetMainUser() + "@" + TestEnv.GetConnectString()) self.assertRaises(cx_Oracle.DatabaseError, cx_Oracle.connect, TestEnv.GetMainUser() + "@" + \ TestEnv.GetConnectString() + "/" + TestEnv.GetMainPassword()) - def testBadPassword(self): - "connection to database with bad password" + def test_1106_BadPassword(self): + "1106 - connection to database with bad password" self.assertRaises(cx_Oracle.DatabaseError, cx_Oracle.connect, TestEnv.GetMainUser(), TestEnv.GetMainPassword() + "X", TestEnv.GetConnectString()) - def testChangePassword(self): - "test changing password" + def test_1107_ChangePassword(self): + "1107 - test changing password" connection = TestEnv.GetConnection() if self.isOnOracleCloud(connection): self.skipTest("passwords on Oracle Cloud are strictly controlled") @@ -140,8 +142,8 @@ class TestCase(TestEnv.BaseTestCase): TestEnv.GetConnectString()) connection.changepassword(newPassword, TestEnv.GetMainPassword()) - def testChangePasswordNegative(self): - "test changing password to an invalid value" + def test_1108_ChangePasswordNegative(self): + "1108 - test changing password to an invalid value" connection = TestEnv.GetConnection() if self.isOnOracleCloud(connection): self.skipTest("passwords on Oracle Cloud are strictly controlled") @@ -149,8 +151,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertRaises(cx_Oracle.DatabaseError, connection.changepassword, TestEnv.GetMainPassword(), newPassword) - def testParsePassword(self): - "test connecting with password containing / and @ symbols" + def test_1109_ParsePassword(self): + "1109 - test connecting with password containing / and @ symbols" connection = TestEnv.GetConnection() if self.isOnOracleCloud(connection): self.skipTest("passwords on Oracle Cloud are strictly controlled") @@ -167,8 +169,8 @@ class TestCase(TestEnv.BaseTestCase): finally: connection.changepassword(newPassword, TestEnv.GetMainPassword()) - def testEncodings(self): - "connection with only encoding or nencoding specified should work" + def test_1110_Encodings(self): + "1110 - connection with only encoding/nencoding specified should work" connection = cx_Oracle.connect(TestEnv.GetMainUser(), TestEnv.GetMainPassword(), TestEnv.GetConnectString()) encoding = connection.encoding @@ -185,11 +187,12 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(connection.encoding, encoding) self.assertEqual(connection.nencoding, altEncoding) - def testDifferentEncodings(self): + def test_1111_DifferentEncodings(self): + "1111 - different encodings can be specified for encoding/nencoding" connection = cx_Oracle.connect(TestEnv.GetMainUser(), TestEnv.GetMainPassword(), TestEnv.GetConnectString(), encoding="UTF-8", nencoding="UTF-16") - value = u"\u03b4\u4e2a" + value = "\u03b4\u4e2a" cursor = connection.cursor() ncharVar = cursor.var(cx_Oracle.DB_TYPE_NVARCHAR, 100) ncharVar.setvalue(0, value) @@ -197,14 +200,14 @@ class TestCase(TestEnv.BaseTestCase): result, = cursor.fetchone() self.assertEqual(result, value) - def testExceptionOnClose(self): - "confirm an exception is raised after closing a connection" + def test_1112_ExceptionOnClose(self): + "1112 - confirm an exception is raised after closing a connection" connection = TestEnv.GetConnection() connection.close() self.assertRaises(cx_Oracle.InterfaceError, connection.rollback) - def testConnectWithHandle(self): - "test creating a connection using a handle" + def test_1113_ConnectWithHandle(self): + "1113 - test creating a connection using a handle" connection = TestEnv.GetConnection() cursor = connection.cursor() cursor.execute("truncate table TestTempTable") @@ -224,31 +227,28 @@ class TestCase(TestEnv.BaseTestCase): self.assertRaises(cx_Oracle.DatabaseError, cursor.execute, "select count(*) from TestTempTable") - def testMakeDSN(self): - "test making a data source name from host, port and sid" - formatString = u"(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)" + \ + def test_1114_MakeDSN(self): + "1114 - test making a data source name from host, port and sid" + formatString = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)" + \ "(HOST=%s)(PORT=%d))(CONNECT_DATA=(SID=%s)))" args = ("hostname", 1521, "TEST") result = cx_Oracle.makedsn(*args) self.assertEqual(result, formatString % args) - args = (u"hostname", 1521, u"TEST") - result = cx_Oracle.makedsn(*args) - self.assertEqual(result, formatString % args) - def testSingleArg(self): - "connection to database with user, password, DSN together" + def test_1115_SingleArg(self): + "1115 - connection to database with user, password, DSN together" connection = cx_Oracle.connect("%s/%s@%s" % \ (TestEnv.GetMainUser(), TestEnv.GetMainPassword(), TestEnv.GetConnectString())) self.verifyArgs(connection) - def testVersion(self): - "connection version is a string" + def test_1116_Version(self): + "1116 - connection version is a string" connection = TestEnv.GetConnection() self.assertTrue(isinstance(connection.version, str)) - def testRollbackOnClose(self): - "connection rolls back before close" + def test_1117_RollbackOnClose(self): + "1117 - connection rolls back before close" connection = TestEnv.GetConnection() cursor = connection.cursor() cursor.execute("truncate table TestTempTable") @@ -261,8 +261,8 @@ class TestCase(TestEnv.BaseTestCase): count, = cursor.fetchone() self.assertEqual(count, 0) - def testRollbackOnDel(self): - "connection rolls back before destruction" + def test_1118_RollbackOnDel(self): + "1118 - connection rolls back before destruction" connection = TestEnv.GetConnection() cursor = connection.cursor() cursor.execute("truncate table TestTempTable") @@ -275,8 +275,8 @@ class TestCase(TestEnv.BaseTestCase): count, = cursor.fetchone() self.assertEqual(count, 0) - def testThreading(self): - "connection to database with multiple threads" + def test_1119_Threading(self): + "1119 - connection to database with multiple threads" threads = [] for i in range(20): thread = threading.Thread(None, self.__ConnectAndDrop) @@ -285,15 +285,15 @@ class TestCase(TestEnv.BaseTestCase): for thread in threads: thread.join() - def testStringFormat(self): - "test string format of connection" + def test_1120_StringFormat(self): + "1120 - test string format of connection" connection = TestEnv.GetConnection() expectedValue = "" % \ (TestEnv.GetMainUser(), TestEnv.GetConnectString()) self.assertEqual(str(connection), expectedValue) - def testCtxMgrClose(self): - "test context manager - close" + def test_1121_CtxMgrClose(self): + "1121 - test context manager - close" connection = TestEnv.GetConnection() with connection: cursor = connection.cursor() @@ -308,8 +308,8 @@ class TestCase(TestEnv.BaseTestCase): count, = cursor.fetchone() self.assertEqual(count, 1) - def testConnectionAttributes(self): - "test connection attribute values" + def test_1122_ConnectionAttributes(self): + "1122 - test connection attribute values" connection = cx_Oracle.connect(TestEnv.GetMainUser(), TestEnv.GetMainPassword(), TestEnv.GetConnectString(), encoding="ASCII") @@ -333,8 +333,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertRaises(TypeError, connection.stmtcachesize, 20.5) self.assertRaises(TypeError, connection.stmtcachesize, "value") - def testClosedConnectionAttributes(self): - "test closed connection attribute values" + def test_1123_ClosedConnectionAttributes(self): + "1123 - test closed connection attribute values" connection = TestEnv.GetConnection() connection.close() attrNames = ["current_schema", "edition", "external_name", @@ -345,13 +345,13 @@ class TestCase(TestEnv.BaseTestCase): self.assertRaises(cx_Oracle.InterfaceError, getattr, connection, name) - def testPing(self): - "test connection ping" + def test_1124_Ping(self): + "1124 - test connection ping" connection = TestEnv.GetConnection() connection.ping() - def testTransactionBegin(self): - "test begin, prepare, cancel transaction" + def test_1125_TransactionBegin(self): + "1125 - test begin, prepare, cancel transaction" connection = TestEnv.GetConnection() cursor = connection.cursor() cursor.execute("truncate table TestTempTable") @@ -370,4 +370,3 @@ class TestCase(TestEnv.BaseTestCase): if __name__ == "__main__": TestEnv.RunTestCases() - diff --git a/test/Cursor.py b/test/test_1200_cursor.py similarity index 77% rename from test/Cursor.py rename to test/test_1200_cursor.py index 7e871d3..9bcee39 100644 --- a/test/Cursor.py +++ b/test/test_1200_cursor.py @@ -1,5 +1,5 @@ #------------------------------------------------------------------------------ -# Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. # # Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved. # @@ -7,7 +7,9 @@ # Canada. All rights reserved. #------------------------------------------------------------------------------ -"""Module for testing cursor objects.""" +""" +1200 - Module for testing cursors +""" import TestEnv @@ -17,8 +19,8 @@ import sys class TestCase(TestEnv.BaseTestCase): - def testCreateScrollableCursor(self): - """test creating a scrollable cursor""" + def test_1200_CreateScrollableCursor(self): + "1200 - test creating a scrollable cursor" cursor = self.connection.cursor() self.assertEqual(cursor.scrollable, False) cursor = self.connection.cursor(True) @@ -28,18 +30,18 @@ class TestCase(TestEnv.BaseTestCase): cursor.scrollable = False self.assertEqual(cursor.scrollable, False) - def testExecuteNoArgs(self): - """test executing a statement without any arguments""" + def test_1201_ExecuteNoArgs(self): + "1201 - test executing a statement without any arguments" result = self.cursor.execute("begin null; end;") self.assertEqual(result, None) - def testExecuteNoStatementWithArgs(self): - """test executing a None statement with bind variables""" + def test_1202_ExecuteNoStatementWithArgs(self): + "1202 - test executing a None statement with bind variables" self.assertRaises(cx_Oracle.ProgrammingError, self.cursor.execute, None, x = 5) - def testExecuteEmptyKeywordArgs(self): - """test executing a statement with args and empty keyword args""" + def test_1203_ExecuteEmptyKeywordArgs(self): + "1203 - test executing a statement with args and empty keyword args" simpleVar = self.cursor.var(cx_Oracle.NUMBER) args = [simpleVar] kwArgs = {} @@ -47,47 +49,43 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(result, None) self.assertEqual(simpleVar.getvalue(), 25) - def testExecuteKeywordArgs(self): - """test executing a statement with keyword arguments""" + def test_1204_ExecuteKeywordArgs(self): + "1204 - test executing a statement with keyword arguments" simpleVar = self.cursor.var(cx_Oracle.NUMBER) result = self.cursor.execute("begin :value := 5; end;", value = simpleVar) self.assertEqual(result, None) self.assertEqual(simpleVar.getvalue(), 5) - def testExecuteDictionaryArg(self): - """test executing a statement with a dictionary argument""" + def test_1205_ExecuteDictionaryArg(self): + "1205 - test executing a statement with a dictionary argument" simpleVar = self.cursor.var(cx_Oracle.NUMBER) dictArg = { "value" : simpleVar } result = self.cursor.execute("begin :value := 10; end;", dictArg) self.assertEqual(result, None) self.assertEqual(simpleVar.getvalue(), 10) - dictArg = { u"value" : simpleVar } - result = self.cursor.execute("begin :value := 25; end;", dictArg) - self.assertEqual(result, None) - self.assertEqual(simpleVar.getvalue(), 25) - def testExecuteMultipleMethod(self): - """test executing a statement with both a dict arg and keyword args""" + def test_1206_ExecuteMultipleMethod(self): + "1206 - test executing a statement with both a dict and keyword args" simpleVar = self.cursor.var(cx_Oracle.NUMBER) dictArg = { "value" : simpleVar } self.assertRaises(cx_Oracle.InterfaceError, self.cursor.execute, "begin :value := 15; end;", dictArg, value = simpleVar) - def testExecuteAndModifyArraySize(self): - """test executing a statement and then changing the array size""" + def test_1207_ExecuteAndModifyArraySize(self): + "1207 - test executing a statement and then changing the array size" self.cursor.execute("select IntCol from TestNumbers") self.cursor.arraysize = 20 self.assertEqual(len(self.cursor.fetchall()), 10) - def testCallProc(self): - """test executing a stored procedure""" + def test_1208_CallProc(self): + "1208 - test executing a stored procedure" var = self.cursor.var(cx_Oracle.NUMBER) results = self.cursor.callproc("proc_Test", ("hi", 5, var)) self.assertEqual(results, ["hi", 10, 2.0]) - def testCallProcAllKeywords(self): - "test executing a stored procedure with args in keywordParameters" + def test_1209_CallProcAllKeywords(self): + "1209 - test executing a stored procedure with keyword args" kwargs = dict(a_InOutValue=self.cursor.var(cx_Oracle.NUMBER), a_InValue="hi", a_OutValue=self.cursor.var(cx_Oracle.NUMBER)) kwargs['a_InOutValue'].setvalue(0, 5) @@ -96,38 +94,38 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(kwargs['a_InOutValue'].getvalue(), 10) self.assertEqual(kwargs['a_OutValue'].getvalue(), 2.0) - def testCallProcOnlyLastKeyword(self): - "test executing a stored procedure with last arg in keywordParameters" + def test_1210_CallProcOnlyLastKeyword(self): + "1210 - test executing a stored procedure with last arg as keyword arg" kwargs = dict(a_OutValue = self.cursor.var(cx_Oracle.NUMBER)) results = self.cursor.callproc("proc_Test", ("hi", 5), kwargs) self.assertEqual(results, ["hi", 10]) self.assertEqual(kwargs['a_OutValue'].getvalue(), 2.0) - def testCallProcRepeatedKeywordParameters(self): - "test executing a stored procedure, repeated arg in keywordParameters" + def test_1211_CallProcRepeatedKeywordParameters(self): + "1211 - test executing a stored procedure, repeated keyword arg" kwargs = dict(a_InValue="hi", a_OutValue=self.cursor.var(cx_Oracle.NUMBER)) self.assertRaises(cx_Oracle.DatabaseError, self.cursor.callproc, "proc_Test", parameters=("hi", 5), keywordParameters=kwargs) - def testCallProcNoArgs(self): - """test executing a stored procedure without any arguments""" - results = self.cursor.callproc(u"proc_TestNoArgs") + def test_1212_CallProcNoArgs(self): + "1212 - test executing a stored procedure without any arguments" + results = self.cursor.callproc("proc_TestNoArgs") self.assertEqual(results, []) - def testCallFunc(self): - """test executing a stored function""" - results = self.cursor.callfunc(u"func_Test", cx_Oracle.NUMBER, - (u"hi", 5)) + def test_1213_CallFunc(self): + "1213 - test executing a stored function" + results = self.cursor.callfunc("func_Test", cx_Oracle.NUMBER, + ("hi", 5)) self.assertEqual(results, 7) - def testCallFuncNoArgs(self): - """test executing a stored function without any arguments""" + def test_1214_CallFuncNoArgs(self): + "1214 - test executing a stored function without any arguments" results = self.cursor.callfunc("func_TestNoArgs", cx_Oracle.NUMBER) self.assertEqual(results, 712) - def testCallFuncNegative(self): - """test executing a stored function with wrong parameters""" + def test_1215_CallFuncNegative(self): + "1215 - test executing a stored function with wrong parameters" funcName = "func_Test" self.assertRaises(TypeError, self.cursor.callfunc, cx_Oracle.NUMBER, funcName, ("hi", 5)) @@ -142,10 +140,10 @@ class TestCase(TestEnv.BaseTestCase): self.assertRaises(TypeError, self.cursor.callfunc, funcName, cx_Oracle.NUMBER, 5) - def testExecuteManyByName(self): - """test executing a statement multiple times (named args)""" + def test_1216_ExecuteManyByName(self): + "1216 - test executing a statement multiple times (named args)" self.cursor.execute("truncate table TestTempTable") - rows = [ { u"value" : n } for n in range(250) ] + rows = [ { "value" : n } for n in range(250) ] self.cursor.arraysize = 100 statement = "insert into TestTempTable (IntCol) values (:value)" self.cursor.executemany(statement, rows) @@ -154,8 +152,8 @@ class TestCase(TestEnv.BaseTestCase): count, = self.cursor.fetchone() self.assertEqual(count, len(rows)) - def testExecuteManyByPosition(self): - """test executing a statement multiple times (positional args)""" + def test_1217_ExecuteManyByPosition(self): + "1217 - test executing a statement multiple times (positional args)" self.cursor.execute("truncate table TestTempTable") rows = [ [n] for n in range(230) ] self.cursor.arraysize = 100 @@ -166,8 +164,8 @@ class TestCase(TestEnv.BaseTestCase): count, = self.cursor.fetchone() self.assertEqual(count, len(rows)) - def testExecuteManyWithPrepare(self): - """test executing a statement multiple times (with prepare)""" + def test_1218_ExecuteManyWithPrepare(self): + "1218 - test executing a statement multiple times (with prepare)" self.cursor.execute("truncate table TestTempTable") rows = [ [n] for n in range(225) ] self.cursor.arraysize = 100 @@ -179,8 +177,8 @@ class TestCase(TestEnv.BaseTestCase): count, = self.cursor.fetchone() self.assertEqual(count, len(rows)) - def testExecuteManyWithRebind(self): - """test executing a statement multiple times (with rebind)""" + def test_1219_ExecuteManyWithRebind(self): + "1219 - test executing a statement multiple times (with rebind)" self.cursor.execute("truncate table TestTempTable") rows = [ [n] for n in range(235) ] self.cursor.arraysize = 100 @@ -192,22 +190,22 @@ class TestCase(TestEnv.BaseTestCase): count, = self.cursor.fetchone() self.assertEqual(count, len(rows)) - def testExecuteManyWithInputSizesWrong(self): - "test executing a statement multiple times (with input sizes wrong)" + def test_1220_ExecuteManyWithInputSizesWrong(self): + "1220 - test executing multiple times (with input sizes wrong)" cursor = self.connection.cursor() cursor.setinputsizes(cx_Oracle.NUMBER) data = [[decimal.Decimal("25.8")], [decimal.Decimal("30.0")]] cursor.executemany("declare t number; begin t := :1; end;", data) - def testExecuteManyMultipleBatches(self): - "test executing a statement multiple times (with multiple batches)" + def test_1221_ExecuteManyMultipleBatches(self): + "1221 - test executing multiple times (with multiple batches)" self.cursor.execute("truncate table TestTempTable") sql = "insert into TestTempTable (IntCol, StringCol) values (:1, :2)" self.cursor.executemany(sql, [(1, None), (2, None)]) self.cursor.executemany(sql, [(3, None), (4, "Testing")]) - def testExecuteManyNumeric(self): - "test executemany() with various numeric types" + def test_1222_ExecuteManyNumeric(self): + "1222 - test executemany() with various numeric types" self.cursor.execute("truncate table TestTempTable") data = [(1, 5), (2, 7.0), (3, 6.5), (4, 2 ** 65), (5, decimal.Decimal("24.5"))] @@ -219,8 +217,8 @@ class TestCase(TestEnv.BaseTestCase): order by IntCol""") self.assertEqual(self.cursor.fetchall(), data) - def testExecuteManyWithResize(self): - """test executing a statement multiple times (with resize)""" + def test_1223_ExecuteManyWithResize(self): + "1223 - test executing a statement multiple times (with resize)" self.cursor.execute("truncate table TestTempTable") rows = [ ( 1, "First" ), ( 2, "Second" ), @@ -238,8 +236,8 @@ class TestCase(TestEnv.BaseTestCase): fetchedRows = self.cursor.fetchall() self.assertEqual(fetchedRows, rows) - def testExecuteManyWithExecption(self): - """test executing a statement multiple times (with exception)""" + def test_1224_ExecuteManyWithExecption(self): + "1224 - test executing a statement multiple times (with exception)" self.cursor.execute("truncate table TestTempTable") rows = [ { "value" : n } for n in (1, 2, 3, 2, 5) ] statement = "insert into TestTempTable (IntCol) values (:value)" @@ -247,14 +245,14 @@ class TestCase(TestEnv.BaseTestCase): statement, rows) self.assertEqual(self.cursor.rowcount, 3) - def testExecuteManyWithInvalidParameters(self): - "test calling executemany() with invalid parameters" + def test_1225_ExecuteManyWithInvalidParameters(self): + "1225 - test calling executemany() with invalid parameters" self.assertRaises(TypeError, self.cursor.executemany, "insert into TestTempTable (IntCol, StringCol) values (:1, :2)", "These are not valid parameters") - def testExecuteManyNoParameters(self): - "test calling executemany() without any bind parameters" + def test_1226_ExecuteManyNoParameters(self): + "1226 - test calling executemany() without any bind parameters" numRows = 5 self.cursor.execute("truncate table TestTempTable") self.cursor.executemany(""" @@ -272,8 +270,8 @@ class TestCase(TestEnv.BaseTestCase): count, = self.cursor.fetchone() self.assertEqual(count, numRows) - def testExecuteManyBoundEarlier(self): - "test calling executemany() with binds performed earlier" + def test_1227_ExecuteManyBoundEarlier(self): + "1227 - test calling executemany() with binds performed earlier" numRows = 9 self.cursor.execute("truncate table TestTempTable") var = self.cursor.var(int, arraysize = numRows) @@ -295,8 +293,8 @@ class TestCase(TestEnv.BaseTestCase): expectedData = [1, 3, 6, 10, 15, 21, 28, 36, 45] self.assertEqual(var.values, expectedData) - def testPrepare(self): - """test preparing a statement and executing it multiple times""" + def test_1228_Prepare(self): + "1228 - test preparing a statement and executing it multiple times" self.assertEqual(self.cursor.statement, None) statement = "begin :value := :value + 5; end;" self.cursor.prepare(statement) @@ -310,14 +308,14 @@ class TestCase(TestEnv.BaseTestCase): self.cursor.execute("begin :value2 := 3; end;", value2 = var) self.assertEqual(var.getvalue(), 3) - def testExceptionOnClose(self): - "confirm an exception is raised after closing a cursor" + def test_1229_ExceptionOnClose(self): + "1229 - confirm an exception is raised after closing a cursor" self.cursor.close() self.assertRaises(cx_Oracle.InterfaceError, self.cursor.execute, "select 1 from dual") - def testIterators(self): - """test iterators""" + def test_1230_Iterators(self): + "1230 - test iterators" self.cursor.execute(""" select IntCol from TestNumbers @@ -328,8 +326,8 @@ class TestCase(TestEnv.BaseTestCase): rows.append(row[0]) self.assertEqual(rows, [1, 2, 3]) - def testIteratorsInterrupted(self): - """test iterators (with intermediate execute)""" + def test_1231_IteratorsInterrupted(self): + "1231 - test iterators (with intermediate execute)" self.cursor.execute("truncate table TestTempTable") self.cursor.execute(""" select IntCol @@ -347,10 +345,10 @@ class TestCase(TestEnv.BaseTestCase): else: self.assertRaises(cx_Oracle.InterfaceError, testIter.next) - def testBindNames(self): - """test that bindnames() works correctly.""" + def test_1232_BindNames(self): + "1232 - test that bindnames() works correctly." self.assertRaises(cx_Oracle.ProgrammingError, self.cursor.bindnames) - self.cursor.prepare(u"begin null; end;") + self.cursor.prepare("begin null; end;") self.assertEqual(self.cursor.bindnames(), []) self.cursor.prepare("begin :retval := :inval + 5; end;") self.assertEqual(self.cursor.bindnames(), ["RETVAL", "INVAL"]) @@ -363,22 +361,22 @@ class TestCase(TestEnv.BaseTestCase): self.cursor.prepare("select :a * :a + :b * :b from dual") self.assertEqual(self.cursor.bindnames(), ["A", "B"]) - def testBadPrepare(self): - """test that subsequent executes succeed after bad prepare""" + def test_1233_BadPrepare(self): + "1233 - test that subsequent executes succeed after bad prepare" self.assertRaises(cx_Oracle.DatabaseError, self.cursor.execute, "begin raise_application_error(-20000, 'this); end;") self.cursor.execute("begin null; end;") - def testBadExecute(self): - """test that subsequent fetches fail after bad execute""" + def test_1234_BadExecute(self): + "1234 - test that subsequent fetches fail after bad execute" self.assertRaises(cx_Oracle.DatabaseError, self.cursor.execute, "select y from dual") self.assertRaises(cx_Oracle.InterfaceError, self.cursor.fetchall) - def testScrollAbsoluteExceptionAfter(self): - """test scrolling absolute yields an exception (after result set)""" + def test_1235_ScrollAbsoluteExceptionAfter(self): + "1235 - test scrolling absolute yields an exception (after result set)" cursor = self.connection.cursor(scrollable = True) cursor.arraysize = self.cursor.arraysize cursor.execute(""" @@ -388,8 +386,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertRaises(cx_Oracle.DatabaseError, cursor.scroll, 12, "absolute") - def testScrollAbsoluteInBuffer(self): - """test scrolling absolute (when in buffers)""" + def test_1236_ScrollAbsoluteInBuffer(self): + "1236 - test scrolling absolute (when in buffers)" cursor = self.connection.cursor(scrollable = True) cursor.arraysize = self.cursor.arraysize cursor.execute(""" @@ -404,8 +402,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(row[0], 1.25) self.assertEqual(cursor.rowcount, 1) - def testScrollAbsoluteNotInBuffer(self): - """test scrolling absolute (when not in buffers)""" + def test_1237_ScrollAbsoluteNotInBuffer(self): + "1237 - test scrolling absolute (when not in buffers)" cursor = self.connection.cursor(scrollable = True) cursor.arraysize = self.cursor.arraysize cursor.execute(""" @@ -417,8 +415,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(row[0], 7.5) self.assertEqual(cursor.rowcount, 6) - def testScrollFirstInBuffer(self): - """test scrolling to first row in result set (when in buffers)""" + def test_1238_ScrollFirstInBuffer(self): + "1238 - test scrolling to first row in result set (in buffers)" cursor = self.connection.cursor(scrollable = True) cursor.arraysize = self.cursor.arraysize cursor.execute(""" @@ -431,8 +429,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(row[0], 1.25) self.assertEqual(cursor.rowcount, 1) - def testScrollFirstNotInBuffer(self): - """test scrolling to first row in result set (when not in buffers)""" + def test_1239_ScrollFirstNotInBuffer(self): + "1239 - test scrolling to first row in result set (not in buffers)" cursor = self.connection.cursor(scrollable = True) cursor.arraysize = self.cursor.arraysize cursor.execute(""" @@ -446,8 +444,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(row[0], 1.25) self.assertEqual(cursor.rowcount, 1) - def testScrollLast(self): - """test scrolling to last row in result set""" + def test_1240_ScrollLast(self): + "1240 - test scrolling to last row in result set" cursor = self.connection.cursor(scrollable = True) cursor.arraysize = self.cursor.arraysize cursor.execute(""" @@ -459,8 +457,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(row[0], 12.5) self.assertEqual(cursor.rowcount, 10) - def testScrollRelativeExceptionAfter(self): - """test scrolling relative yields an exception (after result set)""" + def test_1241_ScrollRelativeExceptionAfter(self): + "1241 - test scrolling relative yields an exception (after result set)" cursor = self.connection.cursor(scrollable = True) cursor.arraysize = self.cursor.arraysize cursor.execute(""" @@ -469,8 +467,8 @@ class TestCase(TestEnv.BaseTestCase): order by IntCol""") self.assertRaises(cx_Oracle.DatabaseError, cursor.scroll, 15) - def testScrollRelativeExceptionBefore(self): - """test scrolling relative yields an exception (before result set)""" + def test_1242_ScrollRelativeExceptionBefore(self): + "1242 - test scrolling relative yields exception (before result set)" cursor = self.connection.cursor(scrollable = True) cursor.arraysize = self.cursor.arraysize cursor.execute(""" @@ -479,8 +477,8 @@ class TestCase(TestEnv.BaseTestCase): order by IntCol""") self.assertRaises(cx_Oracle.DatabaseError, cursor.scroll, -5) - def testScrollRelativeInBuffer(self): - """test scrolling relative (when in buffers)""" + def test_1243_ScrollRelativeInBuffer(self): + "1243 - test scrolling relative (when in buffers)" cursor = self.connection.cursor(scrollable = True) cursor.arraysize = self.cursor.arraysize cursor.execute(""" @@ -495,8 +493,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(row[0], 2.5) self.assertEqual(cursor.rowcount, 2) - def testScrollRelativeNotInBuffer(self): - """test scrolling relative (when not in buffers)""" + def test_1244_ScrollRelativeNotInBuffer(self): + "1244 - test scrolling relative (when not in buffers)" cursor = self.connection.cursor(scrollable = True) cursor.arraysize = self.cursor.arraysize cursor.execute(""" @@ -512,8 +510,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(row[0], 3.75) self.assertEqual(cursor.rowcount, 3) - def testScrollNoRows(self): - """test scrolling when there are no rows""" + def test_1245_ScrollNoRows(self): + "1245 - test scrolling when there are no rows" self.cursor.execute("truncate table TestTempTable") cursor = self.connection.cursor(scrollable = True) cursor.execute("select * from TestTempTable") @@ -524,8 +522,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertRaises(cx_Oracle.DatabaseError, cursor.scroll, 1, mode = "absolute") - def testScrollDifferingArrayAndFetchSizes(self): - """test scrolling with differing array sizes and fetch array sizes""" + def test_1246_ScrollDifferingArrayAndFetchSizes(self): + "1246 - test scrolling with differing array and fetch array sizes" self.cursor.execute("truncate table TestTempTable") for i in range(30): self.cursor.execute(""" @@ -553,62 +551,62 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(cursor.rowcount, 15 + numRows + numRowsFetched + numRows - 6) - def testSetInputSizesNegative(self): - "test cursor.setinputsizes() with invalid parameters" + def test_1247_SetInputSizesNegative(self): + "1247 - test cursor.setinputsizes() with invalid parameters" val = decimal.Decimal(5) self.assertRaises(cx_Oracle.InterfaceError, self.cursor.setinputsizes, val, x = val) self.assertRaises(TypeError, self.cursor.setinputsizes, val) - def testSetInputSizesNoParameters(self): - "test setting input sizes without any parameters" + def test_1248_SetInputSizesNoParameters(self): + "1248 - test setting input sizes without any parameters" self.cursor.setinputsizes() self.cursor.execute("select :val from dual", val = "Test Value") self.assertEqual(self.cursor.fetchall(), [("Test Value",)]) - def testSetInputSizesEmptyDict(self): - "test setting input sizes with an empty dictionary" + def test_1249_SetInputSizesEmptyDict(self): + "1249 - test setting input sizes with an empty dictionary" emptyDict = {} self.cursor.prepare("select 236 from dual") self.cursor.setinputsizes(**emptyDict) self.cursor.execute(None, emptyDict) self.assertEqual(self.cursor.fetchall(), [(236,)]) - def testSetInputSizesEmptyList(self): - "test setting input sizes with an empty list" + def test_1250_SetInputSizesEmptyList(self): + "1250 - test setting input sizes with an empty list" emptyList = {} self.cursor.prepare("select 239 from dual") self.cursor.setinputsizes(*emptyList) self.cursor.execute(None, emptyList) self.assertEqual(self.cursor.fetchall(), [(239,)]) - def testSetInputSizesByPosition(self): - """test setting input sizes with positional args""" + def test_1251_SetInputSizesByPosition(self): + "1251 - test setting input sizes with positional args" var = self.cursor.var(cx_Oracle.STRING, 100) self.cursor.setinputsizes(None, 5, None, 10, None, cx_Oracle.NUMBER) self.cursor.execute(""" begin :1 := :2 || to_char(:3) || :4 || to_char(:5) || to_char(:6); end;""", [var, 'test_', 5, '_second_', 3, 7]) - self.assertEqual(var.getvalue(), u"test_5_second_37") + self.assertEqual(var.getvalue(), "test_5_second_37") - def testStringFormat(self): - """test string format of cursor""" + def test_1252_StringFormat(self): + "1252 - test string format of cursor" formatString = ">" expectedValue = formatString % \ (TestEnv.GetMainUser(), TestEnv.GetConnectString()) self.assertEqual(str(self.cursor), expectedValue) - def testCursorFetchRaw(self): - """test cursor.fetchraw()""" + def test_1253_CursorFetchRaw(self): + "1253 - test cursor.fetchraw()" cursor = self.connection.cursor() cursor.arraysize = 25 cursor.execute("select LongIntCol from TestNumbers order by IntCol") self.assertEqual(cursor.fetchraw(), 10) self.assertEqual(cursor.fetchvars[0].getvalue(), 38) - def testParse(self): - """test parsing statements""" + def test_1254_Parse(self): + "1254 - test parsing statements" sql = "select LongIntCol from TestNumbers where IntCol = :val" self.cursor.parse(sql) self.assertEqual(self.cursor.statement, sql) @@ -616,20 +614,20 @@ class TestCase(TestEnv.BaseTestCase): [ ('LONGINTCOL', cx_Oracle.DB_TYPE_NUMBER, 17, None, 16, 0, 0) ]) - def testSetOutputSize(self): - "test cursor.setoutputsize() does not fail (but does nothing)" + def test_1255_SetOutputSize(self): + "1255 - test cursor.setoutputsize() does not fail (but does nothing)" self.cursor.setoutputsize(100, 2) - def testVarNegative(self): - "test cursor.var() with invalid parameters" + def test_1256_VarNegative(self): + "1256 - test cursor.var() with invalid parameters" self.assertRaises(TypeError, self.cursor.var, 5) - def testArrayVarNegative(self): - "test cursor.arrayvar() with invalid parameters" + def test_1257_ArrayVarNegative(self): + "1257 - test cursor.arrayvar() with invalid parameters" self.assertRaises(TypeError, self.cursor.arrayvar, 5, 1) - def testBooleanWithoutPlsql(self): - "test binding boolean data without the use of PL/SQL" + def test_1258_BooleanWithoutPlsql(self): + "1258 - test binding boolean data without the use of PL/SQL" self.cursor.execute("truncate table TestTempTable") sql = "insert into TestTempTable (IntCol, StringCol) values (:1, :2)" self.cursor.execute(sql, (False, "Value should be 0")) @@ -641,8 +639,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(self.cursor.fetchall(), [ (0, "Value should be 0"), (1, "Value should be 1") ]) - def testAsContextManager(self): - "test using a cursor as a context manager" + def test_1259_AsContextManager(self): + "1259 - test using a cursor as a context manager" with self.cursor as cursor: cursor.execute("truncate table TestTempTable") cursor.execute("select count(*) from TestTempTable") @@ -650,8 +648,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(count, 0) self.assertRaises(cx_Oracle.InterfaceError, self.cursor.close) - def testQueryRowCount(self): - "test that the rowcount attribute is reset to zero on query execute" + def test_1260_QueryRowCount(self): + "1260 - test that rowcount attribute is reset to zero on query execute" sql = "select * from dual where 1 = :s" self.cursor.execute(sql, [0]) self.cursor.fetchone() @@ -666,15 +664,15 @@ class TestCase(TestEnv.BaseTestCase): self.cursor.fetchone() self.assertEqual(self.cursor.rowcount, 0) - def testVarTypeNameNone(self): - "test that the typename attribute can be passed a value of None" + def test_1261_VarTypeNameNone(self): + "1261 - test that the typename attribute can be passed a value of None" valueToSet = 5 var = self.cursor.var(int, typename=None) var.setvalue(0, valueToSet) self.assertEqual(var.getvalue(), valueToSet) - def testVarTypeWithObjectType(self): - "test that an object type can be used as type in cursor.var()" + def test_1262_VarTypeWithObjectType(self): + "1262 - test that an object type can be used as type in cursor.var()" objType = self.connection.gettype("UDT_OBJECT") var = self.cursor.var(objType) self.cursor.callproc("pkg_TestBindObject.BindObjectOut", @@ -685,8 +683,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(result, "udt_Object(28, 'Bind obj out', null, null, null, null, null)") - def testFetchXMLType(self): - "test that fetching an XMLType returns a string contains its contents" + def test_1263_FetchXMLType(self): + "1263 - test that fetching an XMLType returns a string" intVal = 5 label = "IntCol" expectedResult = "<%s>%s" % (label, intVal, label) @@ -698,8 +696,8 @@ class TestCase(TestEnv.BaseTestCase): result, = self.cursor.fetchone() self.assertEqual(result, expectedResult) - def testLastRowid(self): - "test last rowid" + def test_1264_LastRowid(self): + "1264 - test last rowid" # no statement executed: no rowid self.assertEqual(None, self.cursor.lastrowid) @@ -750,8 +748,8 @@ class TestCase(TestEnv.BaseTestCase): where rowid = :1""", [rowid]) self.assertEqual("Row %s" % rows[-3], self.cursor.fetchone()[0]) - def testPrefetchRows(self): - "test prefetch rows" + def test_1265_PrefetchRows(self): + "1265 - test prefetch rows" self.setUpRoundTripChecker() # perform simple query and verify only one round trip is needed diff --git a/test/CursorVar.py b/test/test_1300_cursor_var.py similarity index 85% rename from test/CursorVar.py rename to test/test_1300_cursor_var.py index 41e0fd6..587c7ca 100644 --- a/test/CursorVar.py +++ b/test/test_1300_cursor_var.py @@ -7,7 +7,9 @@ # Canada. All rights reserved. #------------------------------------------------------------------------------ -"""Module for testing cursor variables.""" +""" +1300 - Module for testing cursor variables +""" import TestEnv @@ -16,8 +18,8 @@ import sys class TestCase(TestEnv.BaseTestCase): - def testBindCursor(self): - "test binding in a cursor" + def test_1300_BindCursor(self): + "1300 - test binding in a cursor" cursor = self.connection.cursor() self.assertEqual(cursor.description, None) self.cursor.execute(""" @@ -30,8 +32,8 @@ class TestCase(TestEnv.BaseTestCase): TestEnv.GetCharSetRatio(), None, None, 1) ]) self.assertEqual(cursor.fetchall(), [('X',)]) - def testBindCursorInPackage(self): - "test binding in a cursor from a package" + def test_1301_BindCursorInPackage(self): + "1301 - test binding in a cursor from a package" cursor = self.connection.cursor() self.assertEqual(cursor.description, None) self.cursor.callproc("pkg_TestRefCursors.TestOutCursor", (2, cursor)) @@ -42,8 +44,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(cursor.fetchall(), [ (1, 'String 1'), (2, 'String 2') ]) - def testBindSelf(self): - "test that binding the cursor itself is not supported" + def test_1302_BindSelf(self): + "1302 - test that binding the cursor itself is not supported" cursor = self.connection.cursor() sql = """ begin @@ -53,8 +55,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertRaises(cx_Oracle.DatabaseError, cursor.execute, sql, pcursor = cursor) - def testExecuteAfterClose(self): - "test executing a statement returning a ref cursor after closing it" + def test_1303_ExecuteAfterClose(self): + "1303 - test returning a ref cursor after closing it" outCursor = self.connection.cursor() sql = """ begin @@ -71,8 +73,8 @@ class TestCase(TestEnv.BaseTestCase): rows2 = outCursor.fetchall() self.assertEqual(rows, rows2) - def testFetchCursor(self): - "test fetching a cursor" + def test_1304_FetchCursor(self): + "1304 - test fetching a cursor" self.cursor.execute(""" select IntCol, diff --git a/test/DateTimeVar.py b/test/test_1400_datetime_var.py similarity index 81% rename from test/DateTimeVar.py rename to test/test_1400_datetime_var.py index 0cf84d9..b97ce0e 100644 --- a/test/DateTimeVar.py +++ b/test/test_1400_datetime_var.py @@ -1,5 +1,5 @@ #------------------------------------------------------------------------------ -# Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. # # Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved. # @@ -7,7 +7,9 @@ # Canada. All rights reserved. #------------------------------------------------------------------------------ -"""Module for testing date/time variables.""" +""" +1400 - Module for testing date/time variables +""" import TestEnv @@ -35,31 +37,31 @@ class TestCase(TestEnv.BaseTestCase): self.rawData.append(tuple) self.dataByKey[i] = tuple - def testBindDate(self): - "test binding in a date" + def test_1400_BindDate(self): + "1400 - test binding in a date" self.cursor.execute(""" select * from TestDates where DateCol = :value""", value = cx_Oracle.Timestamp(2002, 12, 13, 9, 36, 0)) self.assertEqual(self.cursor.fetchall(), [self.dataByKey[4]]) - def testBindDateTime(self): - "test binding in a datetime.datetime value" + def test_1401_BindDateTime(self): + "1401 - test binding in a datetime.datetime value" self.cursor.execute(""" select * from TestDates where DateCol = :value""", value = datetime.datetime(2002, 12, 13, 9, 36, 0)) self.assertEqual(self.cursor.fetchall(), [self.dataByKey[4]]) - def testBindDateInDateTimeVar(self): - "test binding date in a datetime variable" + def test_1402_BindDateInDateTimeVar(self): + "1402 - test binding date in a datetime variable" var = self.cursor.var(cx_Oracle.DATETIME) dateVal = datetime.date.today() var.setvalue(0, dateVal) self.assertEqual(var.getvalue().date(), dateVal) - def testBindDateAfterString(self): - "test binding in a date after setting input sizes to a string" + def test_1403_BindDateAfterString(self): + "1403 - test binding in a date after setting input sizes to a string" self.cursor.setinputsizes(value = 15) self.cursor.execute(""" select * from TestDates @@ -67,8 +69,8 @@ class TestCase(TestEnv.BaseTestCase): value = cx_Oracle.Timestamp(2002, 12, 14, 12, 0, 0)) self.assertEqual(self.cursor.fetchall(), [self.dataByKey[5]]) - def testBindNull(self): - "test binding in a null" + def test_1404_BindNull(self): + "1404 - test binding in a null" self.cursor.setinputsizes(value = cx_Oracle.DATETIME) self.cursor.execute(""" select * from TestDates @@ -76,8 +78,8 @@ class TestCase(TestEnv.BaseTestCase): value = None) self.assertEqual(self.cursor.fetchall(), []) - def testBindDateArrayDirect(self): - "test binding in a date array" + def test_1405_BindDateArrayDirect(self): + "1405 - test binding in a date array" returnValue = self.cursor.var(cx_Oracle.NUMBER) array = [r[1] for r in self.rawData] statement = """ @@ -98,8 +100,8 @@ class TestCase(TestEnv.BaseTestCase): array = array) self.assertEqual(returnValue.getvalue(), 24.0) - def testBindDateArrayBySizes(self): - "test binding in a date array (with setinputsizes)" + def test_1406_BindDateArrayBySizes(self): + "1406 - test binding in a date array (with setinputsizes)" returnValue = self.cursor.var(cx_Oracle.NUMBER) self.cursor.setinputsizes(array = [cx_Oracle.DATETIME, 10]) array = [r[1] for r in self.rawData] @@ -114,8 +116,8 @@ class TestCase(TestEnv.BaseTestCase): array = array) self.assertEqual(returnValue.getvalue(), 26.5) - def testBindDateArrayByVar(self): - "test binding in a date array (with arrayvar)" + def test_1407_BindDateArrayByVar(self): + "1407 - test binding in a date array (with arrayvar)" returnValue = self.cursor.var(cx_Oracle.NUMBER) array = self.cursor.arrayvar(cx_Oracle.DATETIME, 10, 20) array.setvalue(0, [r[1] for r in self.rawData]) @@ -130,8 +132,8 @@ class TestCase(TestEnv.BaseTestCase): array = array) self.assertEqual(returnValue.getvalue(), 17.5) - def testBindInOutDateArrayByVar(self): - "test binding in/out a date array (with arrayvar)" + def test_1408_BindInOutDateArrayByVar(self): + "1408 - test binding in/out a date array (with arrayvar)" array = self.cursor.arrayvar(cx_Oracle.DATETIME, 10, 100) originalData = [r[1] for r in self.rawData] array.setvalue(0, originalData) @@ -149,8 +151,8 @@ class TestCase(TestEnv.BaseTestCase): cx_Oracle.Timestamp(2002, 12, 21, 12, 0, 0) ] + \ originalData[5:]) - def testBindOutDateArrayByVar(self): - "test binding out a date array (with arrayvar)" + def test_1409_BindOutDateArrayByVar(self): + "1409 - test binding out a date array (with arrayvar)" array = self.cursor.arrayvar(cx_Oracle.DATETIME, 6, 100) self.cursor.execute(""" begin @@ -166,8 +168,8 @@ class TestCase(TestEnv.BaseTestCase): cx_Oracle.Timestamp(2002, 12, 18, 0, 0, 0), cx_Oracle.Timestamp(2002, 12, 19, 4, 48, 0) ]) - def testBindOutSetInputSizes(self): - "test binding out with set input sizes defined" + def test_1410_BindOutSetInputSizes(self): + "1410 - test binding out with set input sizes defined" vars = self.cursor.setinputsizes(value = cx_Oracle.DATETIME) self.cursor.execute(""" begin @@ -176,8 +178,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(vars["value"].getvalue(), cx_Oracle.Timestamp(2002, 12, 9)) - def testBindInOutSetInputSizes(self): - "test binding in/out with set input sizes defined" + def test_1411_BindInOutSetInputSizes(self): + "1411 - test binding in/out with set input sizes defined" vars = self.cursor.setinputsizes(value = cx_Oracle.DATETIME) self.cursor.execute(""" begin @@ -187,8 +189,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(vars["value"].getvalue(), cx_Oracle.Timestamp(2002, 12, 17, 16, 0, 0)) - def testBindOutVar(self): - "test binding out with cursor.var() method" + def test_1412_BindOutVar(self): + "1412 - test binding out with cursor.var() method" var = self.cursor.var(cx_Oracle.DATETIME) self.cursor.execute(""" begin @@ -199,8 +201,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(var.getvalue(), cx_Oracle.Timestamp(2002, 12, 31, 12, 31, 0)) - def testBindInOutVarDirectSet(self): - "test binding in/out with cursor.var() method" + def test_1413_BindInOutVarDirectSet(self): + "1413 - test binding in/out with cursor.var() method" var = self.cursor.var(cx_Oracle.DATETIME) var.setvalue(0, cx_Oracle.Timestamp(2002, 12, 9, 6, 0, 0)) self.cursor.execute(""" @@ -211,8 +213,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(var.getvalue(), cx_Oracle.Timestamp(2002, 12, 14, 12, 0, 0)) - def testCursorDescription(self): - "test cursor description is accurate" + def test_1414_CursorDescription(self): + "1414 - test cursor description is accurate" self.cursor.execute("select * from TestDates") self.assertEqual(self.cursor.description, [ ('INTCOL', cx_Oracle.DB_TYPE_NUMBER, 10, None, 9, 0, 0), @@ -220,14 +222,14 @@ class TestCase(TestEnv.BaseTestCase): ('NULLABLECOL', cx_Oracle.DB_TYPE_DATE, 23, None, None, None, 1) ]) - def testFetchAll(self): - "test that fetching all of the data returns the correct results" + def test_1415_FetchAll(self): + "1415 - test that fetching all of the data returns the correct results" self.cursor.execute("select * From TestDates order by IntCol") self.assertEqual(self.cursor.fetchall(), self.rawData) self.assertEqual(self.cursor.fetchall(), []) - def testFetchMany(self): - "test that fetching data in chunks returns the correct results" + def test_1416_FetchMany(self): + "1416 - test that fetching data in chunks returns the correct results" self.cursor.execute("select * From TestDates order by IntCol") self.assertEqual(self.cursor.fetchmany(3), self.rawData[0:3]) self.assertEqual(self.cursor.fetchmany(2), self.rawData[3:5]) @@ -235,8 +237,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(self.cursor.fetchmany(3), self.rawData[9:]) self.assertEqual(self.cursor.fetchmany(3), []) - def testFetchOne(self): - "test that fetching a single row returns the correct results" + def test_1417_FetchOne(self): + "1417 - test that fetching a single row returns the correct results" self.cursor.execute(""" select * from TestDates @@ -248,4 +250,3 @@ class TestCase(TestEnv.BaseTestCase): if __name__ == "__main__": TestEnv.RunTestCases() - diff --git a/test/DbTypes.py b/test/test_1500_dbtypes.py similarity index 55% rename from test/DbTypes.py rename to test/test_1500_dbtypes.py index e4f8c37..790827e 100644 --- a/test/DbTypes.py +++ b/test/test_1500_dbtypes.py @@ -3,8 +3,8 @@ #------------------------------------------------------------------------------ """ -Module for testing comparisons with database types and API types. This also -contains tests for comparisons with database types and variable types, for +1500 - Module for testing comparisons with database types and API types. This +also contains tests for comparisons with database types and variable types, for backwards compatibility. """ @@ -21,110 +21,110 @@ class TestCase(TestEnv.BaseTestCase): self.assertNotEqual(dbType, 5) self.assertNotEqual(dbType, cx_Oracle.DB_TYPE_OBJECT) - def testBfile(self): - "test cx_Oracle.DB_TYPE_BFILE comparisons" + def test_1500_Bfile(self): + "1500 - test cx_Oracle.DB_TYPE_BFILE comparisons" self.assertEqual(cx_Oracle.DB_TYPE_BFILE, cx_Oracle.BFILE) - def testBinaryDouble(self): - "test cx_Oracle.DB_TYPE_BINARY_DOUBLE comparisons" + def test_1501_BinaryDouble(self): + "1501 - test cx_Oracle.DB_TYPE_BINARY_DOUBLE comparisons" self.__testCompare(cx_Oracle.DB_TYPE_BINARY_DOUBLE, cx_Oracle.NUMBER) self.assertEqual(cx_Oracle.DB_TYPE_BINARY_DOUBLE, cx_Oracle.NATIVE_FLOAT) - def testBinaryFloat(self): - "test cx_Oracle.DB_TYPE_BINARY_FLOAT comparisons" + def test_1502_BinaryFloat(self): + "1502 - test cx_Oracle.DB_TYPE_BINARY_FLOAT comparisons" self.__testCompare(cx_Oracle.DB_TYPE_BINARY_FLOAT, cx_Oracle.NUMBER) - def testBinaryInteger(self): - "test cx_Oracle.DB_TYPE_BINARY_INTEGER comparisons" + def test_1503_BinaryInteger(self): + "1503 - test cx_Oracle.DB_TYPE_BINARY_INTEGER comparisons" self.__testCompare(cx_Oracle.DB_TYPE_BINARY_INTEGER, cx_Oracle.NUMBER) self.assertEqual(cx_Oracle.DB_TYPE_BINARY_INTEGER, cx_Oracle.NATIVE_INT) - def testBlob(self): - "test cx_Oracle.DB_TYPE_BLOB comparisons" + def test_1504_Blob(self): + "1504 - test cx_Oracle.DB_TYPE_BLOB comparisons" self.assertEqual(cx_Oracle.DB_TYPE_BLOB, cx_Oracle.BLOB) - def testBoolean(self): - "test cx_Oracle.DB_TYPE_BOOLEAN comparisons" + def test_1505_Boolean(self): + "1505 - test cx_Oracle.DB_TYPE_BOOLEAN comparisons" self.assertEqual(cx_Oracle.DB_TYPE_BOOLEAN, cx_Oracle.BOOLEAN) - def testChar(self): - "test cx_Oracle.DB_TYPE_CHAR comparisons" + def test_1506_Char(self): + "1506 - test cx_Oracle.DB_TYPE_CHAR comparisons" self.__testCompare(cx_Oracle.DB_TYPE_CHAR, cx_Oracle.STRING) self.assertEqual(cx_Oracle.DB_TYPE_CHAR, cx_Oracle.FIXED_CHAR) - def testClob(self): - "test cx_Oracle.DB_TYPE_CLOB comparisons" + def test_1507_Clob(self): + "1507 - test cx_Oracle.DB_TYPE_CLOB comparisons" self.assertEqual(cx_Oracle.DB_TYPE_CLOB, cx_Oracle.CLOB) - def testCursor(self): - "test cx_Oracle.DB_TYPE_CURSOR comparisons" + def test_1508_Cursor(self): + "1508 - test cx_Oracle.DB_TYPE_CURSOR comparisons" self.assertEqual(cx_Oracle.DB_TYPE_CURSOR, cx_Oracle.CURSOR) - def testDate(self): - "test cx_Oracle.DB_TYPE_DATE comparisons" + def test_1509_Date(self): + "1509 - test cx_Oracle.DB_TYPE_DATE comparisons" self.__testCompare(cx_Oracle.DB_TYPE_DATE, cx_Oracle.DATETIME) - def testIntervalDS(self): - "test cx_Oracle.DB_TYPE_INTERVAL_DS comparisons" + def test_1510_IntervalDS(self): + "1510 - test cx_Oracle.DB_TYPE_INTERVAL_DS comparisons" self.assertEqual(cx_Oracle.DB_TYPE_INTERVAL_DS, cx_Oracle.INTERVAL) - def testLong(self): - "test cx_Oracle.DB_TYPE_LONG comparisons" + def test_1511_Long(self): + "1511 - test cx_Oracle.DB_TYPE_LONG comparisons" self.__testCompare(cx_Oracle.DB_TYPE_LONG, cx_Oracle.STRING) self.assertEqual(cx_Oracle.DB_TYPE_LONG, cx_Oracle.LONG_STRING) - def testLongRaw(self): - "test cx_Oracle.DB_TYPE_LONG_RAW comparisons" + def test_1512_LongRaw(self): + "1512 - test cx_Oracle.DB_TYPE_LONG_RAW comparisons" self.__testCompare(cx_Oracle.DB_TYPE_LONG_RAW, cx_Oracle.BINARY) self.assertEqual(cx_Oracle.DB_TYPE_LONG_RAW, cx_Oracle.LONG_BINARY) - def testNchar(self): - "test cx_Oracle.DB_TYPE_NCHAR comparisons" + def test_1513_Nchar(self): + "1513 - test cx_Oracle.DB_TYPE_NCHAR comparisons" self.__testCompare(cx_Oracle.DB_TYPE_NCHAR, cx_Oracle.STRING) self.assertEqual(cx_Oracle.DB_TYPE_NCHAR, cx_Oracle.FIXED_NCHAR) - def testNclob(self): - "test cx_Oracle.DB_TYPE_NCLOB comparisons" + def test_1514_Nclob(self): + "1514 - test cx_Oracle.DB_TYPE_NCLOB comparisons" self.assertEqual(cx_Oracle.DB_TYPE_NCLOB, cx_Oracle.NCLOB) - def testNumber(self): - "test cx_Oracle.DB_TYPE_NUMBER comparisons" + def test_1515_Number(self): + "1515 - test cx_Oracle.DB_TYPE_NUMBER comparisons" self.__testCompare(cx_Oracle.DB_TYPE_NUMBER, cx_Oracle.NUMBER) - def testNvarchar(self): - "test cx_Oracle.DB_TYPE_NVARCHAR comparisons" + def test_1516_Nvarchar(self): + "1516 - test cx_Oracle.DB_TYPE_NVARCHAR comparisons" self.__testCompare(cx_Oracle.DB_TYPE_NVARCHAR, cx_Oracle.STRING) self.assertEqual(cx_Oracle.DB_TYPE_NVARCHAR, cx_Oracle.NCHAR) - def testObject(self): - "test cx_Oracle.DB_TYPE_OBJECT comparisons" + def test_1517_Object(self): + "1517 - test cx_Oracle.DB_TYPE_OBJECT comparisons" self.assertEqual(cx_Oracle.DB_TYPE_OBJECT, cx_Oracle.OBJECT) - def testRaw(self): - "test cx_Oracle.DB_TYPE_RAW comparisons" + def test_1518_Raw(self): + "1518 - test cx_Oracle.DB_TYPE_RAW comparisons" self.__testCompare(cx_Oracle.DB_TYPE_RAW, cx_Oracle.BINARY) - def testRowid(self): - "test cx_Oracle.DB_TYPE_ROWID comparisons" + def test_1519_Rowid(self): + "1519 - test cx_Oracle.DB_TYPE_ROWID comparisons" self.__testCompare(cx_Oracle.DB_TYPE_ROWID, cx_Oracle.ROWID) - def testTimestamp(self): - "test cx_Oracle.DB_TYPE_TIMESTAMP comparisons" + def test_1520_Timestamp(self): + "1520 - test cx_Oracle.DB_TYPE_TIMESTAMP comparisons" self.__testCompare(cx_Oracle.DB_TYPE_TIMESTAMP, cx_Oracle.DATETIME) self.assertEqual(cx_Oracle.DB_TYPE_TIMESTAMP, cx_Oracle.TIMESTAMP) - def testTimestampLTZ(self): - "test cx_Oracle.DB_TYPE_TIMESTAMP_LTZ comparisons" + def test_1521_TimestampLTZ(self): + "1521 - test cx_Oracle.DB_TYPE_TIMESTAMP_LTZ comparisons" self.__testCompare(cx_Oracle.DB_TYPE_TIMESTAMP_LTZ, cx_Oracle.DATETIME) - def testTimestampTZ(self): - "test cx_Oracle.DB_TYPE_TIMESTAMP_TZ comparisons" + def test_1522_TimestampTZ(self): + "1522 - test cx_Oracle.DB_TYPE_TIMESTAMP_TZ comparisons" self.__testCompare(cx_Oracle.DB_TYPE_TIMESTAMP_TZ, cx_Oracle.DATETIME) - def testVarchar(self): - "test cx_Oracle.DB_TYPE_VARCHAR comparisons" + def test_1523_Varchar(self): + "1523 - test cx_Oracle.DB_TYPE_VARCHAR comparisons" self.__testCompare(cx_Oracle.DB_TYPE_VARCHAR, cx_Oracle.STRING) diff --git a/test/DMLReturning.py b/test/test_1600_dml_returning.py similarity index 87% rename from test/DMLReturning.py rename to test/test_1600_dml_returning.py index 418aa14..817565e 100644 --- a/test/DMLReturning.py +++ b/test/test_1600_dml_returning.py @@ -1,8 +1,10 @@ #------------------------------------------------------------------------------ -# Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. #------------------------------------------------------------------------------ -"""Module for testing DML returning clauses.""" +""" +1600 - Module for testing DML returning clauses +""" import TestEnv @@ -10,8 +12,8 @@ import cx_Oracle class TestCase(TestEnv.BaseTestCase): - def testInsert(self): - "test insert statement (single row) with DML returning" + def test_1600_Insert(self): + "1600 - test insert (single row) with DML returning" self.cursor.execute("truncate table TestTempTable") intVal = 5 strVal = "A test string" @@ -28,8 +30,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(intVar.values, [[intVal]]) self.assertEqual(strVar.values, [[strVal]]) - def testInsertMany(self): - "test insert statement (multiple rows) with DML returning" + def test_1601_InsertMany(self): + "1601 - test insert (multiple rows) with DML returning" self.cursor.execute("truncate table TestTempTable") intValues = [5, 8, 17, 24, 6] strValues = ["Test 5", "Test 8", "Test 17", "Test 24", "Test 6"] @@ -44,8 +46,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(intVar.values, [[v] for v in intValues]) self.assertEqual(strVar.values, [[v] for v in strValues]) - def testInsertWithSmallSize(self): - "test insert statement with DML returning into too small a variable" + def test_1602_InsertWithSmallSize(self): + "1602 - test insert with DML returning into too small a variable" self.cursor.execute("truncate table TestTempTable") intVal = 6 strVal = "A different test string" @@ -59,8 +61,8 @@ class TestCase(TestEnv.BaseTestCase): returning IntCol, StringCol into :intVar, :strVar""", parameters) - def testUpdateSingleRow(self): - "test update single row statement with DML returning" + def test_1603_UpdateSingleRow(self): + "1603 - test update single row with DML returning" intVal = 7 strVal = "The updated value of the string" self.cursor.execute("truncate table TestTempTable") @@ -82,8 +84,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(intVar.values, [[intVal]]) self.assertEqual(strVar.values, [[strVal]]) - def testUpdateNoRows(self): - "test update no rows statement with DML returning" + def test_1604_UpdateNoRows(self): + "1604 - test update no rows with DML returning" intVal = 8 strVal = "The updated value of the string" self.cursor.execute("truncate table TestTempTable") @@ -107,8 +109,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(intVar.getvalue(), []) self.assertEqual(strVar.getvalue(), []) - def testUpdateMultipleRows(self): - "test update multiple rows statement with DML returning" + def test_1605_UpdateMultipleRows(self): + "1605 - test update multiple rows with DML returning" self.cursor.execute("truncate table TestTempTable") for i in (8, 9, 10): self.cursor.execute(""" @@ -132,8 +134,8 @@ class TestCase(TestEnv.BaseTestCase): "The final value of string 10" ]]) - def testUpdateMultipleRowsExecuteMany(self): - "test update multiple rows with DML returning (executeMany)" + def test_1606_UpdateMultipleRowsExecuteMany(self): + "1606 - test update multiple rows with DML returning (executeMany)" data = [(i, "The initial value of string %d" % i) \ for i in range(1, 11)] self.cursor.execute("truncate table TestTempTable") @@ -168,8 +170,8 @@ class TestCase(TestEnv.BaseTestCase): "Updated value of string 10" ] ]) - def testInsertAndReturnObject(self): - "test inserting an object with DML returning" + def test_1607_InsertAndReturnObject(self): + "1607 - test inserting an object with DML returning" typeObj = self.connection.gettype("UDT_OBJECT") stringValue = "The string that will be verified" obj = typeObj.newobject() @@ -185,8 +187,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(result.STRINGVALUE, stringValue) self.connection.rollback() - def testInsertAndReturnRowid(self): - "test inserting a row and returning a rowid" + def test_1608_InsertAndReturnRowid(self): + "1608 - test inserting a row and returning a rowid" self.cursor.execute("truncate table TestTempTable") var = self.cursor.var(cx_Oracle.ROWID) self.cursor.execute(""" @@ -201,8 +203,8 @@ class TestCase(TestEnv.BaseTestCase): (rowid,)) self.assertEqual(self.cursor.fetchall(), [(278, 'String 278')]) - def testInsertWithRefCursor(self): - "test inserting with a REF cursor and returning a rowid" + def test_1609_InsertWithRefCursor(self): + "1609 - test inserting with a REF cursor and returning a rowid" self.cursor.execute("truncate table TestTempTable") var = self.cursor.var(cx_Oracle.ROWID) inCursor = self.connection.cursor() @@ -224,8 +226,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(self.cursor.fetchall(), [(187, 'String 7 (Modified)')]) - def testDeleteReturningDecreasingRowsReturned(self): - "test delete returning multiple times with decreasing number of rows" + def test_1610_DeleteReturningDecreasingRowsReturned(self): + "1610 - test delete returning decreasing number of rows" data = [(i, "Test String %d" % i) for i in range(1, 11)] self.cursor.execute("truncate table TestTempTable") self.cursor.executemany(""" @@ -242,8 +244,8 @@ class TestCase(TestEnv.BaseTestCase): results.append(intVar.getvalue()) self.assertEqual(results, [ [1, 2, 3, 4], [5, 6, 7], [8, 9] ]) - def testDeleteReturningNoRowsAfterManyRows(self): - "test delete returning no rows after initially returning many rows" + def test_1611_DeleteReturningNoRowsAfterManyRows(self): + "1611 - test delete returning no rows after returning many rows" data = [(i, "Test String %d" % i) for i in range(1, 11)] self.cursor.execute("truncate table TestTempTable") self.cursor.executemany(""" @@ -260,4 +262,3 @@ class TestCase(TestEnv.BaseTestCase): if __name__ == "__main__": TestEnv.RunTestCases() - diff --git a/test/Error.py b/test/test_1700_error.py similarity index 85% rename from test/Error.py rename to test/test_1700_error.py index 9cf162a..58ae0b7 100644 --- a/test/Error.py +++ b/test/test_1700_error.py @@ -1,5 +1,5 @@ #------------------------------------------------------------------------------ -# Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. # # Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved. # @@ -7,7 +7,9 @@ # Canada. All rights reserved. #------------------------------------------------------------------------------ -"""Module for testing error objects.""" +""" +1700 - Module for testing error objects +""" import TestEnv @@ -16,15 +18,15 @@ import pickle class TestCase(TestEnv.BaseTestCase): - def testParseError(self): - "test parse error returns offset correctly" + def test_1700_ParseError(self): + "1700 - test parse error returns offset correctly" with self.assertRaises(cx_Oracle.Error) as cm: self.cursor.execute("begin t_Missing := 5; end;") errorObj, = cm.exception.args self.assertEqual(errorObj.offset, 6) - def testPickleError(self): - "test picking/unpickling an error object" + def test_1701_PickleError(self): + "1701 - test picking/unpickling an error object" with self.assertRaises(cx_Oracle.Error) as cm: self.cursor.execute(""" begin diff --git a/test/IntervalVar.py b/test/test_1800_interval_var.py similarity index 81% rename from test/IntervalVar.py rename to test/test_1800_interval_var.py index 796ebb1..f8bb626 100644 --- a/test/IntervalVar.py +++ b/test/test_1800_interval_var.py @@ -7,7 +7,9 @@ # Canada. All rights reserved. #------------------------------------------------------------------------------ -"""Module for testing interval variables.""" +""" +1800 - Module for testing interval variables +""" import TestEnv @@ -32,8 +34,8 @@ class TestCase(TestEnv.BaseTestCase): self.rawData.append(tuple) self.dataByKey[i] = tuple - def testBindInterval(self): - "test binding in an interval" + def test_1800_BindInterval(self): + "1800 - test binding in an interval" self.cursor.setinputsizes(value = cx_Oracle.DB_TYPE_INTERVAL_DS) self.cursor.execute(""" select * from TestIntervals @@ -42,8 +44,8 @@ class TestCase(TestEnv.BaseTestCase): seconds = 15)) self.assertEqual(self.cursor.fetchall(), [self.dataByKey[5]]) - def testBindNull(self): - "test binding in a null" + def test_1801_BindNull(self): + "1801 - test binding in a null" self.cursor.setinputsizes(value = cx_Oracle.DB_TYPE_INTERVAL_DS) self.cursor.execute(""" select * from TestIntervals @@ -51,8 +53,8 @@ class TestCase(TestEnv.BaseTestCase): value = None) self.assertEqual(self.cursor.fetchall(), []) - def testBindOutSetInputSizes(self): - "test binding out with set input sizes defined" + def test_1802_BindOutSetInputSizes(self): + "1802 - test binding out with set input sizes defined" vars = self.cursor.setinputsizes(value = cx_Oracle.DB_TYPE_INTERVAL_DS) self.cursor.execute(""" begin @@ -62,8 +64,8 @@ class TestCase(TestEnv.BaseTestCase): datetime.timedelta(days = 8, hours = 9, minutes = 24, seconds = 18, microseconds = 123789)) - def testBindInOutSetInputSizes(self): - "test binding in/out with set input sizes defined" + def test_1803_BindInOutSetInputSizes(self): + "1803 - test binding in/out with set input sizes defined" vars = self.cursor.setinputsizes(value = cx_Oracle.DB_TYPE_INTERVAL_DS) self.cursor.execute(""" begin @@ -73,8 +75,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(vars["value"].getvalue(), datetime.timedelta(days = 10, hours = 10, minutes = 45)) - def testBindInOutFractionalSecond(self): - "test binding in/out with set input sizes defined" + def test_1804_BindInOutFractionalSecond(self): + "1804 - test binding in/out with set input sizes defined" vars = self.cursor.setinputsizes(value = cx_Oracle.DB_TYPE_INTERVAL_DS) self.cursor.execute(""" begin @@ -85,8 +87,8 @@ class TestCase(TestEnv.BaseTestCase): datetime.timedelta(days = 10, hours = 8, minutes = 30, seconds=12, microseconds=123789)) - def testBindOutVar(self): - "test binding out with cursor.var() method" + def test_1805_BindOutVar(self): + "1805 - test binding out with cursor.var() method" var = self.cursor.var(cx_Oracle.DB_TYPE_INTERVAL_DS) self.cursor.execute(""" begin @@ -97,8 +99,8 @@ class TestCase(TestEnv.BaseTestCase): datetime.timedelta(days = 15, hours = 18, minutes = 35, seconds = 45, milliseconds = 586)) - def testBindInOutVarDirectSet(self): - "test binding in/out with cursor.var() method" + def test_1806_BindInOutVarDirectSet(self): + "1806 - test binding in/out with cursor.var() method" var = self.cursor.var(cx_Oracle.DB_TYPE_INTERVAL_DS) var.setvalue(0, datetime.timedelta(days = 1, minutes = 50)) self.cursor.execute(""" @@ -109,8 +111,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(var.getvalue(), datetime.timedelta(days = 9, hours = 6, minutes = 5)) - def testCursorDescription(self): - "test cursor description is accurate" + def test_1807_CursorDescription(self): + "1807 - test cursor description is accurate" self.cursor.execute("select * from TestIntervals") self.assertEqual(self.cursor.description, [ ('INTCOL', cx_Oracle.DB_TYPE_NUMBER, 10, None, 9, 0, 0), @@ -119,14 +121,14 @@ class TestCase(TestEnv.BaseTestCase): ('NULLABLECOL', cx_Oracle.DB_TYPE_INTERVAL_DS, None, None, 2, 6, 1) ]) - def testFetchAll(self): - "test that fetching all of the data returns the correct results" + def test_1808_FetchAll(self): + "1808 - test that fetching all of the data returns the correct results" self.cursor.execute("select * From TestIntervals order by IntCol") self.assertEqual(self.cursor.fetchall(), self.rawData) self.assertEqual(self.cursor.fetchall(), []) - def testFetchMany(self): - "test that fetching data in chunks returns the correct results" + def test_1809_FetchMany(self): + "1809 - test that fetching data in chunks returns the correct results" self.cursor.execute("select * From TestIntervals order by IntCol") self.assertEqual(self.cursor.fetchmany(3), self.rawData[0:3]) self.assertEqual(self.cursor.fetchmany(2), self.rawData[3:5]) @@ -134,8 +136,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(self.cursor.fetchmany(3), self.rawData[9:]) self.assertEqual(self.cursor.fetchmany(3), []) - def testFetchOne(self): - "test that fetching a single row returns the correct results" + def test_1810_FetchOne(self): + "1810 - test that fetching a single row returns the correct results" self.cursor.execute(""" select * from TestIntervals @@ -147,4 +149,3 @@ class TestCase(TestEnv.BaseTestCase): if __name__ == "__main__": TestEnv.RunTestCases() - diff --git a/test/LobVar.py b/test/test_1900_lob_var.py similarity index 82% rename from test/LobVar.py rename to test/test_1900_lob_var.py index 0dcff1a..843f1ab 100644 --- a/test/LobVar.py +++ b/test/test_1900_lob_var.py @@ -7,7 +7,9 @@ # Canada. All rights reserved. #------------------------------------------------------------------------------ -"""Module for testing LOB (CLOB and BLOB) variables.""" +""" +1900 - Module for testing LOB (CLOB and BLOB) variables +""" import TestEnv @@ -147,8 +149,8 @@ class TestCase(TestEnv.BaseTestCase): string = prevChar * 5 + char * 5 self.assertEqual(lob.read(offset, 10), string) - def testBindLobValue(self): - "test binding a LOB value directly" + def test_1900_BindLobValue(self): + "1900 - test binding a LOB value directly" self.cursor.execute("truncate table TestCLOBs") self.cursor.execute("insert into TestCLOBs values (1, 'Short value')") self.cursor.execute("select ClobCol from TestCLOBs") @@ -156,83 +158,83 @@ class TestCase(TestEnv.BaseTestCase): self.cursor.execute("insert into TestCLOBs values (2, :value)", value = lob) - def testBLOBCursorDescription(self): - "test cursor description is accurate for BLOBs" + def test_1901_BLOBCursorDescription(self): + "1901 - test cursor description is accurate for BLOBs" self.cursor.execute("select * from TestBLOBs") self.assertEqual(self.cursor.description, [ ('INTCOL', cx_Oracle.DB_TYPE_NUMBER, 10, None, 9, 0, 0), ('BLOBCOL', cx_Oracle.DB_TYPE_BLOB, None, None, None, None, 0) ]) - def testBLOBsDirect(self): - "test binding and fetching BLOB data (directly)" + def test_1902_BLOBsDirect(self): + "1902 - test binding and fetching BLOB data (directly)" self.__PerformTest("BLOB", cx_Oracle.DB_TYPE_BLOB) - def testBLOBsIndirect(self): - "test binding and fetching BLOB data (indirectly)" + def test_1903_BLOBsIndirect(self): + "1903 - test binding and fetching BLOB data (indirectly)" self.__PerformTest("BLOB", cx_Oracle.DB_TYPE_LONG_RAW) - def testBLOBOperations(self): - "test operations on BLOBs" + def test_1904_BLOBOperations(self): + "1904 - test operations on BLOBs" self.__TestLobOperations("BLOB") - def testCLOBCursorDescription(self): - "test cursor description is accurate for CLOBs" + def test_1905_CLOBCursorDescription(self): + "1905 - test cursor description is accurate for CLOBs" self.cursor.execute("select * from TestCLOBs") self.assertEqual(self.cursor.description, [ ('INTCOL', cx_Oracle.DB_TYPE_NUMBER, 10, None, 9, 0, 0), ('CLOBCOL', cx_Oracle.DB_TYPE_CLOB, None, None, None, None, 0) ]) - def testCLOBsDirect(self): - "test binding and fetching CLOB data (directly)" + def test_1906_CLOBsDirect(self): + "1906 - test binding and fetching CLOB data (directly)" self.__PerformTest("CLOB", cx_Oracle.DB_TYPE_CLOB) - def testCLOBsIndirect(self): - "test binding and fetching CLOB data (indirectly)" + def test_1907_CLOBsIndirect(self): + "1907 - test binding and fetching CLOB data (indirectly)" self.__PerformTest("CLOB", cx_Oracle.DB_TYPE_LONG) - def testCLOBOperations(self): - "test operations on CLOBs" + def test_1908_CLOBOperations(self): + "1908 - test operations on CLOBs" self.__TestLobOperations("CLOB") - def testCreateBlob(self): - "test creating a temporary BLOB" + def test_1909_CreateBlob(self): + "1909 - test creating a temporary BLOB" self.__TestTemporaryLOB("BLOB") - def testCreateClob(self): - "test creating a temporary CLOB" + def test_1910_CreateClob(self): + "1910 - test creating a temporary CLOB" self.__TestTemporaryLOB("CLOB") - def testCreateNclob(self): - "test creating a temporary NCLOB" + def test_1911_CreateNclob(self): + "1911 - test creating a temporary NCLOB" self.__TestTemporaryLOB("NCLOB") - def testMultipleFetch(self): - "test retrieving data from a CLOB after multiple fetches" + def test_1912_MultipleFetch(self): + "1912 - test retrieving data from a CLOB after multiple fetches" self.cursor.arraysize = 1 self.cursor.execute("select * from TestCLOBS") rows = self.cursor.fetchall() self.__ValidateQuery(rows, "CLOB") - def testNCLOBCursorDescription(self): - "test cursor description is accurate for NCLOBs" + def test_1913_NCLOBCursorDescription(self): + "1913 - test cursor description is accurate for NCLOBs" self.cursor.execute("select * from TestNCLOBs") self.assertEqual(self.cursor.description, [ ('INTCOL', cx_Oracle.DB_TYPE_NUMBER, 10, None, 9, 0, 0), ('NCLOBCOL', cx_Oracle.DB_TYPE_NCLOB, None, None, None, None, 0) ]) - def testNCLOBsDirect(self): - "test binding and fetching NCLOB data (directly)" + def test_1914_NCLOBsDirect(self): + "1914 - test binding and fetching NCLOB data (directly)" self.__PerformTest("NCLOB", cx_Oracle.DB_TYPE_NCLOB) - def testNCLOBDifferentEncodings(self): - "test binding and fetching NCLOB data (different encodings)" + def test_1915_NCLOBDifferentEncodings(self): + "1915 - test binding and fetching NCLOB data (different encodings)" connection = cx_Oracle.connect(TestEnv.GetMainUser(), TestEnv.GetMainPassword(), TestEnv.GetConnectString(), encoding = "UTF-8", nencoding = "UTF-16") - value = u"\u03b4\u4e2a" + value = "\u03b4\u4e2a" cursor = connection.cursor() cursor.execute("truncate table TestNCLOBs") cursor.setinputsizes(val = cx_Oracle.DB_TYPE_NVARCHAR) @@ -246,16 +248,16 @@ class TestCase(TestEnv.BaseTestCase): nclob, = cursor.fetchone() self.assertEqual(nclob.read(), value + value) - def testNCLOBsIndirect(self): - "test binding and fetching NCLOB data (indirectly)" + def test_1916_NCLOBsIndirect(self): + "1916 - test binding and fetching NCLOB data (indirectly)" self.__PerformTest("NCLOB", cx_Oracle.DB_TYPE_LONG) - def testNCLOBOperations(self): - "test operations on NCLOBs" + def test_1917_NCLOBOperations(self): + "1917 - test operations on NCLOBs" self.__TestLobOperations("NCLOB") - def testTemporaryLobs(self): - "test temporary LOBs" + def test_1918_TemporaryLobs(self): + "1918 - test temporary LOBs" cursor = self.connection.cursor() cursor.arraysize = self.cursor.arraysize cursor.execute(""" @@ -274,11 +276,10 @@ class TestCase(TestEnv.BaseTestCase): tempLobs = self.__GetTempLobs(sid) self.assertEqual(tempLobs, 0) - def testAssignStringBeyondArraySize(self): - "test assign string to NCLOB beyond array size" + def test_1919_AssignStringBeyondArraySize(self): + "1919 - test assign string to NCLOB beyond array size" nclobVar = self.cursor.var(cx_Oracle.DB_TYPE_NCLOB) self.assertRaises(IndexError, nclobVar.setvalue, 1, "test char") if __name__ == "__main__": TestEnv.RunTestCases() - diff --git a/test/LongVar.py b/test/test_2000_long_var.py similarity index 82% rename from test/LongVar.py rename to test/test_2000_long_var.py index 47299c9..c9aa119 100644 --- a/test/LongVar.py +++ b/test/test_2000_long_var.py @@ -1,5 +1,5 @@ #------------------------------------------------------------------------------ -# Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. # # Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved. # @@ -7,7 +7,9 @@ # Canada. All rights reserved. #------------------------------------------------------------------------------ -"""Module for testing long and long raw variables.""" +""" +2000 - Module for testing long and long raw variables +""" import TestEnv @@ -57,12 +59,12 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(len(fetchedValue), integerValue * 25000) self.assertEqual(fetchedValue, actualValue) - def testLongs(self): - "test binding and fetching long data" + def test_2000_Longs(self): + "2000 - test binding and fetching long data" self.__PerformTest("Long", cx_Oracle.DB_TYPE_LONG) - def testLongWithExecuteMany(self): - "test binding long data with executemany()" + def test_2001_LongWithExecuteMany(self): + "2001 - test binding long data with executemany()" data = [] self.cursor.execute("truncate table TestLongs") for i in range(5): @@ -75,32 +77,31 @@ class TestCase(TestEnv.BaseTestCase): fetchedData = self.cursor.fetchall() self.assertEqual(fetchedData, data) - def testLongRaws(self): - "test binding and fetching long raw data" + def test_2002_LongRaws(self): + "2002 - test binding and fetching long raw data" self.__PerformTest("LongRaw", cx_Oracle.DB_TYPE_LONG_RAW) - def testLongCursorDescription(self): - "test cursor description is accurate for longs" + def test_2003_LongCursorDescription(self): + "2003 - test cursor description is accurate for longs" self.cursor.execute("select * from TestLongs") self.assertEqual(self.cursor.description, [ ('INTCOL', cx_Oracle.DB_TYPE_NUMBER, 10, None, 9, 0, 0), ('LONGCOL', cx_Oracle.DB_TYPE_LONG, None, None, None, None, 0) ]) - def testLongRawCursorDescription(self): - "test cursor description is accurate for long raws" + def test_2004_LongRawCursorDescription(self): + "2004 - test cursor description is accurate for long raws" self.cursor.execute("select * from TestLongRaws") self.assertEqual(self.cursor.description, [ ('INTCOL', cx_Oracle.DB_TYPE_NUMBER, 10, None, 9, 0, 0), ('LONGRAWCOL', cx_Oracle.DB_TYPE_LONG_RAW, None, None, None, None, 0) ]) - def testArraySizeTooLarge(self): - "test array size too large generates an exception" + def test_2005_ArraySizeTooLarge(self): + "2005 - test array size too large generates an exception" self.cursor.arraysize = 268435456 self.assertRaises(cx_Oracle.DatabaseError, self.cursor.execute, "select * from TestLongRaws") if __name__ == "__main__": TestEnv.RunTestCases() - diff --git a/test/NCharVar.py b/test/test_2100_nchar_var.py similarity index 72% rename from test/NCharVar.py rename to test/test_2100_nchar_var.py index 59e9f12..907b92f 100644 --- a/test/NCharVar.py +++ b/test/test_2100_nchar_var.py @@ -1,5 +1,5 @@ #------------------------------------------------------------------------------ -# Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. # # Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved. # @@ -7,7 +7,9 @@ # Canada. All rights reserved. #------------------------------------------------------------------------------ -"""Module for testing NCHAR variables.""" +""" +2100 - Module for testing NCHAR variables +""" import TestEnv @@ -20,51 +22,51 @@ class TestCase(TestEnv.BaseTestCase): self.rawData = [] self.dataByKey = {} for i in range(1, 11): - unicodeCol = u"Unicode \u3042 %d" % i - fixedCharCol = (u"Fixed Unicode %d" % i).ljust(40) + unicodeCol = "Unicode \u3042 %d" % i + fixedCharCol = ("Fixed Unicode %d" % i).ljust(40) if i % 2: - nullableCol = u"Nullable %d" % i + nullableCol = "Nullable %d" % i else: nullableCol = None dataTuple = (i, unicodeCol, fixedCharCol, nullableCol) self.rawData.append(dataTuple) self.dataByKey[i] = dataTuple - def testUnicodeLength(self): - "test value length" + def test_2100_UnicodeLength(self): + "2100 - test value length" returnValue = self.cursor.var(int) self.cursor.execute(""" begin :retval := LENGTH(:value); end;""", - value = u"InVal \u3042", + value = "InVal \u3042", retval = returnValue) self.assertEqual(returnValue.getvalue(), 7) - def testBindUnicode(self): - "test binding in a unicode" + def test_2101_BindUnicode(self): + "2101 - test binding in a unicode" self.cursor.setinputsizes(value = cx_Oracle.DB_TYPE_NVARCHAR) self.cursor.execute(""" select * from TestUnicodes where UnicodeCol = :value""", - value = u"Unicode \u3042 5") + value = "Unicode \u3042 5") self.assertEqual(self.cursor.fetchall(), [self.dataByKey[5]]) - def testBindDifferentVar(self): - "test binding a different variable on second execution" + def test_2102_BindDifferentVar(self): + "2102 - test binding a different variable on second execution" retval_1 = self.cursor.var(cx_Oracle.DB_TYPE_NVARCHAR, 30) retval_2 = self.cursor.var(cx_Oracle.DB_TYPE_NVARCHAR, 30) self.cursor.execute(r"begin :retval := unistr('Called \3042'); end;", retval = retval_1) - self.assertEqual(retval_1.getvalue(), u"Called \u3042") + self.assertEqual(retval_1.getvalue(), "Called \u3042") self.cursor.execute("begin :retval := 'Called'; end;", retval = retval_2) self.assertEqual(retval_2.getvalue(), "Called") - def testBindUnicodeAfterNumber(self): - "test binding in a unicode after setting input sizes to a number" + def test_2103_BindUnicodeAfterNumber(self): + "2103 - test binding in a string after setting input sizes to a number" unicodeVal = self.cursor.var(cx_Oracle.DB_TYPE_NVARCHAR) - unicodeVal.setvalue(0, u"Unicode \u3042 6") + unicodeVal.setvalue(0, "Unicode \u3042 6") self.cursor.setinputsizes(value = cx_Oracle.NUMBER) self.cursor.execute(""" select * from TestUnicodes @@ -72,8 +74,8 @@ class TestCase(TestEnv.BaseTestCase): value = unicodeVal) self.assertEqual(self.cursor.fetchall(), [self.dataByKey[6]]) - def testBindUnicodeArrayDirect(self): - "test binding in a unicode array" + def test_2104_BindUnicodeArrayDirect(self): + "2104 - test binding in a unicode array" returnValue = self.cursor.var(cx_Oracle.NUMBER) array = [r[1] for r in self.rawData] arrayVar = self.cursor.arrayvar(cx_Oracle.DB_TYPE_NVARCHAR, array) @@ -87,15 +89,15 @@ class TestCase(TestEnv.BaseTestCase): integerValue = 5, array = arrayVar) self.assertEqual(returnValue.getvalue(), 116) - array = [ u"Unicode - \u3042 %d" % i for i in range(15) ] + array = [ "Unicode - \u3042 %d" % i for i in range(15) ] arrayVar = self.cursor.arrayvar(cx_Oracle.DB_TYPE_NVARCHAR, array) self.cursor.execute(statement, integerValue = 8, array = arrayVar) self.assertEqual(returnValue.getvalue(), 208) - def testBindUnicodeArrayBySizes(self): - "test binding in a unicode array (with setinputsizes)" + def test_2105_BindUnicodeArrayBySizes(self): + "2105 - test binding in a unicode array (with setinputsizes)" returnValue = self.cursor.var(cx_Oracle.NUMBER) self.cursor.setinputsizes(array = [cx_Oracle.DB_TYPE_NVARCHAR, 10]) array = [r[1] for r in self.rawData] @@ -109,8 +111,8 @@ class TestCase(TestEnv.BaseTestCase): array = array) self.assertEqual(returnValue.getvalue(), 117) - def testBindUnicodeArrayByVar(self): - "test binding in a unicode array (with arrayvar)" + def test_2106_BindUnicodeArrayByVar(self): + "2106 - test binding in a unicode array (with arrayvar)" returnValue = self.cursor.var(cx_Oracle.NUMBER) array = self.cursor.arrayvar(cx_Oracle.DB_TYPE_NVARCHAR, 10, 20) array.setvalue(0, [r[1] for r in self.rawData]) @@ -124,11 +126,11 @@ class TestCase(TestEnv.BaseTestCase): array = array) self.assertEqual(returnValue.getvalue(), 118) - def testBindInOutUnicodeArrayByVar(self): - "test binding in/out a unicode array (with arrayvar)" + def test_2107_BindInOutUnicodeArrayByVar(self): + "2107 - test binding in/out a unicode array (with arrayvar)" array = self.cursor.arrayvar(cx_Oracle.DB_TYPE_NVARCHAR, 10, 100) originalData = [r[1] for r in self.rawData] - format = u"Converted element \u3042 # %d originally had length %d" + format = "Converted element \u3042 # %d originally had length %d" expectedData = [format % (i, len(originalData[i - 1])) \ for i in range(1, 6)] + originalData[5:] array.setvalue(0, originalData) @@ -140,10 +142,10 @@ class TestCase(TestEnv.BaseTestCase): array = array) self.assertEqual(array.getvalue(), expectedData) - def testBindOutUnicodeArrayByVar(self): - "test binding out a unicode array (with arrayvar)" + def test_2108_BindOutUnicodeArrayByVar(self): + "2108 - test binding out a unicode array (with arrayvar)" array = self.cursor.arrayvar(cx_Oracle.DB_TYPE_NVARCHAR, 6, 100) - format = u"Test out element \u3042 # %d" + format = "Test out element \u3042 # %d" expectedData = [format % i for i in range(1, 7)] self.cursor.execute(""" begin @@ -153,57 +155,57 @@ class TestCase(TestEnv.BaseTestCase): array = array) self.assertEqual(array.getvalue(), expectedData) - def testBindNull(self): - "test binding in a null" + def test_2109_BindNull(self): + "2109 - test binding in a null" self.cursor.execute(""" select * from TestUnicodes where UnicodeCol = :value""", value = None) self.assertEqual(self.cursor.fetchall(), []) - def testBindOutSetInputSizesByType(self): - "test binding out with set input sizes defined (by type)" + def test_2110_BindOutSetInputSizesByType(self): + "2110 - test binding out with set input sizes defined (by type)" vars = self.cursor.setinputsizes(value = cx_Oracle.DB_TYPE_NVARCHAR) self.cursor.execute(r""" begin :value := unistr('TSI \3042'); end;""") - self.assertEqual(vars["value"].getvalue(), u"TSI \u3042") + self.assertEqual(vars["value"].getvalue(), "TSI \u3042") - def testBindInOutSetInputSizesByType(self): - "test binding in/out with set input sizes defined (by type)" + def test_2111_BindInOutSetInputSizesByType(self): + "2111 - test binding in/out with set input sizes defined (by type)" vars = self.cursor.setinputsizes(value = cx_Oracle.DB_TYPE_NVARCHAR) self.cursor.execute(r""" begin :value := :value || unistr(' TSI \3042'); end;""", - value = u"InVal \u3041") + value = "InVal \u3041") self.assertEqual(vars["value"].getvalue(), - u"InVal \u3041 TSI \u3042") + "InVal \u3041 TSI \u3042") - def testBindOutVar(self): - "test binding out with cursor.var() method" + def test_2112_BindOutVar(self): + "2112 - test binding out with cursor.var() method" var = self.cursor.var(cx_Oracle.DB_TYPE_NVARCHAR) self.cursor.execute(r""" begin :value := unistr('TSI (VAR) \3042'); end;""", value = var) - self.assertEqual(var.getvalue(), u"TSI (VAR) \u3042") + self.assertEqual(var.getvalue(), "TSI (VAR) \u3042") - def testBindInOutVarDirectSet(self): - "test binding in/out with cursor.var() method" + def test_2113_BindInOutVarDirectSet(self): + "2113 - test binding in/out with cursor.var() method" var = self.cursor.var(cx_Oracle.DB_TYPE_NVARCHAR) - var.setvalue(0, u"InVal \u3041") + var.setvalue(0, "InVal \u3041") self.cursor.execute(r""" begin :value := :value || unistr(' TSI (VAR) \3042'); end;""", value = var) - self.assertEqual(var.getvalue(), u"InVal \u3041 TSI (VAR) \u3042") + self.assertEqual(var.getvalue(), "InVal \u3041 TSI (VAR) \u3042") - def testCursorDescription(self): - "test cursor description is accurate" + def test_2114_CursorDescription(self): + "2114 - test cursor description is accurate" self.cursor.execute("select * from TestUnicodes") self.assertEqual(self.cursor.description, [ ('INTCOL', cx_Oracle.DB_TYPE_NUMBER, 10, None, 9, 0, 0), @@ -214,14 +216,14 @@ class TestCase(TestEnv.BaseTestCase): ('NULLABLECOL', cx_Oracle.DB_TYPE_NVARCHAR, 50, 200, None, None, 1) ]) - def testFetchAll(self): - "test that fetching all of the data returns the correct results" + def test_2115_FetchAll(self): + "2115 - test that fetching all of the data returns the correct results" self.cursor.execute("select * From TestUnicodes order by IntCol") self.assertEqual(self.cursor.fetchall(), self.rawData) self.assertEqual(self.cursor.fetchall(), []) - def testFetchMany(self): - "test that fetching data in chunks returns the correct results" + def test_2116_FetchMany(self): + "2116 - test that fetching data in chunks returns the correct results" self.cursor.execute("select * From TestUnicodes order by IntCol") self.assertEqual(self.cursor.fetchmany(3), self.rawData[0:3]) self.assertEqual(self.cursor.fetchmany(2), self.rawData[3:5]) @@ -229,8 +231,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(self.cursor.fetchmany(3), self.rawData[9:]) self.assertEqual(self.cursor.fetchmany(3), []) - def testFetchOne(self): - "test that fetching a single row returns the correct results" + def test_2117_FetchOne(self): + "2117 - test that fetching a single row returns the correct results" self.cursor.execute(""" select * from TestUnicodes @@ -242,4 +244,3 @@ class TestCase(TestEnv.BaseTestCase): if __name__ == "__main__": TestEnv.RunTestCases() - diff --git a/test/NumberVar.py b/test/test_2200_number_var.py similarity index 79% rename from test/NumberVar.py rename to test/test_2200_number_var.py index b1bcc67..56786f1 100644 --- a/test/NumberVar.py +++ b/test/test_2200_number_var.py @@ -7,7 +7,9 @@ # Canada. All rights reserved. #------------------------------------------------------------------------------ -"""Module for testing number variables.""" +""" +2200 - Module for testing number variables +""" import TestEnv @@ -45,14 +47,14 @@ class TestCase(TestEnv.BaseTestCase): self.rawData.append(dataTuple) self.dataByKey[i] = dataTuple - def testBindBoolean(self): - "test binding in a boolean" + def test_2200_BindBoolean(self): + "2200 - test binding in a boolean" result = self.cursor.callfunc("pkg_TestBooleans.GetStringRep", str, (True,)) self.assertEqual(result, "TRUE") - def testBindBooleanAsNumber(self): - "test binding in a boolean as a number" + def test_2201_BindBooleanAsNumber(self): + "2201 - test binding in a boolean as a number" var = self.cursor.var(cx_Oracle.NUMBER) var.setvalue(0, True) self.cursor.execute("select :1 from dual", [var]) @@ -63,8 +65,8 @@ class TestCase(TestEnv.BaseTestCase): result, = self.cursor.fetchone() self.assertEqual(result, 0) - def testBindDecimal(self): - "test binding in a decimal.Decimal" + def test_2202_BindDecimal(self): + "2202 - test binding in a decimal.Decimal" self.cursor.execute(""" select * from TestNumbers where NumberCol - :value1 - :value2 = trunc(NumberCol)""", @@ -73,8 +75,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(self.cursor.fetchall(), [self.dataByKey[1], self.dataByKey[5], self.dataByKey[9]]) - def testBindFloat(self): - "test binding in a float" + def test_2203_BindFloat(self): + "2203 - test binding in a float" self.cursor.execute(""" select * from TestNumbers where NumberCol - :value = trunc(NumberCol)""", @@ -82,16 +84,16 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(self.cursor.fetchall(), [self.dataByKey[1], self.dataByKey[5], self.dataByKey[9]]) - def testBindInteger(self): - "test binding in an integer" + def test_2204_BindInteger(self): + "2204 - test binding in an integer" self.cursor.execute(""" select * from TestNumbers where IntCol = :value""", value = 2) self.assertEqual(self.cursor.fetchall(), [self.dataByKey[2]]) - def testBindLargeLongAsOracleNumber(self): - "test binding in a large long integer as Oracle number" + def test_2205_BindLargeLongAsOracleNumber(self): + "2205 - test binding in a large long integer as Oracle number" valueVar = self.cursor.var(cx_Oracle.NUMBER) valueVar.setvalue(0, 6088343244) self.cursor.execute(""" @@ -102,15 +104,15 @@ class TestCase(TestEnv.BaseTestCase): value = valueVar.getvalue() self.assertEqual(value, 6088343249) - def testBindLargeLongAsInteger(self): - "test binding in a large long integer as Python integer" + def test_2206_BindLargeLongAsInteger(self): + "2206 - test binding in a large long integer as Python integer" longValue = -9999999999999999999 self.cursor.execute("select :value from dual", value = longValue) result, = self.cursor.fetchone() self.assertEqual(result, longValue) - def testBindIntegerAfterString(self): - "test binding in an number after setting input sizes to a string" + def test_2207_BindIntegerAfterString(self): + "2207 - test binding in an integer after setting input sizes to string" self.cursor.setinputsizes(value = 15) self.cursor.execute(""" select * from TestNumbers @@ -118,8 +120,8 @@ class TestCase(TestEnv.BaseTestCase): value = 3) self.assertEqual(self.cursor.fetchall(), [self.dataByKey[3]]) - def testBindDecimalAfterNumber(self): - "test binding in a decimal value after setting input sizes to a number" + def test_2208_BindDecimalAfterNumber(self): + "2208 - test binding in a decimal after setting input sizes to number" cursor = self.connection.cursor() value = decimal.Decimal("319438950232418390.273596") cursor.setinputsizes(value = cx_Oracle.NUMBER) @@ -129,16 +131,16 @@ class TestCase(TestEnv.BaseTestCase): outValue, = cursor.fetchone() self.assertEqual(outValue, value) - def testBindNull(self): - "test binding in a null" + def test_2209_BindNull(self): + "2209 - test binding in a null" self.cursor.execute(""" select * from TestNumbers where IntCol = :value""", value = None) self.assertEqual(self.cursor.fetchall(), []) - def testBindNumberArrayDirect(self): - "test binding in a number array" + def test_2210_BindNumberArrayDirect(self): + "2210 - test binding in a number array" returnValue = self.cursor.var(cx_Oracle.NUMBER) array = [r[2] for r in self.rawData] statement = """ @@ -157,8 +159,8 @@ class TestCase(TestEnv.BaseTestCase): array = array) self.assertEqual(returnValue.getvalue(), 115.0) - def testBindNumberArrayBySizes(self): - "test binding in a number array (with setinputsizes)" + def test_2211_BindNumberArrayBySizes(self): + "2211 - test binding in a number array (with setinputsizes)" returnValue = self.cursor.var(cx_Oracle.NUMBER) self.cursor.setinputsizes(array = [cx_Oracle.NUMBER, 10]) array = [r[2] for r in self.rawData] @@ -172,8 +174,8 @@ class TestCase(TestEnv.BaseTestCase): array = array) self.assertEqual(returnValue.getvalue(), 74.75) - def testBindNumberArrayByVar(self): - "test binding in a number array (with arrayvar)" + def test_2212_BindNumberArrayByVar(self): + "2212 - test binding in a number array (with arrayvar)" returnValue = self.cursor.var(cx_Oracle.NUMBER) array = self.cursor.arrayvar(cx_Oracle.NUMBER, [r[2] for r in self.rawData]) @@ -187,8 +189,8 @@ class TestCase(TestEnv.BaseTestCase): array = array) self.assertEqual(returnValue.getvalue(), 75.75) - def testBindZeroLengthNumberArrayByVar(self): - "test binding in a zero length number array (with arrayvar)" + def test_2213_BindZeroLengthNumberArrayByVar(self): + "2213 - test binding in a zero length number array (with arrayvar)" returnValue = self.cursor.var(cx_Oracle.NUMBER) array = self.cursor.arrayvar(cx_Oracle.NUMBER, 0) self.cursor.execute(""" @@ -202,8 +204,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(returnValue.getvalue(), 8.0) self.assertEqual(array.getvalue(), []) - def testBindInOutNumberArrayByVar(self): - "test binding in/out a number array (with arrayvar)" + def test_2214_BindInOutNumberArrayByVar(self): + "2214 - test binding in/out a number array (with arrayvar)" array = self.cursor.arrayvar(cx_Oracle.NUMBER, 10) originalData = [r[2] for r in self.rawData] expectedData = [originalData[i - 1] * 10 for i in range(1, 6)] + \ @@ -217,8 +219,8 @@ class TestCase(TestEnv.BaseTestCase): array = array) self.assertEqual(array.getvalue(), expectedData) - def testBindOutNumberArrayByVar(self): - "test binding out a Number array (with arrayvar)" + def test_2215_BindOutNumberArrayByVar(self): + "2215 - test binding out a Number array (with arrayvar)" array = self.cursor.arrayvar(cx_Oracle.NUMBER, 6) expectedData = [i * 100 for i in range(1, 7)] self.cursor.execute(""" @@ -229,8 +231,8 @@ class TestCase(TestEnv.BaseTestCase): array = array) self.assertEqual(array.getvalue(), expectedData) - def testBindOutSetInputSizes(self): - "test binding out with set input sizes defined" + def test_2216_BindOutSetInputSizes(self): + "2216 - test binding out with set input sizes defined" vars = self.cursor.setinputsizes(value = cx_Oracle.NUMBER) self.cursor.execute(""" begin @@ -238,8 +240,8 @@ class TestCase(TestEnv.BaseTestCase): end;""") self.assertEqual(vars["value"].getvalue(), 5) - def testBindInOutSetInputSizes(self): - "test binding in/out with set input sizes defined" + def test_2217_BindInOutSetInputSizes(self): + "2217 - test binding in/out with set input sizes defined" vars = self.cursor.setinputsizes(value = cx_Oracle.NUMBER) self.cursor.execute(""" begin @@ -248,8 +250,8 @@ class TestCase(TestEnv.BaseTestCase): value = 1.25) self.assertEqual(vars["value"].getvalue(), 6.25) - def testBindOutVar(self): - "test binding out with cursor.var() method" + def test_2218_BindOutVar(self): + "2218 - test binding out with cursor.var() method" var = self.cursor.var(cx_Oracle.NUMBER) self.cursor.execute(""" begin @@ -258,8 +260,8 @@ class TestCase(TestEnv.BaseTestCase): value = var) self.assertEqual(var.getvalue(), 5) - def testBindInOutVarDirectSet(self): - "test binding in/out with cursor.var() method" + def test_2219_BindInOutVarDirectSet(self): + "2219 - test binding in/out with cursor.var() method" var = self.cursor.var(cx_Oracle.NUMBER) var.setvalue(0, 2.25) self.cursor.execute(""" @@ -269,8 +271,8 @@ class TestCase(TestEnv.BaseTestCase): value = var) self.assertEqual(var.getvalue(), 7.25) - def testCursorDescription(self): - "test cursor description is accurate" + def test_2220_CursorDescription(self): + "2220 - test cursor description is accurate" self.cursor.execute("select * from TestNumbers") self.assertEqual(self.cursor.description, [ ('INTCOL', cx_Oracle.DB_TYPE_NUMBER, 10, None, 9, 0, 0), @@ -283,14 +285,14 @@ class TestCase(TestEnv.BaseTestCase): ('NULLABLECOL', cx_Oracle.DB_TYPE_NUMBER, 39, None, 38, 0, 1) ]) - def testFetchAll(self): - "test that fetching all of the data returns the correct results" + def test_2221_FetchAll(self): + "2221 - test that fetching all of the data returns the correct results" self.cursor.execute("select * From TestNumbers order by IntCol") self.assertEqual(self.cursor.fetchall(), self.rawData) self.assertEqual(self.cursor.fetchall(), []) - def testFetchMany(self): - "test that fetching data in chunks returns the correct results" + def test_2222_FetchMany(self): + "2222 - test that fetching data in chunks returns the correct results" self.cursor.execute("select * From TestNumbers order by IntCol") self.assertEqual(self.cursor.fetchmany(3), self.rawData[0:3]) self.assertEqual(self.cursor.fetchmany(2), self.rawData[3:5]) @@ -298,8 +300,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(self.cursor.fetchmany(3), self.rawData[9:]) self.assertEqual(self.cursor.fetchmany(3), []) - def testFetchOne(self): - "test that fetching a single row returns the correct results" + def test_2223_FetchOne(self): + "2223 - test that fetching a single row returns the correct results" self.cursor.execute(""" select * from TestNumbers @@ -309,8 +311,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(self.cursor.fetchone(), self.dataByKey[4]) self.assertEqual(self.cursor.fetchone(), None) - def testReturnAsLong(self): - "test that fetching a long integer returns such in Python" + def test_2224_ReturnAsLong(self): + "2224 - test that fetching a long integer returns such in Python" self.cursor.execute(""" select NullableCol from TestNumbers @@ -318,21 +320,21 @@ class TestCase(TestEnv.BaseTestCase): col, = self.cursor.fetchone() self.assertEqual(col, 25004854810776297743) - def testReturnConstantFloat(self): - "test that fetching a floating point number returns such in Python" + def test_2225_ReturnConstantFloat(self): + "2225 - test fetching a floating point number returns such in Python" self.cursor.execute("select 1.25 from dual") result, = self.cursor.fetchone() self.assertEqual(result, 1.25) - def testReturnConstantInteger(self): - "test that fetching an integer returns such in Python" + def test_2226_ReturnConstantInteger(self): + "2226 - test that fetching an integer returns such in Python" self.cursor.execute("select 148 from dual") result, = self.cursor.fetchone() self.assertEqual(result, 148) self.assertTrue(isinstance(result, int), "integer not returned") - def testAcceptableBoundaryNumbers(self): - "test that acceptable boundary numbers are handled properly" + def test_2227_AcceptableBoundaryNumbers(self): + "2227 - test that acceptable boundary numbers are handled properly" inValues = [decimal.Decimal("9.99999999999999e+125"), decimal.Decimal("-9.99999999999999e+125"), 0.0, 1e-130, -1e-130] @@ -343,8 +345,8 @@ class TestCase(TestEnv.BaseTestCase): result, = self.cursor.fetchone() self.assertEqual(result, outValue) - def testUnacceptableBoundaryNumbers(self): - "test that unacceptable boundary numbers are rejected" + def test_2228_UnacceptableBoundaryNumbers(self): + "2228 - test that unacceptable boundary numbers are rejected" inValues = [1e126, -1e126, float("inf"), float("-inf"), float("NaN"), decimal.Decimal("1e126"), decimal.Decimal("-1e126"), decimal.Decimal("inf"), @@ -360,8 +362,8 @@ class TestCase(TestEnv.BaseTestCase): method(cx_Oracle.DatabaseError, error, self.cursor.execute, "select :1 from dual", (inValue,)) - def testReturnFloatFromDivision(self): - "test that fetching the result of division returns a float" + def test_2229_ReturnFloatFromDivision(self): + "2229 - test that fetching the result of division returns a float" self.cursor.execute(""" select IntCol / 7 from TestNumbers @@ -370,8 +372,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(result, 1.0 / 7.0) self.assertTrue(isinstance(result, float), "float not returned") - def testStringFormat(self): - "test that string format is returned properly" + def test_2230_StringFormat(self): + "2230 - test that string format is returned properly" var = self.cursor.var(cx_Oracle.NUMBER) self.assertEqual(str(var), "") @@ -379,8 +381,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(str(var), "") - def testBindNativeFloat(self): - "test that binding native float is possible" + def test_2231_BindNativeFloat(self): + "2231 - test that binding native float is possible" self.cursor.setinputsizes(cx_Oracle.DB_TYPE_BINARY_DOUBLE) self.cursor.execute("select :1 from dual", (5,)) self.assertEqual(self.cursor.bindvars[0].type, @@ -398,8 +400,8 @@ class TestCase(TestEnv.BaseTestCase): value, = self.cursor.fetchone() self.assertEqual(str(value), str(float("NaN"))) - def testFetchNativeInt(self): - "test fetching numbers as native integers" + def test_2232_FetchNativeInt(self): + "2232 - test fetching numbers as native integers" self.cursor.outputtypehandler = self.outputTypeHandlerNativeInt for value in (1, 2 ** 31, 2 ** 63 - 1, -1, -2 ** 31, -2 ** 63 + 1): self.cursor.execute("select :1 from dual", [str(value)]) diff --git a/test/ObjectVar.py b/test/test_2300_object_var.py similarity index 89% rename from test/ObjectVar.py rename to test/test_2300_object_var.py index e09713c..5db7d50 100644 --- a/test/ObjectVar.py +++ b/test/test_2300_object_var.py @@ -7,7 +7,9 @@ # Canada. All rights reserved. #------------------------------------------------------------------------------ -"""Module for testing object variables.""" +""" +2300 - Module for testing object variables +""" import TestEnv @@ -48,16 +50,16 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(objectValue, expectedObjectValue) self.assertEqual(arrayValue, expectedArrayValue) - def testBindNullIn(self): - "test binding a null value (IN)" + def test_2300_BindNullIn(self): + "2300 - test binding a null value (IN)" var = self.cursor.var(cx_Oracle.DB_TYPE_OBJECT, typename = "UDT_OBJECT") result = self.cursor.callfunc("pkg_TestBindObject.GetStringRep", str, (var,)) self.assertEqual(result, "null") - def testBindObjectIn(self): - "test binding an object (IN)" + def test_2301_BindObjectIn(self): + "2301 - test binding an object (IN)" typeObj = self.connection.gettype("UDT_OBJECT") obj = typeObj.newobject() obj.NUMBERVALUE = 13 @@ -91,8 +93,8 @@ class TestCase(TestEnv.BaseTestCase): "udt_Object(null, 'Test With Dates', null, null, null, " \ "udt_SubObject(18.25, 'Sub String'), null)") - def testCopyObject(self): - "test copying an object" + def test_2302_CopyObject(self): + "2302 - test copying an object" typeObj = self.connection.gettype("UDT_OBJECT") obj = typeObj() obj.NUMBERVALUE = 5124 @@ -105,15 +107,15 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(obj.DATEVALUE, copiedObj.DATEVALUE) self.assertEqual(obj.TIMESTAMPVALUE, copiedObj.TIMESTAMPVALUE) - def testEmptyCollectionAsList(self): - "test getting an empty collection as a list" + def test_2303_EmptyCollectionAsList(self): + "2303 - test getting an empty collection as a list" typeName = "UDT_ARRAY" typeObj = self.connection.gettype(typeName) obj = typeObj.newobject() self.assertEqual(obj.aslist(), []) - def testFetchData(self): - "test fetching objects" + def test_2304_FetchData(self): + "2304 - test fetching objects" self.cursor.execute("alter session set time_zone = 'UTC'") self.cursor.execute(""" select @@ -151,8 +153,8 @@ class TestCase(TestEnv.BaseTestCase): [(10, 'element #1'), (20, 'element #2'), (30, 'element #3'), (40, 'element #4')]), None) - def testGetObjectType(self): - "test getting object type" + def test_2305_GetObjectType(self): + "2305 - test getting object type" typeObj = self.connection.gettype("UDT_OBJECT") self.assertEqual(typeObj.iscollection, False) self.assertEqual(typeObj.schema, self.connection.username.upper()) @@ -186,8 +188,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(subObjectArrayType.iscollection, True) self.assertEqual(subObjectArrayType.attributes, []) - def testObjectType(self): - "test object type data" + def test_2306_ObjectType(self): + "2306 - test object type data" self.cursor.execute(""" select ObjectCol from TestObjects @@ -196,11 +198,11 @@ class TestCase(TestEnv.BaseTestCase): objValue, = self.cursor.fetchone() self.assertEqual(objValue.type.schema, self.connection.username.upper()) - self.assertEqual(objValue.type.name, u"UDT_OBJECT") + self.assertEqual(objValue.type.name, "UDT_OBJECT") self.assertEqual(objValue.type.attributes[0].name, "NUMBERVALUE") - def testRoundTripObject(self): - "test inserting and then querying object with all data types" + def test_2307_RoundTripObject(self): + "2307 - test inserting and then querying object with all data types" self.cursor.execute("alter session set time_zone = 'UTC'") self.cursor.execute("truncate table TestClobs") self.cursor.execute("truncate table TestNClobs") @@ -218,7 +220,7 @@ class TestCase(TestEnv.BaseTestCase): nclob, = self.cursor.fetchone() self.cursor.execute("select BLOBCol from TestBlobs") blob, = self.cursor.fetchone() - typeObj = self.connection.gettype(u"UDT_OBJECT") + typeObj = self.connection.gettype("UDT_OBJECT") obj = typeObj.newobject() obj.NUMBERVALUE = 5 obj.STRINGVALUE = "A string" @@ -279,13 +281,13 @@ class TestCase(TestEnv.BaseTestCase): (23, 'Substring value'), None), None) self.connection.rollback() - def testInvalidTypeObject(self): - "test trying to find an object type that does not exist" + def test_2308_InvalidTypeObject(self): + "2308 - test trying to find an object type that does not exist" self.assertRaises(cx_Oracle.DatabaseError, self.connection.gettype, "A TYPE THAT DOES NOT EXIST") - def testAppendingWrongObjectType(self): - "test appending an object of the wrong type to a collection" + def test_2309_AppendingWrongObjectType(self): + "2309 - test appending an object of the wrong type to a collection" collectionObjType = self.connection.gettype("UDT_OBJECTARRAY") collectionObj = collectionObjType.newobject() arrayObjType = self.connection.gettype("UDT_ARRAY") @@ -293,8 +295,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertRaises(cx_Oracle.DatabaseError, collectionObj.append, arrayObj) - def testReferencingSubObj(self): - "test that referencing a sub object affects the parent object" + def test_2310_ReferencingSubObj(self): + "2310 - test that referencing a sub object affects the parent object" objType = self.connection.gettype("UDT_OBJECT") subObjType = self.connection.gettype("UDT_SUBOBJECT") obj = objType.newobject() @@ -304,8 +306,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(obj.SUBOBJECTVALUE.SUBNUMBERVALUE, 5) self.assertEqual(obj.SUBOBJECTVALUE.SUBSTRINGVALUE, "Substring") - def testAccessSubObjectParentObjectDestroyed(self): - "test that accessing sub object after parent object destroyed works" + def test_2311_AccessSubObjectParentObjectDestroyed(self): + "2311 - test accessing sub object after parent object destroyed" objType = self.connection.gettype("UDT_OBJECT") subObjType = self.connection.gettype("UDT_SUBOBJECT") arrayType = self.connection.gettype("UDT_OBJECTARRAY") @@ -322,8 +324,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(self.__GetObjectAsTuple(subObjArray), [(2, "AB"), (3, "CDE")]) - def testSettingAttrWrongObjectType(self): - "test assigning an object of the wrong type to an object attribute" + def test_2312_SettingAttrWrongObjectType(self): + "2312 - test assigning an object of wrong type to an object attribute" objType = self.connection.gettype("UDT_OBJECT") obj = objType.newobject() wrongObjType = self.connection.gettype("UDT_OBJECTARRAY") @@ -331,16 +333,16 @@ class TestCase(TestEnv.BaseTestCase): self.assertRaises(cx_Oracle.DatabaseError, setattr, obj, "SUBOBJECTVALUE", wrongObj) - def testSettingVarWrongObjectType(self): - "test setting value of object variable to wrong object type" + def test_2313_SettingVarWrongObjectType(self): + "2313 - test setting value of object variable to wrong object type" wrongObjType = self.connection.gettype("UDT_OBJECTARRAY") wrongObj = wrongObjType.newobject() var = self.cursor.var(cx_Oracle.DB_TYPE_OBJECT, typename = "UDT_OBJECT") self.assertRaises(cx_Oracle.DatabaseError, var.setvalue, 0, wrongObj) - def testStringFormat(self): - "test object string format" + def test_2314_StringFormat(self): + "2314 - test object string format" objType = self.connection.gettype("UDT_OBJECT") user = TestEnv.GetMainUser() self.assertEqual(str(objType), @@ -348,8 +350,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(str(objType.attributes[0]), "") - def testTrimCollectionList(self): - "test Trim number of elements from collection" + def test_2315_TrimCollectionList(self): + "2315 - test Trim number of elements from collection" subObjType = self.connection.gettype("UDT_SUBOBJECT") arrayType = self.connection.gettype("UDT_OBJECTARRAY") data = [(1, "AB"), (2, "CDE"), (3, "FGH"), (4, "IJK")] @@ -371,4 +373,3 @@ class TestCase(TestEnv.BaseTestCase): if __name__ == "__main__": TestEnv.RunTestCases() - diff --git a/test/SessionPool.py b/test/test_2400_session_pool.py similarity index 88% rename from test/SessionPool.py rename to test/test_2400_session_pool.py index c1cb34f..54679d2 100644 --- a/test/SessionPool.py +++ b/test/test_2400_session_pool.py @@ -1,5 +1,5 @@ #------------------------------------------------------------------------------ -# Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. # # Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved. # @@ -7,7 +7,9 @@ # Canada. All rights reserved. #------------------------------------------------------------------------------ -"""Module for testing session pools.""" +""" +2400 - Module for testing session pools +""" import TestEnv @@ -50,8 +52,8 @@ class TestCase(TestEnv.BaseTestCase): def tearDown(self): pass - def testPool(self): - """test that the pool is created and has the right attributes""" + def test_2400_Pool(self): + "2400 - test that the pool is created and has the right attributes" pool = TestEnv.GetPool(min=2, max=8, increment=3, getmode=cx_Oracle.SPOOL_ATTRVAL_WAIT) self.assertEqual(pool.username, TestEnv.GetMainUser(), @@ -90,14 +92,14 @@ class TestCase(TestEnv.BaseTestCase): pool.max_lifetime_session = 10 self.assertEqual(pool.max_lifetime_session, 10) - def testProxyAuth(self): - """test that proxy authentication is possible""" + def test_2401_ProxyAuth(self): + "2401 - test that proxy authentication is possible" pool = TestEnv.GetPool(min=2, max=8, increment=3, getmode=cx_Oracle.SPOOL_ATTRVAL_WAIT) self.assertEqual(pool.homogeneous, 1, "homogeneous should be 1 by default") self.assertRaises(cx_Oracle.DatabaseError, pool.acquire, - user = u"missing_proxyuser") + user = "missing_proxyuser") pool = TestEnv.GetPool(min=2, max=8, increment=3, getmode=cx_Oracle.SPOOL_ATTRVAL_WAIT, homogeneous=False) self.assertEqual(pool.homogeneous, 0, @@ -108,8 +110,8 @@ class TestCase(TestEnv.BaseTestCase): result, = cursor.fetchone() self.assertEqual(result, TestEnv.GetProxyUser().upper()) - def testRollbackOnDel(self): - "connection rolls back before being destroyed" + def test_2402_RollbackOnDel(self): + "2402 - connection rolls back before being destroyed" pool = TestEnv.GetPool() connection = pool.acquire() cursor = connection.cursor() @@ -122,8 +124,8 @@ class TestCase(TestEnv.BaseTestCase): count, = cursor.fetchone() self.assertEqual(count, 0) - def testRollbackOnRelease(self): - "connection rolls back before released back to the pool" + def test_2403_RollbackOnRelease(self): + "2403 - connection rolls back before released back to the pool" pool = TestEnv.GetPool() connection = pool.acquire() cursor = connection.cursor() @@ -138,8 +140,8 @@ class TestCase(TestEnv.BaseTestCase): count, = cursor.fetchone() self.assertEqual(count, 0) - def testThreading(self): - """test session pool to database with multiple threads""" + def test_2404_Threading(self): + "2404 - test session pool with multiple threads" self.pool = TestEnv.GetPool(min=5, max=20, increment=2, threaded=True, getmode=cx_Oracle.SPOOL_ATTRVAL_WAIT) threads = [] @@ -150,8 +152,8 @@ class TestCase(TestEnv.BaseTestCase): for thread in threads: thread.join() - def testThreadingWithErrors(self): - """test session pool to database with multiple threads (with errors)""" + def test_2405_ThreadingWithErrors(self): + "2405 - test session pool with multiple threads (with errors)" self.pool = TestEnv.GetPool(min=5, max=20, increment=2, threaded=True, getmode=cx_Oracle.SPOOL_ATTRVAL_WAIT) threads = [] @@ -162,8 +164,8 @@ class TestCase(TestEnv.BaseTestCase): for thread in threads: thread.join() - def testPurity(self): - """test session pool with various types of purity""" + def test_2406_Purity(self): + "2406 - test session pool with various types of purity" action = "TEST_ACTION" pool = TestEnv.GetPool(min=1, max=8, increment=1, getmode=cx_Oracle.SPOOL_ATTRVAL_WAIT) @@ -198,8 +200,8 @@ class TestCase(TestEnv.BaseTestCase): pool.drop(connection) self.assertEqual(pool.opened, 1, "opened (4)") - def testHeterogeneous(self): - """test heterogeneous pool with user and password specified""" + def test_2407_Heterogeneous(self): + "2407 - test heterogeneous pool with user and password specified" pool = TestEnv.GetPool(min=2, max=8, increment=3, homogeneous=False, getmode=cx_Oracle.SPOOL_ATTRVAL_WAIT) self.assertEqual(pool.homogeneous, 0) @@ -213,8 +215,8 @@ class TestCase(TestEnv.BaseTestCase): TestEnv.GetMainPassword()), TestEnv.GetProxyUser(), TestEnv.GetMainUser()) - def testHeterogenousWithoutUser(self): - """test heterogeneous pool without user and password specified""" + def test_2408_HeterogenousWithoutUser(self): + "2408 - test heterogeneous pool without user and password specified" pool = TestEnv.GetPool(user="", password="", min=2, max=8, increment=3, getmode=cx_Oracle.SPOOL_ATTRVAL_WAIT, homogeneous=False) self.__VerifyConnection(pool.acquire(TestEnv.GetMainUser(), @@ -226,15 +228,15 @@ class TestCase(TestEnv.BaseTestCase): TestEnv.GetMainPassword()), TestEnv.GetProxyUser(), TestEnv.GetMainUser()) - def testHeterogeneousWrongPassword(self): - """test heterogeneous pool with wrong password specified""" + def test_2409_HeterogeneousWrongPassword(self): + "2409 - test heterogeneous pool with wrong password specified" pool = TestEnv.GetPool(min=2, max=8, increment=3, getmode=cx_Oracle.SPOOL_ATTRVAL_WAIT, homogeneous=False) self.assertRaises(cx_Oracle.DatabaseError, pool.acquire, TestEnv.GetProxyUser(), "this is the wrong password") - def testTaggingSession(self): - "test tagging a session" + def test_2410_TaggingSession(self): + "2410 - test tagging a session" pool = TestEnv.GetPool(min=2, max=8, increment=3, getmode=cx_Oracle.SPOOL_ATTRVAL_NOWAIT) @@ -258,8 +260,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(conn.tag, tagUTC) conn.close() - def testPLSQLSessionCallbacks(self): - "test PL/SQL session callbacks" + def test_2411_PLSQLSessionCallbacks(self): + "2411 - test PL/SQL session callbacks" clientVersion = cx_Oracle.clientversion() if clientVersion < (12, 2): self.skipTest("PL/SQL session callbacks not supported before 12.2") @@ -296,8 +298,8 @@ class TestCase(TestEnv.BaseTestCase): expectedResults = list(zip(tags, actualTags)) self.assertEqual(results, expectedResults) - def testTaggingInvalidKey(self): - """testTagging with Invalid key""" + def test_2412_TaggingInvalidKey(self): + "2412 - testTagging with Invalid key" pool = TestEnv.GetPool(getmode=cx_Oracle.SPOOL_ATTRVAL_NOWAIT) conn = pool.acquire() self.assertRaises(TypeError, pool.release, conn, tag=12345) @@ -308,4 +310,3 @@ class TestCase(TestEnv.BaseTestCase): if __name__ == "__main__": TestEnv.RunTestCases() - diff --git a/test/StringVar.py b/test/test_2500_string_var.py similarity index 80% rename from test/StringVar.py rename to test/test_2500_string_var.py index 5a8043d..51ef477 100644 --- a/test/StringVar.py +++ b/test/test_2500_string_var.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- #------------------------------------------------------------------------------ -# Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. # # Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved. # @@ -8,7 +8,9 @@ # Canada. All rights reserved. #------------------------------------------------------------------------------ -"""Module for testing string variables.""" +""" +2500 - Module for testing string variables +""" import TestEnv @@ -35,23 +37,23 @@ class TestCase(TestEnv.BaseTestCase): self.rawData.append(dataTuple) self.dataByKey[i] = dataTuple - def testArrayWithIncreasedSize(self): - "test creating an array var and then increasing the internal size" + def test_2500_ArrayWithIncreasedSize(self): + "2500 - test creating array var and then increasing the internal size" val = ["12345678901234567890"] * 3 arrayVar = self.cursor.arrayvar(str, len(val), 4) arrayVar.setvalue(0, val) self.assertEqual(arrayVar.getvalue(), val) - def testBindString(self): - "test binding in a string" + def test_2501_BindString(self): + "2501 - test binding in a string" self.cursor.execute(""" select * from TestStrings where StringCol = :value""", value = "String 5") self.assertEqual(self.cursor.fetchall(), [self.dataByKey[5]]) - def testBindDifferentVar(self): - "test binding a different variable on second execution" + def test_2502_BindDifferentVar(self): + "2502 - test binding a different variable on second execution" retval_1 = self.cursor.var(cx_Oracle.STRING, 30) retval_2 = self.cursor.var(cx_Oracle.STRING, 30) self.cursor.execute("begin :retval := 'Called'; end;", @@ -61,13 +63,13 @@ class TestCase(TestEnv.BaseTestCase): retval = retval_2) self.assertEqual(retval_2.getvalue(), "Called") - def testExceedsNumElements(self): - "test exceeding the number of elements returns IndexError" + def test_2503_ExceedsNumElements(self): + "2503 - test exceeding the number of elements returns IndexError" var = self.cursor.var(str) self.assertRaises(IndexError, var.getvalue, 1) - def testBindStringAfterNumber(self): - "test binding in a string after setting input sizes to a number" + def test_2504_BindStringAfterNumber(self): + "2504 - test binding in a string after setting input sizes to a number" self.cursor.setinputsizes(value = cx_Oracle.NUMBER) self.cursor.execute(""" select * from TestStrings @@ -75,8 +77,8 @@ class TestCase(TestEnv.BaseTestCase): value = "String 6") self.assertEqual(self.cursor.fetchall(), [self.dataByKey[6]]) - def testBindStringArrayDirect(self): - "test binding in a string array" + def test_2505_BindStringArrayDirect(self): + "2505 - test binding in a string array" returnValue = self.cursor.var(cx_Oracle.NUMBER) array = [r[1] for r in self.rawData] statement = """ @@ -95,8 +97,8 @@ class TestCase(TestEnv.BaseTestCase): array = array) self.assertEqual(returnValue.getvalue(), 163) - def testBindStringArrayBySizes(self): - "test binding in a string array (with setinputsizes)" + def test_2506_BindStringArrayBySizes(self): + "2506 - test binding in a string array (with setinputsizes)" returnValue = self.cursor.var(cx_Oracle.NUMBER) self.cursor.setinputsizes(array = [cx_Oracle.STRING, 10]) array = [r[1] for r in self.rawData] @@ -110,8 +112,8 @@ class TestCase(TestEnv.BaseTestCase): array = array) self.assertEqual(returnValue.getvalue(), 87) - def testBindStringArrayByVar(self): - "test binding in a string array (with arrayvar)" + def test_2507_BindStringArrayByVar(self): + "2507 - test binding in a string array (with arrayvar)" returnValue = self.cursor.var(cx_Oracle.NUMBER) array = self.cursor.arrayvar(cx_Oracle.STRING, 10, 20) array.setvalue(0, [r[1] for r in self.rawData]) @@ -125,8 +127,8 @@ class TestCase(TestEnv.BaseTestCase): array = array) self.assertEqual(returnValue.getvalue(), 88) - def testBindInOutStringArrayByVar(self): - "test binding in/out a string array (with arrayvar)" + def test_2508_BindInOutStringArrayByVar(self): + "2508 - test binding in/out a string array (with arrayvar)" array = self.cursor.arrayvar(cx_Oracle.STRING, 10, 100) originalData = [r[1] for r in self.rawData] expectedData = ["Converted element # %d originally had length %d" % \ @@ -141,8 +143,8 @@ class TestCase(TestEnv.BaseTestCase): array = array) self.assertEqual(array.getvalue(), expectedData) - def testBindOutStringArrayByVar(self): - "test binding out a string array (with arrayvar)" + def test_2509_BindOutStringArrayByVar(self): + "2509 - test binding out a string array (with arrayvar)" array = self.cursor.arrayvar(cx_Oracle.STRING, 6, 100) expectedData = ["Test out element # %d" % i for i in range(1, 7)] self.cursor.execute(""" @@ -153,8 +155,8 @@ class TestCase(TestEnv.BaseTestCase): array = array) self.assertEqual(array.getvalue(), expectedData) - def testBindRaw(self): - "test binding in a raw" + def test_2510_BindRaw(self): + "2510 - test binding in a raw" self.cursor.setinputsizes(value = cx_Oracle.BINARY) self.cursor.execute(""" select * from TestStrings @@ -162,8 +164,8 @@ class TestCase(TestEnv.BaseTestCase): value = "Raw 4".encode("ascii")) self.assertEqual(self.cursor.fetchall(), [self.dataByKey[4]]) - def testBindAndFetchRowid(self): - "test binding (and fetching) a rowid" + def test_2511_BindAndFetchRowid(self): + "2511 - test binding (and fetching) a rowid" self.cursor.execute(""" select rowid from TestStrings @@ -176,8 +178,8 @@ class TestCase(TestEnv.BaseTestCase): value = rowid) self.assertEqual(self.cursor.fetchall(), [self.dataByKey[3]]) - def testBindAndFetchUniversalRowids(self): - "test binding (and fetching) universal rowids" + def test_2512_BindAndFetchUniversalRowids(self): + "2512 - test binding (and fetching) universal rowids" self.cursor.execute("truncate table TestUniversalRowids") data = [ (1, "ABC" * 75, datetime.datetime(2017, 4, 11)), @@ -203,16 +205,16 @@ class TestCase(TestEnv.BaseTestCase): fetchedData.extend(self.cursor.fetchall()) self.assertEqual(fetchedData, data) - def testBindNull(self): - "test binding in a null" + def test_2513_BindNull(self): + "2513 - test binding in a null" self.cursor.execute(""" select * from TestStrings where StringCol = :value""", value = None) self.assertEqual(self.cursor.fetchall(), []) - def testBindOutSetInputSizesByType(self): - "test binding out with set input sizes defined (by type)" + def test_2514_BindOutSetInputSizesByType(self): + "2514 - test binding out with set input sizes defined (by type)" vars = self.cursor.setinputsizes(value = cx_Oracle.STRING) self.cursor.execute(""" begin @@ -220,8 +222,8 @@ class TestCase(TestEnv.BaseTestCase): end;""") self.assertEqual(vars["value"].getvalue(), "TSI") - def testBindOutSetInputSizesByInteger(self): - "test binding out with set input sizes defined (by integer)" + def test_2515_BindOutSetInputSizesByInteger(self): + "2515 - test binding out with set input sizes defined (by integer)" vars = self.cursor.setinputsizes(value = 30) self.cursor.execute(""" begin @@ -229,8 +231,8 @@ class TestCase(TestEnv.BaseTestCase): end;""") self.assertEqual(vars["value"].getvalue(), "TSI (I)") - def testBindInOutSetInputSizesByType(self): - "test binding in/out with set input sizes defined (by type)" + def test_2516_BindInOutSetInputSizesByType(self): + "2516 - test binding in/out with set input sizes defined (by type)" vars = self.cursor.setinputsizes(value = cx_Oracle.STRING) self.cursor.execute(""" begin @@ -239,8 +241,8 @@ class TestCase(TestEnv.BaseTestCase): value = "InVal") self.assertEqual(vars["value"].getvalue(), "InVal TSI") - def testBindInOutSetInputSizesByInteger(self): - "test binding in/out with set input sizes defined (by integer)" + def test_2517_BindInOutSetInputSizesByInteger(self): + "2517 - test binding in/out with set input sizes defined (by integer)" vars = self.cursor.setinputsizes(value = 30) self.cursor.execute(""" begin @@ -249,8 +251,8 @@ class TestCase(TestEnv.BaseTestCase): value = "InVal") self.assertEqual(vars["value"].getvalue(), "InVal TSI (I)") - def testBindOutVar(self): - "test binding out with cursor.var() method" + def test_2518_BindOutVar(self): + "2518 - test binding out with cursor.var() method" var = self.cursor.var(cx_Oracle.STRING) self.cursor.execute(""" begin @@ -259,8 +261,8 @@ class TestCase(TestEnv.BaseTestCase): value = var) self.assertEqual(var.getvalue(), "TSI (VAR)") - def testBindInOutVarDirectSet(self): - "test binding in/out with cursor.var() method" + def test_2519_BindInOutVarDirectSet(self): + "2519 - test binding in/out with cursor.var() method" var = self.cursor.var(cx_Oracle.STRING) var.setvalue(0, "InVal") self.cursor.execute(""" @@ -270,8 +272,8 @@ class TestCase(TestEnv.BaseTestCase): value = var) self.assertEqual(var.getvalue(), "InVal TSI (VAR)") - def testBindLongString(self): - "test that binding a long string succeeds" + def test_2520_BindLongString(self): + "2520 - test that binding a long string succeeds" self.cursor.setinputsizes(bigString = cx_Oracle.DB_TYPE_LONG) self.cursor.execute(""" declare @@ -281,8 +283,8 @@ class TestCase(TestEnv.BaseTestCase): end;""", bigString = "X" * 10000) - def testBindLongStringAfterSettingSize(self): - "test that setinputsizes() returns a long variable" + def test_2521_BindLongStringAfterSettingSize(self): + "2521 - test that setinputsizes() returns a long variable" var = self.cursor.setinputsizes(test = 90000)["test"] inString = "1234567890" * 9000 var.setvalue(0, inString) @@ -291,8 +293,8 @@ class TestCase(TestEnv.BaseTestCase): "output does not match: in was %d, out was %d" % \ (len(inString), len(outString))) - def testCursorDescription(self): - "test cursor description is accurate" + def test_2522_CursorDescription(self): + "2522 - test cursor description is accurate" self.cursor.execute("select * from TestStrings") self.assertEqual(self.cursor.description, [ ('INTCOL', cx_Oracle.DB_TYPE_NUMBER, 10, None, 9, 0, 0), @@ -307,14 +309,14 @@ class TestCase(TestEnv.BaseTestCase): 50 * TestEnv.GetCharSetRatio(), None, None, 1) ]) - def testFetchAll(self): - "test that fetching all of the data returns the correct results" + def test_2523_FetchAll(self): + "2523 - test that fetching all of the data returns the correct results" self.cursor.execute("select * From TestStrings order by IntCol") self.assertEqual(self.cursor.fetchall(), self.rawData) self.assertEqual(self.cursor.fetchall(), []) - def testFetchMany(self): - "test that fetching data in chunks returns the correct results" + def test_2524_FetchMany(self): + "2524 - test that fetching data in chunks returns the correct results" self.cursor.execute("select * From TestStrings order by IntCol") self.assertEqual(self.cursor.fetchmany(3), self.rawData[0:3]) self.assertEqual(self.cursor.fetchmany(2), self.rawData[3:5]) @@ -322,8 +324,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(self.cursor.fetchmany(3), self.rawData[9:]) self.assertEqual(self.cursor.fetchmany(3), []) - def testFetchOne(self): - "test that fetching a single row returns the correct results" + def test_2525_FetchOne(self): + "2525 - test that fetching a single row returns the correct results" self.cursor.execute(""" select * from TestStrings @@ -333,8 +335,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(self.cursor.fetchone(), self.dataByKey[4]) self.assertEqual(self.cursor.fetchone(), None) - def testSupplementalCharacters(self): - "test that binding and fetching supplemental charcters works correctly" + def test_2526_SupplementalCharacters(self): + "2526 - test binding and fetching supplemental charcters" self.cursor.execute(""" select value from nls_database_parameters @@ -356,8 +358,8 @@ class TestCase(TestEnv.BaseTestCase): value, = self.cursor.fetchone() self.assertEqual(value, supplementalChars) - def testBindTwiceWithLargeStringSecond(self): - "test binding twice with a larger string the second time" + def test_2527_BindTwiceWithLargeStringSecond(self): + "2527 - test binding twice with a larger string the second time" self.cursor.execute("truncate table TestTempTable") sql = "insert into TestTempTable (IntCol, StringCol) values (:1, :2)" shortString = "short string" @@ -372,8 +374,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(self.cursor.fetchall(), [(1, shortString), (2, longString)]) - def testIssue50(self): - "test issue 50 - avoid error ORA-24816" + def test_2528_Issue50(self): + "2528 - test issue 50 - avoid error ORA-24816" cursor = self.connection.cursor() try: cursor.execute("drop table issue_50 purge") @@ -402,14 +404,14 @@ class TestCase(TestEnv.BaseTestCase): [2, u'd5ff845a', u'94275767', u'bf161ff6', u'', u'', idVar]) cursor.execute("drop table issue_50 purge") - def testSetRowidToString(self): - "test assigning a string to rowid" + def test_2529_SetRowidToString(self): + "2529 - test assigning a string to rowid" var = self.cursor.var(cx_Oracle.ROWID) self.assertRaises(cx_Oracle.NotSupportedError, var.setvalue, 0, "ABDHRYTHFJGKDKKDH") - def testShortXMLAsString(self): - "test fetching XMLType object as a string" + def test_2530_ShortXMLAsString(self): + "2530 - test fetching XMLType object as a string" self.cursor.execute(""" select XMLElement("string", stringCol) from TestStrings @@ -418,8 +420,8 @@ class TestCase(TestEnv.BaseTestCase): expectedValue = "String 1" self.assertEqual(actualValue, expectedValue) - def testLongXMLAsString(self): - "test inserting and fetching an XMLType object (1K) as a string" + def test_2531_LongXMLAsString(self): + "2531 - test inserting and fetching an XMLType object (1K) as a string" chars = string.ascii_uppercase + string.ascii_lowercase randomString = ''.join(random.choice(chars) for _ in range(1024)) intVal = 200 @@ -434,4 +436,3 @@ class TestCase(TestEnv.BaseTestCase): if __name__ == "__main__": TestEnv.RunTestCases() - diff --git a/test/TimestampVar.py b/test/test_2600_timestamp_var.py similarity index 82% rename from test/TimestampVar.py rename to test/test_2600_timestamp_var.py index 0752047..0ad6a9c 100644 --- a/test/TimestampVar.py +++ b/test/test_2600_timestamp_var.py @@ -1,5 +1,5 @@ #------------------------------------------------------------------------------ -# Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. # # Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved. # @@ -7,7 +7,9 @@ # Canada. All rights reserved. #------------------------------------------------------------------------------ -"""Module for testing timestamp variables.""" +""" +2600 - Module for testing timestamp variables +""" import TestEnv @@ -43,8 +45,8 @@ class TestCase(TestEnv.BaseTestCase): self.rawData.append(tuple) self.dataByKey[i] = tuple - def testBindTimestamp(self): - "test binding in a timestamp" + def test_2600_BindTimestamp(self): + "2600 - test binding in a timestamp" self.cursor.setinputsizes(value = cx_Oracle.DB_TYPE_TIMESTAMP) self.cursor.execute(""" select * from TestTimestamps @@ -52,8 +54,8 @@ class TestCase(TestEnv.BaseTestCase): value = cx_Oracle.Timestamp(2002, 12, 14, 0, 0, 10, 250000)) self.assertEqual(self.cursor.fetchall(), [self.dataByKey[5]]) - def testBindNull(self): - "test binding in a null" + def test_2601_BindNull(self): + "2601 - test binding in a null" self.cursor.setinputsizes(value = cx_Oracle.DB_TYPE_TIMESTAMP) self.cursor.execute(""" select * from TestTimestamps @@ -61,8 +63,8 @@ class TestCase(TestEnv.BaseTestCase): value = None) self.assertEqual(self.cursor.fetchall(), []) - def testBindOutSetInputSizes(self): - "test binding out with set input sizes defined" + def test_2602_BindOutSetInputSizes(self): + "2602 - test binding out with set input sizes defined" vars = self.cursor.setinputsizes(value = cx_Oracle.DB_TYPE_TIMESTAMP) self.cursor.execute(""" begin @@ -71,8 +73,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(vars["value"].getvalue(), cx_Oracle.Timestamp(2002, 12, 9)) - def testBindInOutSetInputSizes(self): - "test binding in/out with set input sizes defined" + def test_2603_BindInOutSetInputSizes(self): + "2603 - test binding in/out with set input sizes defined" vars = self.cursor.setinputsizes(value = cx_Oracle.DB_TYPE_TIMESTAMP) self.cursor.execute(""" begin @@ -82,8 +84,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(vars["value"].getvalue(), cx_Oracle.Timestamp(2002, 12, 17, 16, 0, 0)) - def testBindOutVar(self): - "test binding out with cursor.var() method" + def test_2604_BindOutVar(self): + "2604 - test binding out with cursor.var() method" var = self.cursor.var(cx_Oracle.DB_TYPE_TIMESTAMP) self.cursor.execute(""" begin @@ -94,8 +96,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(var.getvalue(), cx_Oracle.Timestamp(2002, 12, 31, 12, 31, 0)) - def testBindInOutVarDirectSet(self): - "test binding in/out with cursor.var() method" + def test_2605_BindInOutVarDirectSet(self): + "2605 - test binding in/out with cursor.var() method" var = self.cursor.var(cx_Oracle.DB_TYPE_TIMESTAMP) var.setvalue(0, cx_Oracle.Timestamp(2002, 12, 9, 6, 0, 0)) self.cursor.execute(""" @@ -106,8 +108,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(var.getvalue(), cx_Oracle.Timestamp(2002, 12, 14, 12, 0, 0)) - def testCursorDescription(self): - "test cursor description is accurate" + def test_2606_CursorDescription(self): + "2606 - test cursor description is accurate" self.cursor.execute("select * from TestTimestamps") self.assertEqual(self.cursor.description, [ ('INTCOL', cx_Oracle.DB_TYPE_NUMBER, 10, None, 9, 0, 0), @@ -116,14 +118,14 @@ class TestCase(TestEnv.BaseTestCase): ('NULLABLECOL', cx_Oracle.DB_TYPE_TIMESTAMP, 23, None, 0, 6, 1) ]) - def testFetchAll(self): - "test that fetching all of the data returns the correct results" + def test_2607_FetchAll(self): + "2607 - test that fetching all of the data returns the correct results" self.cursor.execute("select * From TestTimestamps order by IntCol") self.assertEqual(self.cursor.fetchall(), self.rawData) self.assertEqual(self.cursor.fetchall(), []) - def testFetchMany(self): - "test that fetching data in chunks returns the correct results" + def test_2608_FetchMany(self): + "2608 - test that fetching data in chunks returns the correct results" self.cursor.execute("select * From TestTimestamps order by IntCol") self.assertEqual(self.cursor.fetchmany(3), self.rawData[0:3]) self.assertEqual(self.cursor.fetchmany(2), self.rawData[3:5]) @@ -131,8 +133,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(self.cursor.fetchmany(3), self.rawData[9:]) self.assertEqual(self.cursor.fetchmany(3), []) - def testFetchOne(self): - "test that fetching a single row returns the correct results" + def test_2609_FetchOne(self): + "2609 - test that fetching a single row returns the correct results" self.cursor.execute(""" select * from TestTimestamps @@ -144,4 +146,3 @@ class TestCase(TestEnv.BaseTestCase): if __name__ == "__main__": TestEnv.RunTestCases() - diff --git a/test/AQ.py b/test/test_2700_aq.py similarity index 89% rename from test/AQ.py rename to test/test_2700_aq.py index bc1bda5..eac47bf 100644 --- a/test/AQ.py +++ b/test/test_2700_aq.py @@ -1,8 +1,10 @@ #------------------------------------------------------------------------------ -# Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. #------------------------------------------------------------------------------ -"""Module for testing AQ objects.""" +""" +2700 - Module for testing AQ +""" import TestEnv @@ -47,8 +49,8 @@ class TestCase(TestEnv.BaseTestCase): setattr(obj, attrName, value) self.assertEqual(getattr(obj, attrName), value) - def testDeqEmpty(self): - "test dequeuing an empty queue" + def test_2700_DeqEmpty(self): + "2700 - test dequeuing an empty queue" self.__clearBooksQueue() booksType = self.connection.gettype("UDT_BOOK") book = booksType.newobject() @@ -59,8 +61,8 @@ class TestCase(TestEnv.BaseTestCase): book) self.assertTrue(messageId is None) - def testDeqEnq(self): - "test enqueuing and dequeuing multiple messages" + def test_2701_DeqEnq(self): + "2701 - test enqueuing and dequeuing multiple messages" self.__clearBooksQueue() booksType = self.connection.gettype("UDT_BOOK") options = self.connection.enqoptions() @@ -81,8 +83,8 @@ class TestCase(TestEnv.BaseTestCase): self.connection.commit() self.assertEqual(results, self.bookData) - def testDeqModeRemoveNoData(self): - "test dequeuing with DEQ_REMOVE_NODATA option" + def test_2702_DeqModeRemoveNoData(self): + "2702 - test dequeuing with DEQ_REMOVE_NODATA option" self.__clearBooksQueue() booksType = self.connection.gettype("UDT_BOOK") book = booksType.newobject() @@ -104,8 +106,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertTrue(messageId is not None) self.assertEqual(book.TITLE, "") - def testDeqOptions(self): - "test getting/setting dequeue options attributes" + def test_2703_DeqOptions(self): + "2703 - test getting/setting dequeue options attributes" options = self.connection.deqoptions() self.__verifyAttribute(options, "condition", "TEST_CONDITION") self.__verifyAttribute(options, "consumername", "TEST_CONSUMERNAME") @@ -119,8 +121,8 @@ class TestCase(TestEnv.BaseTestCase): self.__verifyAttribute(options, "wait", 1287) self.__verifyAttribute(options, "msgid", b'mID') - def testDeqWithWait(self): - "test waiting for dequeue" + def test_2704_DeqWithWait(self): + "2704 - test waiting for dequeue" self.__clearBooksQueue() results = [] thread = threading.Thread(target = self.__deqInThread, @@ -139,13 +141,13 @@ class TestCase(TestEnv.BaseTestCase): thread.join() self.assertEqual(results, [(title, authors, price)]) - def testEnqOptions(self): - "test getting/setting enqueue options attributes" + def test_2705_EnqOptions(self): + "2705 - test getting/setting enqueue options attributes" options = self.connection.enqoptions() self.__verifyAttribute(options, "visibility", cx_Oracle.ENQ_IMMEDIATE) - def testErrorsForInvalidValues(self): - "test errors for invalid values for options" + def test_2706_ErrorsForInvalidValues(self): + "2706 - test errors for invalid values for options" booksType = self.connection.gettype("UDT_BOOK") book = booksType.newobject() options = self.connection.enqoptions() @@ -156,8 +158,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertRaises(TypeError, self.connection.enq, self.bookQueueName, options, props, book) - def testMsgProps(self): - "test getting/setting message properties attributes" + def test_2707_MsgProps(self): + "2707 - test getting/setting message properties attributes" props = self.connection.msgproperties() self.__verifyAttribute(props, "correlation", "TEST_CORRELATION") self.__verifyAttribute(props, "delay", 60) @@ -169,8 +171,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(props.state, cx_Oracle.MSG_READY) self.assertEqual(props.deliverymode, 0) - def testVisibilityModeCommit(self): - "test enqueue visibility option - ENQ_ON_COMMIT" + def test_2708_VisibilityModeCommit(self): + "2708 - test enqueue visibility option - ENQ_ON_COMMIT" self.__clearBooksQueue() booksType = self.connection.gettype("UDT_BOOK") book = booksType.newobject() @@ -195,8 +197,8 @@ class TestCase(TestEnv.BaseTestCase): book) self.assertTrue(messageId is not None) - def testVisibilityModeImmediate(self): - "test enqueue visibility option - ENQ_IMMEDIATE" + def test_2709_VisibilityModeImmediate(self): + "2709 - test enqueue visibility option - ENQ_IMMEDIATE" self.__clearBooksQueue() booksType = self.connection.gettype("UDT_BOOK") book = booksType.newobject() @@ -219,8 +221,8 @@ class TestCase(TestEnv.BaseTestCase): otherConnection.commit() self.assertEqual(results, self.bookData[0]) - def testDeliveryModeSameBuffered(self): - "test enqueue/dequeue delivery modes identical - buffered" + def test_2710_DeliveryModeSameBuffered(self): + "2710 - test enqueue/dequeue delivery modes identical - buffered" self.__clearBooksQueue() booksType = self.connection.gettype("UDT_BOOK") book = booksType.newobject() @@ -245,8 +247,8 @@ class TestCase(TestEnv.BaseTestCase): otherConnection.commit() self.assertEqual(results, self.bookData[0]) - def testDeliveryModeSamePersistent(self): - "test enqueue/dequeue delivery modes identical - persistent" + def test_2711_DeliveryModeSamePersistent(self): + "2711 - test enqueue/dequeue delivery modes identical - persistent" self.__clearBooksQueue() booksType = self.connection.gettype("UDT_BOOK") book = booksType.newobject() @@ -271,8 +273,8 @@ class TestCase(TestEnv.BaseTestCase): otherConnection.commit() self.assertEqual(results, self.bookData[0]) - def testDeliveryModeSamePersistentBuffered(self): - "test enqueue/dequeue delivery modes identical - persistent/buffered" + def test_2712_DeliveryModeSamePersistentBuffered(self): + "2712 - test enqueue/dequeue delivery modes the same" self.__clearBooksQueue() booksType = self.connection.gettype("UDT_BOOK") book = booksType.newobject() @@ -297,8 +299,8 @@ class TestCase(TestEnv.BaseTestCase): otherConnection.commit() self.assertEqual(results, self.bookData[0]) - def testDeliveryModeDifferent(self): - "test enqueue/dequeue delivery modes different" + def test_2713_DeliveryModeDifferent(self): + "2713 - test enqueue/dequeue delivery modes different" self.__clearBooksQueue() booksType = self.connection.gettype("UDT_BOOK") book = booksType.newobject() @@ -322,8 +324,8 @@ class TestCase(TestEnv.BaseTestCase): book) self.assertTrue(messageId is None) - def testDequeueTransformation(self): - "test dequeue transformation" + def test_2714_DequeueTransformation(self): + "2714 - test dequeue transformation" self.__clearBooksQueue() booksType = self.connection.gettype("UDT_BOOK") book = booksType.newobject() @@ -347,8 +349,8 @@ class TestCase(TestEnv.BaseTestCase): otherPrice = book.PRICE self.assertEqual(otherPrice, expectedPrice) - def testEnqueueTransformation(self): - "test enqueue transformation" + def test_2715_EnqueueTransformation(self): + "2715 - test enqueue transformation" self.__clearBooksQueue() booksType = self.connection.gettype("UDT_BOOK") book = booksType.newobject() @@ -374,4 +376,3 @@ class TestCase(TestEnv.BaseTestCase): if __name__ == "__main__": TestEnv.RunTestCases() - diff --git a/test/BulkAQ.py b/test/test_2800_bulk_aq.py similarity index 88% rename from test/BulkAQ.py rename to test/test_2800_bulk_aq.py index 5abbc31..4e7debb 100644 --- a/test/BulkAQ.py +++ b/test/test_2800_bulk_aq.py @@ -1,8 +1,10 @@ #------------------------------------------------------------------------------ -# Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. #------------------------------------------------------------------------------ -"""Module for testing AQ Bulk enqueue/dequeue.""" +""" +2800 - Module for testing AQ Bulk enqueue/dequeue +""" import TestEnv @@ -50,8 +52,8 @@ class TestCase(TestEnv.BaseTestCase): self.connection.commit() return queue - def testEnqAndDeq(self): - "test bulk enqueue and dequeue" + def test_2800_EnqAndDeq(self): + "2800 - test bulk enqueue and dequeue" queue = self.__getAndClearRawQueue() messages = [self.connection.msgproperties(payload=d) \ for d in RAW_PAYLOAD_DATA] @@ -61,15 +63,15 @@ class TestCase(TestEnv.BaseTestCase): self.connection.commit() self.assertEqual(data, RAW_PAYLOAD_DATA) - def testDequeueEmpty(self): - "test empty bulk dequeue" + def test_2801_DequeueEmpty(self): + "2801 - test empty bulk dequeue" queue = self.__getAndClearRawQueue() messages = queue.deqMany(5) self.connection.commit() self.assertEqual(messages, []) - def testDeqWithWait(self): - "test bulk dequeue with wait" + def test_2802_DeqWithWait(self): + "2802 - test bulk dequeue with wait" queue = self.__getAndClearRawQueue() results = [] thread = threading.Thread(target=self.__deqInThread, args=(results,)) @@ -81,8 +83,8 @@ class TestCase(TestEnv.BaseTestCase): thread.join() self.assertEqual(results, RAW_PAYLOAD_DATA) - def testEnqAndDeqMultipleTimes(self): - "test enqueue and dequeue multiple times" + def test_2803_EnqAndDeqMultipleTimes(self): + "2803 - test enqueue and dequeue multiple times" queue = self.__getAndClearRawQueue() dataToEnqueue = RAW_PAYLOAD_DATA for num in (2, 6, 4): @@ -99,8 +101,8 @@ class TestCase(TestEnv.BaseTestCase): self.connection.commit() self.assertEqual(allData, RAW_PAYLOAD_DATA) - def testEnqAndDeqVisibility(self): - "test visibility option for enqueue and dequeue" + def test_2804_EnqAndDeqVisibility(self): + "2804 - test visibility option for enqueue and dequeue" queue = self.__getAndClearRawQueue() # first test with ENQ_ON_COMMIT (commit required) diff --git a/test/Rowid.py b/test/test_2900_rowid.py similarity index 78% rename from test/Rowid.py rename to test/test_2900_rowid.py index 5d21876..e5eb2cb 100644 --- a/test/Rowid.py +++ b/test/test_2900_rowid.py @@ -1,9 +1,10 @@ -# -*- coding: utf-8 -*- #------------------------------------------------------------------------------ -# Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. #------------------------------------------------------------------------------ -"""Module for testing Rowids""" +""" +2900 - Module for testing Rowids +""" import TestEnv @@ -21,16 +22,16 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(len(rows), 1) self.assertEqual(rows[0][0], intVal) - def testSelectRowidsRegular(self): - "test selecting all rowids from a regular table" + def test_2900_SelectRowidsRegular(self): + "2900 - test selecting all rowids from a regular table" self.__TestSelectRowids("TestNumbers") - def testSelectRowidsIndexOrganised(self): - "test selecting all rowids from an index organised table" + def test_2901_SelectRowidsIndexOrganised(self): + "2901 - test selecting all rowids from an index organised table" self.__TestSelectRowids("TestUniversalRowids") - def testInsertInvalidRowid(self): - "test inserting an invalid rowid" + def test_2902_InsertInvalidRowid(self): + "2902 - test inserting an invalid rowid" self.assertRaises(cx_Oracle.DatabaseError, self.cursor.execute, "insert into TestRowids (IntCol, RowidCol) values (1, :rid)", rid = 12345) @@ -38,8 +39,8 @@ class TestCase(TestEnv.BaseTestCase): "insert into TestRowids (IntCol, RowidCol) values (1, :rid)", rid = "523lkhlf") - def testInsertRowids(self): - "test inserting rowids and verify they are inserted correctly" + def test_2903_InsertRowids(self): + "2903 - test inserting rowids and verify they are inserted correctly" self.cursor.execute("select IntCol, rowid from TestNumbers") rows = self.cursor.fetchall() self.cursor.execute("truncate table TestRowids") @@ -59,4 +60,3 @@ class TestCase(TestEnv.BaseTestCase): if __name__ == "__main__": TestEnv.RunTestCases() - diff --git a/test/Subscription.py b/test/test_3000_subscription.py similarity index 94% rename from test/Subscription.py rename to test/test_3000_subscription.py index 6210532..1225e0c 100644 --- a/test/Subscription.py +++ b/test/test_3000_subscription.py @@ -1,8 +1,10 @@ #------------------------------------------------------------------------------ -# Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. #------------------------------------------------------------------------------ -"""Module for testing subscriptions.""" +""" +3000 - Module for testing subscriptions +""" import TestEnv @@ -36,8 +38,8 @@ class SubscriptionData(object): class TestCase(TestEnv.BaseTestCase): - def testSubscription(self): - "test Subscription for insert, update, delete and truncate" + def test_3000_Subscription(self): + "3000 - test Subscription for insert, update, delete and truncate" # skip if running on the Oracle Cloud, which does not support # subscriptions currently @@ -111,4 +113,3 @@ class TestCase(TestEnv.BaseTestCase): if __name__ == "__main__": TestEnv.RunTestCases() - diff --git a/test/BooleanVar.py b/test/test_3100_boolean_var.py similarity index 65% rename from test/BooleanVar.py rename to test/test_3100_boolean_var.py index 660a52d..8cc84ad 100644 --- a/test/BooleanVar.py +++ b/test/test_3100_boolean_var.py @@ -1,5 +1,5 @@ #------------------------------------------------------------------------------ -# Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. # # Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved. # @@ -7,12 +7,17 @@ # Canada. All rights reserved. #------------------------------------------------------------------------------ -"""Module for testing boolean variables.""" +""" +3100 - Module for testing boolean variables +""" +import unittest import TestEnv import cx_Oracle +@unittest.skipUnless(TestEnv.GetClientVersion() >= (12, 1), + "unsupported client") class TestCase(TestEnv.BaseTestCase): def __testBindValueAsBoolean(self, value): @@ -23,48 +28,48 @@ class TestCase(TestEnv.BaseTestCase): (var,)) self.assertEqual(result, expectedResult) - def testBindFalse(self): - "test binding in a False value" + def test_3100_BindFalse(self): + "3100 - test binding in a False value" result = self.cursor.callfunc("pkg_TestBooleans.GetStringRep", str, (False,)) self.assertEqual(result, "FALSE") - def testBindFloatAsBoolean(self): - "test binding in a float as a boolean" + def test_3101_BindFloatAsBoolean(self): + "3101 - test binding in a float as a boolean" self.__testBindValueAsBoolean(0.0) self.__testBindValueAsBoolean(1.0) - def testBindIntegerAsBoolean(self): - "test binding in an integer as a boolean" + def test_3102_BindIntegerAsBoolean(self): + "3102 - test binding in an integer as a boolean" self.__testBindValueAsBoolean(0) self.__testBindValueAsBoolean(1) - def testBindNull(self): - "test binding in a null value" + def test_3103_BindNull(self): + "3103 - test binding in a null value" self.cursor.setinputsizes(None, bool) result = self.cursor.callfunc("pkg_TestBooleans.GetStringRep", str, (None,)) self.assertEqual(result, "NULL") - def testBindOutFalse(self): - "test binding out a boolean value (False)" + def test_3104_BindOutFalse(self): + "3104 - test binding out a boolean value (False)" result = self.cursor.callfunc("pkg_TestBooleans.IsLessThan10", cx_Oracle.DB_TYPE_BOOLEAN, (15,)) self.assertEqual(result, False) - def testBindOutTrue(self): - "test binding out a boolean value (True)" + def test_3105_BindOutTrue(self): + "3105 - test binding out a boolean value (True)" result = self.cursor.callfunc("pkg_TestBooleans.IsLessThan10", bool, (5,)) self.assertEqual(result, True) - def testBindStringAsBoolean(self): - "test binding in a string as a boolean" + def test_3106_BindStringAsBoolean(self): + "3106 - test binding in a string as a boolean" self.__testBindValueAsBoolean("") self.__testBindValueAsBoolean("0") - def testBindTrue(self): - "test binding in a True value" + def test_3107_BindTrue(self): + "3107 - test binding in a True value" result = self.cursor.callfunc("pkg_TestBooleans.GetStringRep", str, (True,)) self.assertEqual(result, "TRUE") diff --git a/test/Features12_1.py b/test/test_3200_features_12_1.py similarity index 84% rename from test/Features12_1.py rename to test/test_3200_features_12_1.py index e200c04..09e7aa7 100644 --- a/test/Features12_1.py +++ b/test/test_3200_features_12_1.py @@ -1,5 +1,5 @@ #------------------------------------------------------------------------------ -# Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. # # Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved. # @@ -7,17 +7,22 @@ # Canada. All rights reserved. #------------------------------------------------------------------------------ -"""Module for testing features introduced in 12.1""" +""" +3200 - Module for testing features introduced in 12.1 +""" import TestEnv import cx_Oracle import datetime +import unittest +@unittest.skipUnless(TestEnv.GetClientVersion() >= (12, 1), + "unsupported client") class TestCase(TestEnv.BaseTestCase): - def testArrayDMLRowCountsOff(self): - "test executing with arraydmlrowcounts mode disabled" + def test_3200_ArrayDMLRowCountsOff(self): + "3200 - test executing with arraydmlrowcounts mode disabled" self.cursor.execute("truncate table TestArrayDML") rows = [ (1, "First"), (2, "Second") ] @@ -31,8 +36,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertRaises(cx_Oracle.DatabaseError, self.cursor.getarraydmlrowcounts) - def testArrayDMLRowCountsOn(self): - "test executing with arraydmlrowcounts mode enabled" + def test_3201_ArrayDMLRowCountsOn(self): + "3201 - test executing with arraydmlrowcounts mode enabled" self.cursor.execute("truncate table TestArrayDML") rows = [ ( 1, "First", 100), ( 2, "Second", 200), @@ -48,8 +53,8 @@ class TestCase(TestEnv.BaseTestCase): count, = self.cursor.fetchone() self.assertEqual(count, len(rows)) - def testBindPLSQLBooleanCollectionIn(self): - "test binding a boolean collection (in)" + def test_3202_BindPLSQLBooleanCollectionIn(self): + "3202 - test binding a boolean collection (in)" typeObj = self.connection.gettype("PKG_TESTBOOLEANS.UDT_BOOLEANLIST") obj = typeObj.newobject() obj.setelement(1, True) @@ -58,15 +63,15 @@ class TestCase(TestEnv.BaseTestCase): (obj,)) self.assertEqual(result, 5) - def testBindPLSQLBooleanCollectionOut(self): - "test binding a boolean collection (out)" + def test_3203_BindPLSQLBooleanCollectionOut(self): + "3203 - test binding a boolean collection (out)" typeObj = self.connection.gettype("PKG_TESTBOOLEANS.UDT_BOOLEANLIST") obj = typeObj.newobject() self.cursor.callproc("pkg_TestBooleans.TestOutArrays", (6, obj)) self.assertEqual(obj.aslist(), [True, False, True, False, True, False]) - def testBindPLSQLDateCollectionIn(self): - "test binding a PL/SQL date collection (in)" + def test_3204_BindPLSQLDateCollectionIn(self): + "3204 - test binding a PL/SQL date collection (in)" typeObj = self.connection.gettype("PKG_TESTDATEARRAYS.UDT_DATELIST") obj = typeObj.newobject() obj.setelement(1, datetime.datetime(2016, 2, 5)) @@ -76,8 +81,8 @@ class TestCase(TestEnv.BaseTestCase): cx_Oracle.NUMBER, (2, datetime.datetime(2016, 2, 1), obj)) self.assertEqual(result, 24.75) - def testBindPLSQLDateCollectionInOut(self): - "test binding a PL/SQL date collection (in/out)" + def test_3205_BindPLSQLDateCollectionInOut(self): + "3205 - test binding a PL/SQL date collection (in/out)" typeObj = self.connection.gettype("PKG_TESTDATEARRAYS.UDT_DATELIST") obj = typeObj.newobject() obj.setelement(1, datetime.datetime(2016, 1, 1)) @@ -91,8 +96,8 @@ class TestCase(TestEnv.BaseTestCase): datetime.datetime(2016, 1, 20), datetime.datetime(2016, 1, 26)]) - def testBindPLSQLDateCollectionOut(self): - "test binding a PL/SQL date collection (out)" + def test_3206_BindPLSQLDateCollectionOut(self): + "3206 - test binding a PL/SQL date collection (out)" typeObj = self.connection.gettype("PKG_TESTDATEARRAYS.UDT_DATELIST") obj = typeObj.newobject() self.cursor.callproc("pkg_TestDateArrays.TestOutArrays", (3, obj)) @@ -101,8 +106,8 @@ class TestCase(TestEnv.BaseTestCase): datetime.datetime(2002, 12, 14, 9, 36), datetime.datetime(2002, 12, 15, 14, 24)]) - def testBindPLSQLNumberCollectionIn(self): - "test binding a PL/SQL number collection (in)" + def test_3207_BindPLSQLNumberCollectionIn(self): + "3207 - test binding a PL/SQL number collection (in)" typeObj = self.connection.gettype("PKG_TESTNUMBERARRAYS.UDT_NUMBERLIST") obj = typeObj.newobject() obj.setelement(1, 10) @@ -111,8 +116,8 @@ class TestCase(TestEnv.BaseTestCase): (5, obj)) self.assertEqual(result, 155) - def testBindPLSQLNumberCollectionInOut(self): - "test binding a PL/SQL number collection (in/out)" + def test_3208_BindPLSQLNumberCollectionInOut(self): + "3208 - test binding a PL/SQL number collection (in/out)" typeObj = self.connection.gettype("PKG_TESTNUMBERARRAYS.UDT_NUMBERLIST") obj = typeObj.newobject() obj.setelement(1, 5) @@ -120,15 +125,15 @@ class TestCase(TestEnv.BaseTestCase): self.cursor.callproc("pkg_TestNumberArrays.TestInOutArrays", (4, obj)) self.assertEqual(obj.aslist(), [50, 80, 30, 20]) - def testBindPLSQLNumberCollectionOut(self): - "test binding a PL/SQL number collection (out)" + def test_3209_BindPLSQLNumberCollectionOut(self): + "3209 - test binding a PL/SQL number collection (out)" typeObj = self.connection.gettype("PKG_TESTNUMBERARRAYS.UDT_NUMBERLIST") obj = typeObj.newobject() self.cursor.callproc("pkg_TestNumberArrays.TestOutArrays", (3, obj)) self.assertEqual(obj.aslist(), [100, 200, 300]) - def testBindPLSQLRecordArray(self): - "test binding an array of PL/SQL records (in)" + def test_3210_BindPLSQLRecordArray(self): + "3210 - test binding an array of PL/SQL records (in)" recType = self.connection.gettype("PKG_TESTRECORDS.UDT_RECORD") arrayType = self.connection.gettype("PKG_TESTRECORDS.UDT_RECORDARRAY") arrayObj = arrayType.newobject() @@ -158,8 +163,8 @@ class TestCase(TestEnv.BaseTestCase): "to_timestamp('2017-01-03 00:00:00', " \ "'YYYY-MM-DD HH24:MI:SS'), false, 10, 4)") - def testBindPLSQLRecordIn(self): - "test binding a PL/SQL record (in)" + def test_3211_BindPLSQLRecordIn(self): + "3211 - test binding a PL/SQL record (in)" typeObj = self.connection.gettype("PKG_TESTRECORDS.UDT_RECORD") obj = typeObj.newobject() obj.NUMBERVALUE = 18 @@ -177,8 +182,8 @@ class TestCase(TestEnv.BaseTestCase): "to_timestamp('2016-02-12 14:25:36', " \ "'YYYY-MM-DD HH24:MI:SS'), false, 21, 5)") - def testBindPLSQLRecordOut(self): - "test binding a PL/SQL record (out)" + def test_3212_BindPLSQLRecordOut(self): + "3212 - test binding a PL/SQL record (out)" typeObj = self.connection.gettype("PKG_TESTRECORDS.UDT_RECORD") obj = typeObj.newobject() obj.NUMBERVALUE = 5 @@ -198,8 +203,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(obj.PLSINTEGERVALUE, 45) self.assertEqual(obj.BINARYINTEGERVALUE, 10) - def testBindPLSQLStringCollectionIn(self): - "test binding a PL/SQL string collection (in)" + def test_3213_BindPLSQLStringCollectionIn(self): + "3213 - test binding a PL/SQL string collection (in)" typeObj = self.connection.gettype("PKG_TESTSTRINGARRAYS.UDT_STRINGLIST") obj = typeObj.newobject() obj.setelement(1, "First element") @@ -209,8 +214,8 @@ class TestCase(TestEnv.BaseTestCase): (5, obj)) self.assertEqual(result, 45) - def testBindPLSQLStringCollectionInOut(self): - "test binding a PL/SQL string collection (in/out)" + def test_3214_BindPLSQLStringCollectionInOut(self): + "3214 - test binding a PL/SQL string collection (in/out)" typeObj = self.connection.gettype("PKG_TESTSTRINGARRAYS.UDT_STRINGLIST") obj = typeObj.newobject() obj.setelement(1, "The first element") @@ -222,8 +227,8 @@ class TestCase(TestEnv.BaseTestCase): 'Converted element # 2 originally had length 18', 'Converted element # 3 originally had length 27']) - def testBindPLSQLStringCollectionOut(self): - "test binding a PL/SQL string collection (out)" + def test_3215_BindPLSQLStringCollectionOut(self): + "3215 - test binding a PL/SQL string collection (out)" typeObj = self.connection.gettype("PKG_TESTSTRINGARRAYS.UDT_STRINGLIST") obj = typeObj.newobject() self.cursor.callproc("pkg_TestStringArrays.TestOutArrays", (4, obj)) @@ -233,8 +238,8 @@ class TestCase(TestEnv.BaseTestCase): 'Test out element # 3', 'Test out element # 4']) - def testBindPLSQLStringCollectionOutWithHoles(self): - "test binding a PL/SQL string collection (out with holes)" + def test_3216_BindPLSQLStringCollectionOutWithHoles(self): + "3216 - test binding a PL/SQL string collection (out with holes)" typeObj = self.connection.gettype("PKG_TESTSTRINGARRAYS.UDT_STRINGLIST") obj = typeObj.newobject() self.cursor.callproc("pkg_TestStringArrays.TestIndexBy", (obj,)) @@ -261,8 +266,8 @@ class TestCase(TestEnv.BaseTestCase): { -1048576 : 'First element', 8388608: 'Fourth element' }) - def testExceptionInIteration(self): - "test executing with arraydmlrowcounts with exception" + def test_3217_ExceptionInIteration(self): + "3217 - test executing with arraydmlrowcounts with exception" self.cursor.execute("truncate table TestArrayDML") rows = [ (1, "First"), (2, "Second"), @@ -273,8 +278,8 @@ class TestCase(TestEnv.BaseTestCase): sql, rows, arraydmlrowcounts = True) self.assertEqual(self.cursor.getarraydmlrowcounts(), [1, 1]) - def testExecutingDelete(self): - "test executing delete statement with arraydmlrowcount mode" + def test_3218_ExecutingDelete(self): + "3218 - test executing delete statement with arraydmlrowcount mode" self.cursor.execute("truncate table TestArrayDML") rows = [ (1, "First", 100), (2, "Second", 200), @@ -293,8 +298,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(self.cursor.getarraydmlrowcounts(), [1, 3, 2]) self.assertEqual(self.cursor.rowcount, 6) - def testExecutingUpdate(self): - "test executing update statement with arraydmlrowcount mode" + def test_3219_ExecutingUpdate(self): + "3219 - test executing update statement with arraydmlrowcount mode" self.cursor.execute("truncate table TestArrayDML") rows = [ (1, "First",100), (2, "Second",200), @@ -316,8 +321,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(self.cursor.getarraydmlrowcounts(), [1, 1, 3, 2]) self.assertEqual(self.cursor.rowcount, 7) - def testImplicitResults(self): - "test getimplicitresults() returns the correct data" + def test_3220_ImplicitResults(self): + "3220 - test getimplicitresults() returns the correct data" self.cursor.execute(""" declare c1 sys_refcursor; @@ -344,13 +349,13 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual([n for n, in results[0]], [3.75, 5, 6.25]) self.assertEqual([n for n, in results[1]], [8.75, 10, 11.25, 12.5]) - def testImplicitResultsNoStatement(self): - "test getimplicitresults() without executing a statement" + def test_3221_ImplicitResultsNoStatement(self): + "3221 - test getimplicitresults() without executing a statement" self.assertRaises(cx_Oracle.InterfaceError, self.cursor.getimplicitresults) - def testInsertWithBatchError(self): - "test executing insert with multiple distinct batch errors" + def test_3222_InsertWithBatchError(self): + "3222 - test executing insert with multiple distinct batch errors" self.cursor.execute("truncate table TestArrayDML") rows = [ (1, "First", 100), (2, "Second", 200), @@ -373,8 +378,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(actualErrors, expectedErrors) self.assertEqual(self.cursor.getarraydmlrowcounts(), [1, 1, 0, 1, 0]) - def testBatchErrorFalse(self): - "test batcherrors mode set to False" + def test_3223_BatchErrorFalse(self): + "3223 - test batcherrors mode set to False" self.cursor.execute("truncate table TestArrayDML") rows = [ (1, "First", 100), (2, "Second", 200), @@ -384,8 +389,8 @@ class TestCase(TestEnv.BaseTestCase): self.assertRaises(cx_Oracle.IntegrityError, self.cursor.executemany, sql, rows, batcherrors = False) - def testUpdatewithBatchError(self): - "test executing in succession with batch error" + def test_3224_UpdatewithBatchError(self): + "3224 - test executing in succession with batch error" self.cursor.execute("truncate table TestArrayDML") rows = [ (1, "First", 100), (2, "Second", 200), @@ -427,4 +432,3 @@ class TestCase(TestEnv.BaseTestCase): if __name__ == "__main__": TestEnv.RunTestCases() - diff --git a/test/SodaDatabase.py b/test/test_3300_soda_database.py similarity index 76% rename from test/SodaDatabase.py rename to test/test_3300_soda_database.py index 91e1c4d..072f7ed 100644 --- a/test/SodaDatabase.py +++ b/test/test_3300_soda_database.py @@ -1,14 +1,19 @@ #------------------------------------------------------------------------------ -# Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. #------------------------------------------------------------------------------ -"""Module for testing Simple Oracle Document Access (SODA) Database""" +""" +3300 - Module for testing Simple Oracle Document Access (SODA) Database +""" import TestEnv import cx_Oracle import json +import unittest +@unittest.skipIf(TestEnv.SkipSodaTests(), + "unsupported client/server combination") class TestCase(TestEnv.BaseTestCase): def __dropExistingCollections(self, sodaDatabase): @@ -25,9 +30,9 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(doc.key, key) self.assertEqual(doc.mediaType, mediaType) - def testCreateDocumentWithJson(self): - "test creating documents with JSON data" - sodaDatabase = self.getSodaDatabase() + def test_3300_CreateDocumentWithJson(self): + "3300 - test creating documents with JSON data" + sodaDatabase = self.connection.getSodaDatabase() val = {"testKey1" : "testValue1", "testKey2" : "testValue2" } strVal = json.dumps(val) bytesVal = strVal.encode("UTF-8") @@ -40,9 +45,9 @@ class TestCase(TestEnv.BaseTestCase): doc = sodaDatabase.createDocument(bytesVal, key, mediaType) self.__verifyDocument(doc, bytesVal, strVal, val, key, mediaType) - def testCreateDocumentWithRaw(self): - "test creating documents with raw data" - sodaDatabase = self.getSodaDatabase() + def test_3301_CreateDocumentWithRaw(self): + "3301 - test creating documents with raw data" + sodaDatabase = self.connection.getSodaDatabase() val = b"" key = "MyRawKey" mediaType = "text/html" @@ -53,9 +58,9 @@ class TestCase(TestEnv.BaseTestCase): doc = sodaDatabase.createDocument(val, key, mediaType) self.__verifyDocument(doc, val, key=key, mediaType=mediaType) - def testGetCollectionNames(self): - "test getting collection names from the database" - sodaDatabase = self.getSodaDatabase() + def test_3302_GetCollectionNames(self): + "3302 - test getting collection names from the database" + sodaDatabase = self.connection.getSodaDatabase() self.__dropExistingCollections(sodaDatabase) self.assertEqual(sodaDatabase.getCollectionNames(), []) names = ["zCol", "dCol", "sCol", "aCol", "gCol"] @@ -72,9 +77,9 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(sodaDatabase.getCollectionNames("z"), sortedNames[-1:]) - def testOpenCollection(self): - "test opening a collection" - sodaDatabase = self.getSodaDatabase() + def test_3303_OpenCollection(self): + "3303 - test opening a collection" + sodaDatabase = self.connection.getSodaDatabase() self.__dropExistingCollections(sodaDatabase) coll = sodaDatabase.openCollection("CollectionThatDoesNotExist") self.assertEqual(coll, None) @@ -83,19 +88,19 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(coll.name, createdColl.name) coll.drop() - def testRepr(self): - "test SodaDatabase representation" + def test_3304_Repr(self): + "3304 - test SodaDatabase representation" con1 = self.connection con2 = TestEnv.GetConnection() - sodaDatabase1 = self.getSodaDatabase() + sodaDatabase1 = self.connection.getSodaDatabase() sodaDatabase2 = con1.getSodaDatabase() sodaDatabase3 = con2.getSodaDatabase() self.assertEqual(str(sodaDatabase1), str(sodaDatabase2)) self.assertEqual(str(sodaDatabase2), str(sodaDatabase3)) - def testNegative(self): - "test negative cases for SODA database methods" - sodaDatabase = self.getSodaDatabase() + def test_3305_Negative(self): + "3305 - test negative cases for SODA database methods" + sodaDatabase = self.connection.getSodaDatabase() self.assertRaises(TypeError, sodaDatabase.createCollection) self.assertRaises(TypeError, sodaDatabase.createCollection, 1) self.assertRaises(cx_Oracle.DatabaseError, diff --git a/test/SodaCollection.py b/test/test_3400_soda_collection.py similarity index 81% rename from test/SodaCollection.py rename to test/test_3400_soda_collection.py index 0965946..8429e0c 100644 --- a/test/SodaCollection.py +++ b/test/test_3400_soda_collection.py @@ -1,13 +1,18 @@ #------------------------------------------------------------------------------ -# Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. #------------------------------------------------------------------------------ -"""Module for testing Simple Oracle Document Access (SODA) Collections""" +""" +3400 - Module for testing Simple Oracle Document Access (SODA) Collections +""" import TestEnv import cx_Oracle +import unittest +@unittest.skipIf(TestEnv.SkipSodaTests(), + "unsupported client/server combination") class TestCase(TestEnv.BaseTestCase): def __testSkip(self, coll, numToSkip, expectedContent): @@ -16,18 +21,18 @@ class TestCase(TestEnv.BaseTestCase): content = doc.getContent() if doc is not None else None self.assertEqual(content, expectedContent) - def testInvalidJson(self): - "test inserting invalid JSON value into SODA collection" + def test_3400_InvalidJson(self): + "3400 - test inserting invalid JSON value into SODA collection" invalidJson = "{testKey:testValue}" - sodaDatabase = self.getSodaDatabase() + sodaDatabase = self.connection.getSodaDatabase() coll = sodaDatabase.createCollection("cxoInvalidJSON") doc = sodaDatabase.createDocument(invalidJson) self.assertRaises(cx_Oracle.IntegrityError, coll.insertOne, doc) coll.drop() - def testInsertDocuments(self): - "test inserting documents into a SODA collection" - sodaDatabase = self.getSodaDatabase() + def test_3401_InsertDocuments(self): + "3401 - test inserting documents into a SODA collection" + sodaDatabase = self.connection.getSodaDatabase() coll = sodaDatabase.createCollection("cxoInsertDocs") coll.find().remove() valuesToInsert = [ @@ -47,9 +52,9 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(doc.getContent(), value) coll.drop() - def testSkipDocuments(self): - "test skipping documents in a SODA collection" - sodaDatabase = self.getSodaDatabase() + def test_3402_SkipDocuments(self): + "3402 - test skipping documents in a SODA collection" + sodaDatabase = self.connection.getSodaDatabase() coll = sodaDatabase.createCollection("cxoSkipDocs") coll.find().remove() valuesToInsert = [ @@ -67,9 +72,9 @@ class TestCase(TestEnv.BaseTestCase): self.__testSkip(coll, 4, None) self.__testSkip(coll, 125, None) - def testReplaceDocument(self): - "test replace documents in SODA collection" - sodaDatabase = self.getSodaDatabase() + def test_3403_ReplaceDocument(self): + "3403 - test replace documents in SODA collection" + sodaDatabase = self.connection.getSodaDatabase() coll = sodaDatabase.createCollection("cxoReplaceDoc") coll.find().remove() content = {'name': 'John', 'address': {'city': 'Sydney'}} @@ -81,9 +86,9 @@ class TestCase(TestEnv.BaseTestCase): newContent) coll.drop() - def testSearchDocumentsWithContent(self): - "test search documents with content using $like and $regex" - sodaDatabase = self.getSodaDatabase() + def test_3404_SearchDocumentsWithContent(self): + "3404 - test search documents with content using $like and $regex" + sodaDatabase = self.connection.getSodaDatabase() coll = sodaDatabase.createCollection("cxoSearchDocContent") coll.find().remove() data = [ @@ -118,9 +123,9 @@ class TestCase(TestEnv.BaseTestCase): expectedCount, filterSpec) coll.drop() - def testDocumentRemove(self): - "test removing documents" - sodaDatabase = self.getSodaDatabase() + def test_3405_DocumentRemove(self): + "3405 - test removing documents" + sodaDatabase = self.connection.getSodaDatabase() coll = sodaDatabase.createCollection("cxoRemoveDocs") coll.find().remove() data = [ @@ -143,8 +148,8 @@ class TestCase(TestEnv.BaseTestCase): self.connection.commit() coll.drop() - def testCreateAndDropIndex(self): - "test create and drop Index" + def test_3406_CreateAndDropIndex(self): + "3406 - test create and drop Index" indexName = "cxoTestIndexes_ix_1" indexSpec = { 'name': indexName, @@ -156,7 +161,7 @@ class TestCase(TestEnv.BaseTestCase): } ] } - sodaDatabase = self.getSodaDatabase() + sodaDatabase = self.connection.getSodaDatabase() coll = sodaDatabase.createCollection("cxoTestIndexes") coll.find().remove() self.connection.commit() @@ -167,10 +172,10 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(coll.dropIndex(indexName), False) coll.drop() - def testGetDocuments(self): - "test getting documents from Collection" + def test_3407_GetDocuments(self): + "3407 - test getting documents from Collection" self.connection.autocommit = True - sodaDatabase = self.getSodaDatabase() + sodaDatabase = self.connection.getSodaDatabase() coll = sodaDatabase.createCollection("cxoTestGetDocs") coll.find().remove() data = [ @@ -185,10 +190,10 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(fetchedKeys, insertedKeys) coll.drop() - def testCursor(self): - "test fetching documents from a cursor" + def test_3408_Cursor(self): + "3408 - test fetching documents from a cursor" self.connection.autocommit = True - sodaDatabase = self.getSodaDatabase() + sodaDatabase = self.connection.getSodaDatabase() coll = sodaDatabase.createCollection("cxoFindViaCursor") coll.find().remove() data = [ @@ -201,9 +206,9 @@ class TestCase(TestEnv.BaseTestCase): self.assertEqual(fetchedKeys, insertedKeys) coll.drop() - def testMultipleDocumentRemove(self): - "test removing multiple documents using multiple keys" - sodaDatabase = self.getSodaDatabase() + def test_3409_MultipleDocumentRemove(self): + "3409 - test removing multiple documents using multiple keys" + sodaDatabase = self.connection.getSodaDatabase() coll = sodaDatabase.createCollection("cxoRemoveMultipleDocs") coll.find().remove() data = [ @@ -222,9 +227,9 @@ class TestCase(TestEnv.BaseTestCase): self.connection.commit() coll.drop() - def testDocumentVersion(self): - "test using version to get documents and remove them" - sodaDatabase = self.getSodaDatabase() + def test_3410_DocumentVersion(self): + "3410 - test using version to get documents and remove them" + sodaDatabase = self.connection.getSodaDatabase() coll = sodaDatabase.createCollection("cxoDocumentVersion") coll.find().remove() content = {'name': 'John', 'address': {'city': 'Bangalore'}} @@ -246,9 +251,9 @@ class TestCase(TestEnv.BaseTestCase): self.connection.commit() coll.drop() - def testGetCursor(self): - "test keys with GetCursor" - sodaDatabase = self.getSodaDatabase() + def test_3411_GetCursor(self): + "3411 - test keys with GetCursor" + sodaDatabase = self.connection.getSodaDatabase() coll = sodaDatabase.createCollection("cxoKeysWithGetCursor") coll.find().remove() data = [ @@ -266,18 +271,20 @@ class TestCase(TestEnv.BaseTestCase): self.connection.commit() coll.drop() - def testCreatedOn(self): - "test createdOn attribute of Document" - sodaDatabase = self.getSodaDatabase() + def test_3412_CreatedOn(self): + "3412 - test createdOn attribute of Document" + sodaDatabase = self.connection.getSodaDatabase() coll = sodaDatabase.createCollection("cxoCreatedOn") coll.find().remove() data = {'name': 'John', 'address': {'city': 'Bangalore'}} doc = coll.insertOneAndGet(data) self.assertEqual(doc.createdOn, doc.lastModified) - def testSodaTruncate(self): - "test Soda truncate" - sodaDatabase = self.getSodaDatabase(minclient=(20,1)) + @unittest.skipIf(TestEnv.GetClientVersion() < (20, 1), + "unsupported client") + def test_3413_SodaTruncate(self): + "3413 - test Soda truncate" + sodaDatabase = self.connection.getSodaDatabase() coll = sodaDatabase.createCollection("cxoTruncateDocs") coll.find().remove() valuesToInsert = [ @@ -296,4 +303,3 @@ class TestCase(TestEnv.BaseTestCase): if __name__ == "__main__": TestEnv.RunTestCases() - diff --git a/test/test_dbapi20.py b/test/test_dbapi20.py deleted file mode 100644 index 32c7d26..0000000 --- a/test/test_dbapi20.py +++ /dev/null @@ -1,56 +0,0 @@ -#------------------------------------------------------------------------------ -# Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. -# -# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved. -# -# Portions Copyright 2001-2007, Computronix (Canada) Ltd., Edmonton, Alberta, -# Canada. All rights reserved. -#------------------------------------------------------------------------------ - -"""Driver specific portion of the DB API test suite provided by Stuart Bishop - available at http://stuartbishop.net/Software/DBAPI20TestSuite/""" - -import cx_Oracle -import dbapi20 -import unittest - -import TestEnv - -class TestSuite(dbapi20.DatabaseAPI20Test): - - connect_args = (TestEnv.GetMainUser(), TestEnv.GetMainPassword(), - TestEnv.GetConnectString()) - driver = cx_Oracle - - # not implemented; see cx_Oracle specific test suite instead - def test_callproc(self): - pass - - # not implemented; see cx_Oracle specific test suite instead - def test_fetchmany(self): - pass - - # not implemented; Oracle does not support the concept - def test_nextset(self): - pass - - # not implemented; see cx_Oracle specific test suite instead - def test_rowcount(self): - pass - - # not implemented; see cx_Oracle specific test suite instead - def test_setinputsizes(self): - pass - - # not implemented; not used by cx_Oracle - def test_setoutputsize(self): - pass - - # not implemented; Oracle does not support the concept - def test_Time(self): - pass - -if __name__ == "__main__": - print("Testing cx_Oracle version", cx_Oracle.__version__) - TestEnv.RunTestCases() - diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..9ebba54 --- /dev/null +++ b/tox.ini @@ -0,0 +1,15 @@ +[tox] +envlist = py{36,37,38,39} + +[testenv] +commands = {envpython} test/TestEnv.py +passenv = + CX_ORACLE_TEST_MAIN_USER + CX_ORACLE_TEST_MAIN_PASSWORD + CX_ORACLE_TEST_PROXY_USER + CX_ORACLE_TEST_PROXY_PASSWORD + CX_ORACLE_TEST_CONNECT_STRING + CX_ORACLE_TEST_ADMIN_USER + CX_ORACLE_TEST_ADMIN_PASSWORD + DPI_DEBUG_LEVEL + ORACLE_HOME