Skip to content

Commit

Permalink
Fix host and port to use the ENV
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Hagstedt committed Nov 28, 2018
1 parent 85a7bb9 commit 5cb1efa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
6 changes: 4 additions & 2 deletions aioamqp/tests/test_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AmqpConnectionTestCase(testcase.RabbitTestCase, unittest.TestCase):

@testing.coroutine
def test_connect(self):
_transport, proto = yield from connect(virtualhost=self.vhost, loop=self.loop)
_transport, proto = yield from connect(host=self.host, port=self.port, virtualhost=self.vhost, loop=self.loop)
self.assertEqual(proto.state, OPEN)
self.assertIsNotNone(proto.server_properties)
yield from proto.close()
Expand All @@ -25,6 +25,8 @@ def test_connect_tuning(self):
channel_max = 10
heartbeat = 100
_transport, proto = yield from connect(
host=self.host,
port=self.port,
virtualhost=self.vhost,
loop=self.loop,
channel_max=channel_max,
Expand All @@ -48,7 +50,7 @@ def test_connect_tuning(self):

@testing.coroutine
def test_socket_nodelay(self):
transport, proto = yield from connect(virtualhost=self.vhost, loop=self.loop)
transport, proto = yield from connect(host=self.host, port=self.port, virtualhost=self.vhost, loop=self.loop)
sock = transport.get_extra_info('socket')
opt_val = sock.getsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY)
self.assertNotEqual(opt_val, 0)
Expand Down
8 changes: 5 additions & 3 deletions aioamqp/tests/test_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ProtocolTestCase(testcase.RabbitTestCase, unittest.TestCase):

@testing.coroutine
def test_connect(self):
_transport, protocol = yield from amqp_connect(virtualhost=self.vhost, loop=self.loop)
_transport, protocol = yield from amqp_connect(host=self.host, port=self.port, virtualhost=self.vhost, loop=self.loop)
self.assertEqual(protocol.state, OPEN)
yield from protocol.close()

Expand All @@ -30,6 +30,8 @@ def test_connect_products_info(self):
'program_version': '0.1.1',
}
_transport, protocol = yield from amqp_connect(
host=self.host,
port=self.port,
virtualhost=self.vhost,
client_properties=client_properties,
loop=self.loop,
Expand All @@ -41,11 +43,11 @@ def test_connect_products_info(self):
@testing.coroutine
def test_connection_unexistant_vhost(self):
with self.assertRaises(exceptions.AmqpClosedConnection):
yield from amqp_connect(virtualhost='/unexistant', loop=self.loop)
yield from amqp_connect(host=self.host, port=self.port, virtualhost='/unexistant', loop=self.loop)

def test_connection_wrong_login_password(self):
with self.assertRaises(exceptions.AmqpClosedConnection):
self.loop.run_until_complete(amqp_connect(login='wrong', password='wrong', loop=self.loop))
self.loop.run_until_complete(amqp_connect(host=self.host, port=self.port, login='wrong', password='wrong', loop=self.loop))

@testing.coroutine
def test_connection_from_url(self):
Expand Down
2 changes: 1 addition & 1 deletion aioamqp/tests/testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def setUp(self):
self.port = os.environ.get('AMQP_PORT', 5672)
self.vhost = os.environ.get('AMQP_VHOST', self.VHOST + str(uuid.uuid4()))
self.http_client = pyrabbit.api.Client(
'localhost:15672/api/', 'guest', 'guest', timeout=20
'{HOST}:15672/api/'.format(HOST=self.host), 'guest', 'guest', timeout=20
)

self.amqps = []
Expand Down

0 comments on commit 5cb1efa

Please sign in to comment.