25
25
26
26
class SqlAlchemyConnectionTest (TestCase ):
27
27
28
- def setUp (self ):
29
- self .engine = sa .create_engine ('crate://' )
30
- self .connection = self .engine .connect ()
31
-
32
28
def test_default_connection (self ):
33
29
engine = sa .create_engine ('crate://' )
34
30
conn = engine .raw_connection ()
35
31
self .assertEqual ("<Connection <Client ['http://127.0.0.1:4200']>>" ,
36
32
repr (conn .connection ))
37
33
38
- def test_connection_server (self ):
34
+ def test_connection_server_uri_http (self ):
39
35
engine = sa .create_engine (
40
36
"crate://otherhost:19201" )
41
37
conn = engine .raw_connection ()
42
38
self .assertEqual ("<Connection <Client ['http://otherhost:19201']>>" ,
43
39
repr (conn .connection ))
44
40
45
- def test_connection_multiple_server (self ):
41
+ def test_connection_server_uri_https (self ):
42
+ engine = sa .create_engine (
43
+ "crate://otherhost:19201/?ssl=true" )
44
+ conn = engine .raw_connection ()
45
+ self .assertEqual ("<Connection <Client ['https://otherhost:19201']>>" ,
46
+ repr (conn .connection ))
47
+
48
+ def test_connection_server_uri_https_with_trusted_user (self ):
49
+ engine = sa .create_engine (
50
+ "crate://foo@otherhost:19201/?ssl=true" )
51
+ conn = engine .raw_connection ()
52
+ self .assertEqual ("<Connection <Client ['https://otherhost:19201']>>" ,
53
+ repr (conn .connection ))
54
+ self .assertEqual (conn .connection .client .username , "foo" )
55
+ self .assertEqual (conn .connection .client .password , None )
56
+
57
+ def test_connection_server_uri_https_with_credentials (self ):
58
+ engine = sa .create_engine (
59
+ "crate://foo:bar@otherhost:19201/?ssl=true" )
60
+ conn = engine .raw_connection ()
61
+ self .assertEqual ("<Connection <Client ['https://otherhost:19201']>>" ,
62
+ repr (conn .connection ))
63
+ self .assertEqual (conn .connection .client .username , "foo" )
64
+ self .assertEqual (conn .connection .client .password , "bar" )
65
+
66
+ def test_connection_multiple_server_http (self ):
46
67
engine = sa .create_engine (
47
68
"crate://" , connect_args = {
48
69
'servers' : ['localhost:4201' , 'localhost:4202' ]
@@ -53,3 +74,16 @@ def test_connection_multiple_server(self):
53
74
"<Connection <Client ['http://localhost:4201', " +
54
75
"'http://localhost:4202']>>" ,
55
76
repr (conn .connection ))
77
+
78
+ def test_connection_multiple_server_https (self ):
79
+ engine = sa .create_engine (
80
+ "crate://" , connect_args = {
81
+ 'servers' : ['localhost:4201' , 'localhost:4202' ],
82
+ 'ssl' : True ,
83
+ }
84
+ )
85
+ conn = engine .raw_connection ()
86
+ self .assertEqual (
87
+ "<Connection <Client ['https://localhost:4201', " +
88
+ "'https://localhost:4202']>>" ,
89
+ repr (conn .connection ))
0 commit comments