diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-06-06 10:12:05 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-06-06 10:12:05 -0400 |
commit | 03633a6462ee16a1348acb98fe0323c74eb9ba85 (patch) | |
tree | 04621e773c0de3c4b93f2b6774b604132cfe204c /test/engine/test_parseconnect.py | |
parent | 3874d2576dc536b54af9f5525aff1fe59f4f00d3 (diff) | |
download | sqlalchemy-03633a6462ee16a1348acb98fe0323c74eb9ba85.tar.gz |
Pass URL object, not the string, to on_connect_url
The fix for pysqlcipher released in version 1.4.3 :ticket:`5848` was
unfortunately non-working, in that the new ``on_connect_url`` hook was
erroneously not receiving a ``URL`` object under normal usage of
:func:`_sa.create_engine` and instead received a string that was unhandled;
the test suite failed to fully set up the actual conditions under which
this hook is called. This has been fixed.
Fixes: #6586
Change-Id: I3bf738daec35877a10fdad740f08dca9e7420829
Diffstat (limited to 'test/engine/test_parseconnect.py')
-rw-r--r-- | test/engine/test_parseconnect.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/engine/test_parseconnect.py b/test/engine/test_parseconnect.py index 5e8fbfb5f..ea949dfd6 100644 --- a/test/engine/test_parseconnect.py +++ b/test/engine/test_parseconnect.py @@ -485,6 +485,39 @@ class CreateEngineTest(fixtures.TestBase): eq_(e.dialect.foobar, 5) eq_(e.dialect.bathoho, False) + def test_on_connect_url(self): + """test #6586""" + + tokens = __name__.split(".") + + canary = mock.Mock() + + class MyDialect(MockDialect): + def on_connect_url(self, url): + canary.on_connect_url(url) + + global dialect + dialect = MyDialect + registry.register( + "mockdialect.ocu", ".".join(tokens[0:-1]), tokens[-1] + ) + + create_engine("mockdialect+ocu://foo:bar@host/test") + eq_( + canary.mock_calls, + [ + mock.call.on_connect_url( + url.URL.create( + drivername="mockdialect+ocu", + username="foo", + password="bar", + host="host", + database="test", + ) + ) + ], + ) + def test_custom(self): dbapi = MockDBAPI( foober=12, lala=18, hoho={"this": "dict"}, fooz="somevalue" |