Skip to content

Commit 6abf9a9

Browse files
committed
vhost not exists test
1 parent bceb065 commit 6abf9a9

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

tests/test_connection.py

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,15 @@
1515
ValidationCodeException,
1616
WinSslConfigurationContext,
1717
)
18+
from rabbitmq_amqp_python_client.qpid.proton import (
19+
ConnectionException,
20+
)
1821

19-
from .http_requests import delete_all_connections
20-
from .http_requests import create_vhost, delete_vhost
22+
from .http_requests import (
23+
create_vhost,
24+
delete_all_connections,
25+
delete_vhost,
26+
)
2127
from .utils import token
2228

2329

@@ -127,7 +133,7 @@ def test_connection_oauth_refresh_token(environment_auth: Environment) -> None:
127133

128134

129135
def test_connection_oauth_refresh_token_with_disconnection(
130-
environment_auth: Environment
136+
environment_auth: Environment,
131137
) -> None:
132138

133139
connection = environment_auth.connection()
@@ -243,8 +249,25 @@ def test_connection_vhost() -> None:
243249
environment = Environment(uri=uri)
244250
connection = environment.connection()
245251
connection.dial()
246-
is_correct_vhost = connection._conn.conn.hostname == 'vhost:{}'.format(vhost)
252+
is_correct_vhost = connection._conn.conn.hostname == "vhost:{}".format(vhost)
247253
environment.close()
248254
delete_vhost(vhost)
249255

250-
assert is_correct_vhost is True
256+
assert is_correct_vhost is True
257+
258+
259+
def test_connection_vhost_not_exists() -> None:
260+
261+
exception = False
262+
263+
vhost = "tmpVhost" + str(time.time())
264+
uri = "amqp://guest:guest@localhost:5672/{}".format(vhost)
265+
266+
environment = Environment(uri=uri)
267+
try:
268+
connection = environment.connection()
269+
connection.dial()
270+
except ConnectionException:
271+
exception = True
272+
273+
assert exception is True

0 commit comments

Comments
 (0)