File tree 2 files changed +26
-4
lines changed
2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -46,11 +46,11 @@ def environment_auth(pytestconfig):
46
46
uri = "amqp://localhost:5672" ,
47
47
oauth2_options = OAuth2Options (token = token_string ),
48
48
)
49
- # try:
50
- return environment
49
+ try :
50
+ yield environment
51
51
52
- # finally:
53
- # environment.close()
52
+ finally :
53
+ environment .close ()
54
54
55
55
56
56
@pytest .fixture ()
Original file line number Diff line number Diff line change 4
4
from rabbitmq_amqp_python_client import (
5
5
ConnectionClosed ,
6
6
Environment ,
7
+ QuorumQueueSpecification ,
7
8
RecoveryConfiguration ,
8
9
StreamSpecification ,
9
10
ValidationCodeException ,
@@ -47,6 +48,27 @@ def test_connection_auth(environment_auth: Environment) -> None:
47
48
48
49
connection = environment_auth .connection ()
49
50
connection .dial ()
51
+ management = connection .management ()
52
+ management .declare_queue (QuorumQueueSpecification (name = "test-queue" ))
53
+ management .close ()
54
+ connection .close ()
55
+
56
+
57
+ def test_connection_auth_with_timeout (environment_auth : Environment ) -> None :
58
+
59
+ connection = environment_auth .connection ()
60
+ connection .dial ()
61
+ # let the token expire
62
+ time .sleep (2 )
63
+ raised = False
64
+ # token expired
65
+ try :
66
+ management = connection .management ()
67
+ management .declare_queue (QuorumQueueSpecification (name = "test-queue" ))
68
+ except Exception :
69
+ raised = True
70
+
71
+ assert raised is True
50
72
connection .close ()
51
73
52
74
You can’t perform that action at this time.
0 commit comments