示例#1
0
    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)
示例#2
0
 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)
示例#3
0
    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
示例#4
0
    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)
示例#5
0
    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(),
     )
示例#7
0
    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)
示例#8
0
    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)
示例#9
0
    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))
示例#10
0
    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))