Skip to content

Commit c3a35ea

Browse files
author
DanielePalaia
committed
test
1 parent 2651308 commit c3a35ea

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

tests/conftest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ def environment_auth(pytestconfig):
4646
uri="amqp://localhost:5672",
4747
oauth2_options=OAuth2Options(token=token_string),
4848
)
49-
# try:
50-
return environment
49+
try:
50+
yield environment
5151

52-
# finally:
53-
# environment.close()
52+
finally:
53+
environment.close()
5454

5555

5656
@pytest.fixture()

tests/test_connection.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from rabbitmq_amqp_python_client import (
55
ConnectionClosed,
66
Environment,
7+
QuorumQueueSpecification,
78
RecoveryConfiguration,
89
StreamSpecification,
910
ValidationCodeException,
@@ -47,6 +48,27 @@ def test_connection_auth(environment_auth: Environment) -> None:
4748

4849
connection = environment_auth.connection()
4950
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(3)
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
5072
connection.close()
5173

5274

0 commit comments

Comments
 (0)