33
44import sqlalchemy
55from conftest import MockCursor , MockDBApi
6+ from pytest import mark
67from sqlalchemy .engine import url
78from sqlalchemy .sql import text
89
@@ -46,6 +47,7 @@ def test_create_connect_args(self, dialect: FireboltDialect):
4647 with mock .patch .dict (os .environ , {}, clear = True ):
4748 result_list , result_dict = dialect .create_connect_args (u )
4849 assert "api_endpoint" not in result_dict
50+ assert "use_token_cache" not in result_dict
4951 assert result_list == []
5052
5153 def test_create_connect_args_set_params (self , dialect : FireboltDialect ):
@@ -60,6 +62,24 @@ def test_create_connect_args_set_params(self, dialect: FireboltDialect):
6062 ), "account_name was not parsed correctly from connection string"
6163 assert dialect ._set_parameters == {"param1" : "1" , "param2" : "2" }
6264
65+ @mark .parametrize (
66+ "token,expected" , [("false" , False ), ("0" , False ), ("true" , True )]
67+ )
68+ def test_create_connect_args_token_cache (
69+ self , token , expected , dialect : FireboltDialect
70+ ):
71+ connection_url = (
72+ "test_engine://test_user@email:test_password@test_db_name/test_engine_name"
73+ f"?use_token_cache={ token } ¶m1=1¶m2=2"
74+ )
75+ u = url .make_url (connection_url )
76+ result_list , result_dict = dialect .create_connect_args (u )
77+ assert (
78+ "use_token_cache" in result_dict
79+ ), "use_token_cache was not parsed correctly from connection string"
80+ assert result_dict ["use_token_cache" ] == expected
81+ assert dialect ._set_parameters == {"param1" : "1" , "param2" : "2" }
82+
6383 def test_do_execute (
6484 self , dialect : FireboltDialect , cursor : mock .Mock (spec = MockCursor )
6585 ):
0 commit comments