diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-02-23 13:43:03 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-02-24 08:45:19 -0500 |
| commit | 8f9e971f10dee0614054671e0c284f0acace2d04 (patch) | |
| tree | ba0280b94a8c49358d8cabd1e27a22c8012c6dd0 /test/dialect | |
| parent | 19f13584b07b03a6ee775c197e0e8cda681e9d5a (diff) | |
| download | sqlalchemy-8f9e971f10dee0614054671e0c284f0acace2d04.tar.gz | |
support cx_Oracle DPI disconnect codes
Added support to parse "DPI" error codes from cx_Oracle exception objects
such as ``DPI-1080`` and ``DPI-1010``, both of which now indicate a
disconnect scenario as of cx_Oracle 8.3.
Fixes: #7748
Change-Id: I4a10d606d512c0d7f9b4653c47ea5734afffb8a5
Diffstat (limited to 'test/dialect')
| -rw-r--r-- | test/dialect/oracle/test_dialect.py | 54 |
1 files changed, 51 insertions, 3 deletions
diff --git a/test/dialect/oracle/test_dialect.py b/test/dialect/oracle/test_dialect.py index 5383ffc0c..e827fa56c 100644 --- a/test/dialect/oracle/test_dialect.py +++ b/test/dialect/oracle/test_dialect.py @@ -1,6 +1,7 @@ # coding: utf-8 import re +from unittest import mock from unittest.mock import Mock from sqlalchemy import bindparam @@ -30,7 +31,6 @@ from sqlalchemy.testing import config from sqlalchemy.testing import engines from sqlalchemy.testing import eq_ from sqlalchemy.testing import fixtures -from sqlalchemy.testing import mock from sqlalchemy.testing.schema import Column from sqlalchemy.testing.schema import Table from sqlalchemy.testing.suite import test_select @@ -56,7 +56,7 @@ class DialectTest(fixtures.TestBase): exc.InvalidRequestError, "cx_Oracle version 5.2 and above are supported", cx_oracle.OracleDialect_cx_oracle, - dbapi=Mock(), + dbapi=mock.Mock(), ) with mock.patch( @@ -64,13 +64,61 @@ class DialectTest(fixtures.TestBase): "_parse_cx_oracle_ver", lambda self, vers: (5, 3, 1), ): - cx_oracle.OracleDialect_cx_oracle(dbapi=Mock()) + cx_oracle.OracleDialect_cx_oracle(dbapi=mock.Mock()) class DialectWBackendTest(fixtures.TestBase): __backend__ = True __only_on__ = "oracle" + @testing.combinations( + ( + "db is not connected", + None, + True, + ), + ( + "ORA-1234 fake error", + 1234, + False, + ), + ( + "ORA-03114: not connected to ORACLE", + 3114, + True, + ), + ( + "DPI-1010: not connected", + None, + True, + ), + ( + "DPI-1010: make sure we read the code", + None, + True, + ), + ( + "DPI-1080: connection was closed by ORA-3113", + None, + True, + ), + ( + "DPI-1234: some other DPI error", + None, + False, + ), + ) + @testing.only_on("oracle+cx_oracle") + def test_is_disconnect(self, message, code, expected): + + dialect = testing.db.dialect + + exception_obj = dialect.dbapi.InterfaceError() + exception_obj.args = (Exception(message),) + exception_obj.args[0].code = code + + eq_(dialect.is_disconnect(exception_obj, None, None), expected) + def test_hypothetical_not_implemented_isolation_level(self): engine = engines.testing_engine() |
