def _test_dialect_param_from_url(self, url_string, key, value): import cx_Oracle url_obj = url.make_url(url_string) dialect = cx_oracle.dialect(dbapi=cx_Oracle) with testing.expect_deprecated("cx_oracle dialect option %r should" % key): arg, kw = dialect.create_connect_args(url_obj) eq_(getattr(dialect, key), value) # test setting it on the dialect normally dialect = cx_oracle.dialect(dbapi=cx_Oracle, **{key: value}) eq_(getattr(dialect, key), value)
def test_threaded_deprecated_at_dialect_level(self): with testing.expect_deprecated( "The 'threaded' parameter to the cx_oracle dialect"): dialect = cx_oracle.dialect(threaded=False) arg, kw = dialect.create_connect_args( url.make_url("oracle+cx_oracle://scott:tiger@dsn")) eq_(kw["threaded"], False)
def _test_db_opt_unpresent(self, url_string, key): import cx_Oracle url_obj = url.make_url(url_string) dialect = cx_oracle.dialect(dbapi=cx_Oracle) arg, kw = dialect.create_connect_args(url_obj) assert key not in kw
def _test_db_opt(self, url_string, key, value): import cx_Oracle url_obj = url.make_url(url_string) dialect = cx_oracle.dialect(dbapi=cx_Oracle) arg, kw = dialect.create_connect_args(url_obj) eq_(kw[key], value)
def test_encoding_errors_cx_oracle_py3k( self, cx_Oracle, cx_oracle_type, ): ignore_dialect = cx_oracle.dialect(dbapi=cx_Oracle, encoding_errors="ignore") ignore_outputhandler = ( ignore_dialect._generate_connection_outputtype_handler()) cursor = mock.Mock() ignore_outputhandler(cursor, "foo", cx_oracle_type, None, None, None) eq_( cursor.mock_calls, [ mock.call.var( mock.ANY, None, cursor.arraysize, encodingErrors="ignore", ) ], )
def test_bindparam_quote_raise_on_expanding(self): assert_raises_message( exc.CompileError, "Can't use expanding feature with parameter name 'uid' on " "Oracle; it requires quoting which is not supported in this " "context", bindparam("uid", expanding=True).compile, dialect=cx_oracle.dialect(), )
def test_no_encoding_errors_sqla_py2k( self, cx_Oracle, cx_oracle_type, ): plain_dialect = cx_oracle.dialect(dbapi=cx_Oracle) plain_outputhandler = ( plain_dialect._generate_connection_outputtype_handler()) cursor = mock.Mock() plain_outputhandler(cursor, "foo", cx_oracle_type, None, None, None) outconverter = cursor.mock_calls[0][2]["outconverter"] self._assert_errorhandler(outconverter, False)
def test_older_cx_oracle_warning(self, cx_Oracle, cx_oracle_type): cx_Oracle.version = "6.3" ignore_dialect = cx_oracle.dialect(dbapi=cx_Oracle, encoding_errors="ignore") ignore_outputhandler = ( ignore_dialect._generate_connection_outputtype_handler()) cursor = mock.Mock() with testing.expect_warnings( r"cx_oracle version \(6, 3\) does not support encodingErrors"): ignore_outputhandler(cursor, "foo", cx_oracle_type, None, None, None)
def test_type_adapt(self, start, test): dialect = cx_oracle.dialect() assert isinstance( start.dialect_impl(dialect), test ), "wanted %r got %r" % (test, start.dialect_impl(dialect))
def test_type_adapt_nchar(self, start, test): dialect = cx_oracle.dialect(use_nchar_for_unicode=True) assert isinstance( start.dialect_impl(dialect), test ), "wanted %r got %r" % (test, start.dialect_impl(dialect))