@@ -19,12 +19,12 @@ def setup(self):
1919 @pytest .mark .parametrize (
2020 'url, expected_args, expected_kwargs' ,
2121 [
22- (make_url ('trino://localhost' ),
23- list (), dict (host = 'localhost' , catalog = 'system' , user = 'anonymous' )),
24- (make_url ('trino://1.2.3.4:4321/mysql/sakila' ),
25- list (), dict (host = '1.2.3.4' , port = 4321 , catalog = 'mysql' , schema = 'sakila' , user = 'anonymous' )),
22+ (make_url ('trino://user@localhost' ),
23+ list (), dict (host = 'localhost' , catalog = 'system' , user = 'user' )),
24+
2625 (make_url ('trino://user@localhost:8080' ),
2726 list (), dict (host = 'localhost' , port = 8080 , catalog = 'system' , user = 'user' )),
27+
2828 (make_url ('trino://user:pass@localhost:8080' ),
2929 list (), dict (host = 'localhost' , port = 8080 , catalog = 'system' , user = 'user' ,
3030 auth = BasicAuthentication ('user' , 'pass' ), http_scheme = 'https' )),
@@ -36,6 +36,18 @@ def test_create_connect_args(self, url: URL, expected_args: List[Any], expected_
3636 assert_that (actual_args ).is_equal_to (expected_args )
3737 assert_that (actual_kwargs ).is_equal_to (expected_kwargs )
3838
39+ def test_create_connect_args_missing_user_when_specify_password (self ):
40+ url = make_url ('trino://:pass@localhost' )
41+ assert_that (self .dialect .create_connect_args ).raises (ValueError ) \
42+ .when_called_with (url ) \
43+ .is_equal_to ('Username is required when specify password in connection URL' )
44+
45+ def test_create_connect_args_wrong_db_format (self ):
46+ url = make_url ('trino://abc@localhost/catalog/schema/foobar' )
47+ assert_that (self .dialect .create_connect_args ).raises (ValueError ) \
48+ .when_called_with (url ) \
49+ .is_equal_to ('Unexpected database format catalog/schema/foobar' )
50+
3951 def test_get_default_isolation_level (self ):
4052 isolation_level = self .dialect .get_default_isolation_level (mock .Mock ())
4153 assert_that (isolation_level ).is_equal_to ('AUTOCOMMIT' )
0 commit comments