@@ -19,12 +19,12 @@ def setup(self):
19
19
@pytest .mark .parametrize (
20
20
'url, expected_args, expected_kwargs' ,
21
21
[
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
+
26
25
(make_url ('trino://user@localhost:8080' ),
27
26
list (), dict (host = 'localhost' , port = 8080 , catalog = 'system' , user = 'user' )),
27
+
28
28
(make_url ('trino://user:pass@localhost:8080' ),
29
29
list (), dict (host = 'localhost' , port = 8080 , catalog = 'system' , user = 'user' ,
30
30
auth = BasicAuthentication ('user' , 'pass' ), http_scheme = 'https' )),
@@ -36,6 +36,18 @@ def test_create_connect_args(self, url: URL, expected_args: List[Any], expected_
36
36
assert_that (actual_args ).is_equal_to (expected_args )
37
37
assert_that (actual_kwargs ).is_equal_to (expected_kwargs )
38
38
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
+
39
51
def test_get_default_isolation_level (self ):
40
52
isolation_level = self .dialect .get_default_isolation_level (mock .Mock ())
41
53
assert_that (isolation_level ).is_equal_to ('AUTOCOMMIT' )
0 commit comments