summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatus Valo <matusvalo@gmail.com>2020-09-13 21:58:27 +0200
committerAsif Saif Uddin <auvipy@gmail.com>2020-09-14 10:45:26 +0600
commit0c838416a92722646c7aef7607dbfb0678654bde (patch)
treef08a218546c1fbbdd96321e0ea72fb36a18ed3ec
parent1843521745ca075d683be9f64d09c8f98c6e648c (diff)
downloadpy-amqp-0c838416a92722646c7aef7607dbfb0678654bde.tar.gz
Explicitely test userid, pass and vhost in repr() tests
-rw-r--r--t/unit/test_connection.py28
1 files changed, 22 insertions, 6 deletions
diff --git a/t/unit/test_connection.py b/t/unit/test_connection.py
index 7685f05..4515585 100644
--- a/t/unit/test_connection.py
+++ b/t/unit/test_connection.py
@@ -503,17 +503,33 @@ class test_Connection:
self.conn.server_properties['capabilities'] = {'foo': 1}
assert self.conn.server_capabilities == {'foo': 1}
- def test_repr_disconnected(self):
+ @pytest.mark.parametrize(
+ 'conn_kwargs,expected_vhost', [
+ ({}, '/'),
+ ({'user_id': 'test_user', 'password': 'test_pass'}, '/'),
+ ({'virtual_host': 'test_vhost'}, 'test_vhost')
+ ]
+ )
+ def test_repr_disconnected(self, conn_kwargs, expected_vhost):
assert re.fullmatch(
- r'<AMQP Connection: broker.com:1234// \(disconnected\) at 0x.*>',
- repr(Connection(host='broker.com:1234'))
+ r'<AMQP Connection: broker.com:1234/{} '
+ r'\(disconnected\) at 0x.*>'.format(expected_vhost),
+ repr(Connection(host='broker.com:1234', **conn_kwargs))
)
- def test_repr_connected(self):
- c = Connection(host='broker.com:1234')
+ @pytest.mark.parametrize(
+ 'conn_kwargs,expected_vhost', [
+ ({}, '/'),
+ ({'user_id': 'test_user', 'password': 'test_pass'}, '/'),
+ ({'virtual_host': 'test_vhost'}, 'test_vhost')
+ ]
+ )
+ def test_repr_connected(self, conn_kwargs, expected_vhost):
+ c = Connection(host='broker.com:1234', **conn_kwargs)
c._transport = Mock(name='transport')
assert re.fullmatch(
- r'<AMQP Connection: broker.com:1234// using {} at 0x.*>'.format(
+ r'<AMQP Connection: broker.com:1234/{} using {} at 0x.*>'.format(
+ expected_vhost,
repr(c.transport)
),
repr(c)