22
33from rabbitmq_amqp_python_client import (
44 ClientCert ,
5- Connection ,
65 ConnectionClosed ,
76 Environment ,
87 SslConfigurationContext ,
@@ -20,43 +19,45 @@ def on_disconnected():
2019
2120
2221def test_connection () -> None :
23- environment = Environment ()
24- connection = environment .connection ("amqp://guest:guest@localhost:5672/" )
22+ environment = Environment (uri = "amqp://guest:guest@localhost:5672/" )
23+ connection = environment .connection ()
2524 connection .dial ()
2625 environment .close ()
2726
2827
2928def test_environment_context_manager () -> None :
30- with Environment () as environment :
31- connection = environment .connection ("amqp://guest:guest@localhost:5672/" )
29+ with Environment (uri = "amqp://guest:guest@localhost:5672/" ) as environment :
30+ connection = environment .connection ()
3231 connection .dial ()
3332
3433
3534def test_connection_ssl () -> None :
36- environment = Environment ()
3735 ca_cert_file = ".ci/certs/ca_certificate.pem"
3836 client_cert = ".ci/certs/client_certificate.pem"
3937 client_key = ".ci/certs/client_key.pem"
40- connection = environment .connection (
38+
39+ environment = Environment (
4140 "amqps://guest:guest@localhost:5671/" ,
4241 ssl_context = SslConfigurationContext (
4342 ca_cert = ca_cert_file ,
4443 client_cert = ClientCert (client_cert = client_cert , client_key = client_key ),
4544 ),
4645 )
46+
47+ connection = environment .connection ()
4748 connection .dial ()
4849
4950 environment .close ()
5051
5152
5253def test_environment_connections_management () -> None :
5354
54- environment = Environment ()
55- connection = environment .connection ("amqp://guest:guest@localhost:5672/" )
55+ environment = Environment (uri = "amqp://guest:guest@localhost:5672/" )
56+ connection = environment .connection ()
5657 connection .dial ()
57- connection2 = environment .connection ("amqp://guest:guest@localhost:5672/" )
58+ connection2 = environment .connection ()
5859 connection2 .dial ()
59- connection3 = environment .connection ("amqp://guest:guest@localhost:5672/" )
60+ connection3 = environment .connection ()
6061 connection3 .dial ()
6162
6263 assert environment .active_connections == 3
@@ -89,17 +90,17 @@ def on_disconnected():
8990
9091 # reconnect
9192 if connection is not None :
92- connection = Connection ( "amqp://guest:guest@localhost:5672/" )
93+ connection = environment . connection ( )
9394 connection .dial ()
9495
9596 nonlocal reconnected
9697 reconnected = True
9798
98- environment = Environment ()
99-
100- connection = environment .connection (
99+ environment = Environment (
101100 "amqp://guest:guest@localhost:5672/" , on_disconnection_handler = on_disconnected
102101 )
102+
103+ connection = environment .connection ()
103104 connection .dial ()
104105
105106 # delay
0 commit comments